def test_x2(self): t1 = Track() t1.note(4, 62) t1.note(4, 60) t1.note(2, 62) t2 = Track() t2.note(1, 60) m = MidiEventStream(t1, t2) self.assertEquals( "p0:0 p1:0 v0:100 n0:62 n0:60 d1/4 o62 v1:100 n1:60 d1/4 o60 n0:62 d1/2 o62 o60", m.str_repr(1))
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))
def test_midi_overlap(self): t1 = Track() t1.note(8, 92, 121) t1.note(8, 90, 122) t1.note(8, 92, 123) t1.note(8, 94, 124) t2 = Track() t2.note(2, 90, 120) m = MidiEventStream(t1, t2) self.assertEquals( "p0:0 p1:0 v0:100 n0:92 n0:90 d1/8 o92 v1:100 n1:90 d1/8 o90 n0:92 d1/8 o92 n0:94 d1/8 o94 o90", m.str_repr(1))
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))
def test_x1(self): t1 = Track() t1.set_patch(1) t1.note(4, 60) t1.set_patch(2) t1.note(4, 60) t1.set_patch(3) t1.note(4, 60) t1.set_patch(4) t1.note(4, 60) m = MidiEventStream(t1) self.assertEquals( "p0:1 p1:2 p2:3 p3:4 v0:100 n0:60 d1/4 o60 v1:100 n1:60 d1/4 o60 v2:100 n2:60 d1/4 o60 v3:100 n3:60 d1/4 o60", m.str_repr(1))
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_midi_overlap(self): t1 = Track() t1.note(8, 92, 121) t1.note(8, 90, 122) t1.note(8, 92, 123) t1.note(8, 94, 124) t2 = Track() t2.note(2, 90, 120) m = MidiEventStream(t1, t2) self.assertEqual("p0:0 p1:0 v0:100 n0:92 n0:90 d1/8 o92 v1:100 n1:90 d1/8 o90 n0:92 d1/8 o92 n0:94 d1/8 o94 o90", m.str_repr(1))
def test_x2(self): t1 = Track() t1.note(4, 62) t1.note(4, 60) t1.note(2, 62) t2 = Track() t2.note(1, 60) m = MidiEventStream(t1, t2) self.assertEqual("p0:0 p1:0 v0:100 n0:62 n0:60 d1/4 o62 v1:100 n1:60 d1/4 o60 n0:62 d1/2 o62 o60", m.str_repr(1))
def test_x1(self): t1 = Track() t1.set_patch(1) t1.note(4, 60) t1.set_patch(2) t1.note(4, 60) t1.set_patch(3) t1.note(4, 60) t1.set_patch(4) t1.note(4, 60) m = MidiEventStream(t1) self.assertEqual("p0:1 p1:2 p2:3 p3:4 v0:100 n0:60 d1/4 o60 v1:100 n1:60 d1/4 o60 v2:100 n2:60 d1/4 o60 v3:100 n3:60 d1/4 o60", m.str_repr(1))