Пример #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
Пример #2
0
def gen(max_amp, prev_dur):
    dist_pool = {0, 1, 2}
    dur_pool = {0.5, 1, 2}
    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
Пример #3
0
 def test_init_dur(self):
     with self.assertRaises(AssertionError):
         Note(1, 0, [])
Пример #4
0
 def test_init_del(self):
     with self.assertRaises(AssertionError):
         Note(-1, 1, [])