Exemple #1
0
class CyscoreTest(unittest.TestCase):
    note_dummy = Note(1, 1, [2, 3])
    note_correct = '1\t2\t3'
    voice_dummy = Voice('test', [note_dummy] * 2)
    voice_correct_skel = 'i\t\"test\"\t{0}\t' + note_correct
    voice_correct = voice_correct_skel.format(
        0) + '\n' + voice_correct_skel.format(1)
    score_dummy = Score([voice_dummy] * 2)
    score_correct = voice_correct + '\n' + voice_correct
Exemple #2
0
 def test_init_len(self):
     with self.assertRaises(AssertionError):
         Voice('test', [])
Exemple #3
0
 def test_iter(self):
     result = Voice(self.voice_dummy.instr,
                    list(map(lambda x: x.stretch(1), self.voice_dummy)))
     self.assertEqual(result, self.voice_dummy)
Exemple #4
0
    amp_pool = {0.25, 0.5, 1}
    pitch_pool = {50, 100, 150, 200, 250, 300}

    new_max = 1
    dist = sample(dist_pool, 1)[0]
    cond = dist < prev_dur
    if cond:
        amp_pool = set(map(lambda x: x * max_amp, amp_pool))
    dur = sample(dur_pool, 1)[0]
    amp = sample(amp_pool, 1)
    pitch = sample(pitch_pool, 1)

    if cond:
        new_max = max_amp - amp[0]
    return Note(dist, dur, amp + pitch), new_max


n = 10

notes = []
max_amp = 1
prev_dur = 0
for i in range(n):
    note, max_amp = gen(max_amp, prev_dur)
    prev_dur = note.duration
    notes.append(note)

voice = Voice('example', notes)
score = Score([voice])
score.render('example.orc', 'example.sco', 'example.wav')