def test_melodic_interval_2_tracks(self): """ In this test, only MIDI channel 0 will be allocated, even though two different patches and volumes are used. This because the tones from the two tracks does not sound at the same time. """ t1 = Track() t1.set_patch(1) t1.set_volume(101) t1.note(4, 64) t2 = Track() t2.set_patch(2) t2.set_volume(102) t2.notelen_time(4) t2.note(4, 66) self.assertEquals(t1.str_repr(), "p1 v101 n64 d1/4 o64") self.assertEquals(t2.str_repr(), "p2 v102 d1/4 n66 d1/4 o66") m = MidiEventStream(t1, t2) self.assertEquals(m.str_repr(1), "p0:1 v0:101 n0:64 d1/4 o64 p0:2 v0:102 n0:66 d1/4 o66")
def test_melodic_interval_2_tracks(self): """ In this test, only MIDI channel 0 will be allocated, even though two different patches and volumes are used. This because the tones from the two tracks does not sound at the same time. """ t1 = Track() t1.set_patch(1) t1.set_volume(101) t1.note(4, 64) t2 = Track() t2.set_patch(2) t2.set_volume(102) t2.notelen_time(4) t2.note(4, 66) self.assertEquals(t1.str_repr(), "p1 v101 n64 d1/4 o64") self.assertEquals(t2.str_repr(), "p2 v102 d1/4 n66 d1/4 o66") m = MidiEventStream(t1, t2) self.assertEquals( m.str_repr(1), "p0:1 p1:2 v0:101 n0:64 d1/4 o64 v1:102 n1:66 d1/4 o66")
def test_add(self): t1 = Track() t1.note(8, 92, 121) self.assertEqual("n92 d1/8 o92", t1.str_repr()) t2 = Track() t2.note(2, 90, 120) self.assertEqual("n90 d1/2 o90", t2.str_repr()) self.assertEqual("n92 d1/8 o92", t1.str_repr()) self.assertEqual("n90 d1/2 o90", t2.str_repr()) m1 = MidiEventStream(t1) m2 = MidiEventStream(t2) t3 = t1 + t2 self.assertEqual("n92 d1/8 o92 n90 d1/2 o90", t3.str_repr()) m3 = MidiEventStream(t3) self.assertEqual("n92 d1/8 o92", t1.str_repr()) self.assertEqual("n90 d1/2 o90", t2.str_repr()) # FIXME volume bug? self.assertEqual("p0:0 v0:100 n0:92 d1/8 o92", m1.str_repr(1)) self.assertEqual("p0:0 v0:100 n0:90 d1/2 o90", m2.str_repr(1)) self.assertEqual("p0:0 v0:100 n0:92 d1/8 o92 n0:90 d1/2 o90", m3.str_repr(1))