def test_events1(self): m = Mispel() model = m.parse( "with channel 2 notedriven :\n a3_8. b-_16 c#3_16.5\\vol{100}\\tempo[vivace] " ) for section in model.sections: event = section.events[0] self.assertEqual(event.cs, None) self.assertTrue(event.__class__.__name__, 'NoteSpec') self.assertEqual(event.ns.name, 'a') self.assertEqual(event.ns.octave, '3') self.assertEqual(event.ns.invdur.value, 8) self.assertListEqual(event.ns.invdur.dots, ['.']) self.assertEqual(event.ns.properties, []) event = section.events[1] self.assertEqual(event.ns.name, 'b-') self.assertEqual(event.ns.octave, None) self.assertEqual(event.ns.invdur.value, 16) self.assertListEqual(event.ns.invdur.dots, []) self.assertEqual(event.ns.properties, []) event = section.events[2] self.assertEqual(event.ns.name, 'c#') self.assertEqual(event.ns.octave, '3') self.assertEqual(event.ns.invdur.value, 16.5) for p in event.ns.properties: if p.avol: self.assertEqual(p.avol.symval, None) self.assertEqual(p.avol.value.value, 100) elif p.stempo: self.assertEqual(p.stempo.symval.symval, 'vivace') self.assertEqual(p.stempo.value, None) self.assertListEqual(m.notes_for_section(0), ["a3", "b-3", "c#3"]) self.assertListEqual(m.durations_for_section(0), [1 / 8 + 1 / 16, 1 / 16, 1 / 16.5])
def test_durationmultiplier(self): m = Mispel() m.parse(r""" with track 0 channel 0: cx4_4*2/3 d3 e-_4 g--_4.*2/3 r_1*10/1 a#2_1*5 """) durs = [d for d in m.durations_for_section(0)] self.assertListEqual( durs, [0.16666666666666666, 0.16666666666666666, 0.25, 0.25, 10.0, 5.0])
def test_drumnotes(self): m = Mispel() m.parse(r""" with track 0 channel 11: bassdrum_4 openhihat_8*2/3 openhihat ohh """) notes = m.notes_for_section(0) self.assertListEqual(notes, ['bassdrum', 'openhihat', 'openhihat', 'ohh']) durs = m.durations_for_section(0) self.assertListEqual(durs, [ 0.25, 0.08333333333333333, 0.08333333333333333, 0.08333333333333333 ])