Пример #1
0
 def test_str_repr(self):
     t1 = Track()
     t1.set_volume(88)
     t1.set_patch(3)
     t1.note(4, 93, 127)
     t2 = Track()
     t2.set_patch(4)
     t2.note(4, 94, 127)
     t3 = Track()
     t3.set_patch(5)
     t3.note(4, 95, 127)
     self.assertEquals(list(MidiEventStream(t1, t2, t3)),
        [
         ('program-change', 0, 3),
         ('volume', 0, 88),
         ('note-on', 0, 93, 127),
         ('program-change', 1, 4),
         ('volume', 1, 100),
         ('note-on', 1, 94, 127),
         ('program-change', 2, 5),
         ('volume', 2, 100),
         ('note-on', 2, 95, 127),
         ('notelen-time', Rat(1, 4)),
         ('note-off', 0, 93, 127),
         ('note-off', 1, 94, 127),
         ('note-off', 2, 95, 127)])
     self.assertEquals(MidiEventStream(t1, t2, t3).str_repr(details=1),
         "p0:3 v0:88 n0:93 p1:4 v1:100 n1:94 p2:5 v2:100 n2:95 d1/4 o93 o94 o95")
Пример #2
0
 def test_set_volume(self):
     """
     Assert that there is not sendt a new pacth event when we change volume
     """
     t = Track()
     t.set_volume(98)
     t.note(4, 55)
     t.set_volume(99)
     t.note(4, 57)
     self.assertEquals(MidiEventStream(t).str_repr(),
             "p0:0 v0:98 n55 d1/4 o55 v0:99 n57 d1/4 o57")
Пример #3
0
 def test_set_volume(self):
     """
     Assert that there is not sendt a new pacth event when we change volume
     """
     t = Track()
     t.set_volume(98)
     t.note(4, 55)
     t.set_volume(99)
     t.note(4, 57)
     self.assertEquals(
         MidiEventStream(t).str_repr(),
         "p0:0 p1:0 v0:98 n55 d1/4 o55 v1:99 n57 d1/4 o57")
Пример #4
0
 def test_patch_volume_order(self):
     """
     Assert that the order of set_patch and set_volume does not matter.
     """
     t1 = Track()
     t1.set_patch(1)
     t1.set_volume(101)
     t1.note(4, 64)
     self.assertEquals(MidiEventStream(t1).str_repr(details=1), "p0:1 v0:101 n0:64 d1/4 o64")
     # Then with patch and volume in reverse order
     t1 = Track()
     t1.set_volume(101)
     t1.set_patch(1)
     t1.note(4, 64)
     self.assertEquals(MidiEventStream(t1).str_repr(details=1), "p0:1 v0:101 n0:64 d1/4 o64")
Пример #5
0
 def test_patch_volume_order(self):
     """
     Assert that the order of set_patch and set_volume does not matter.
     """
     t1 = Track()
     t1.set_patch(1)
     t1.set_volume(101)
     t1.note(4, 64)
     self.assertEquals(
         MidiEventStream(t1).str_repr(details=1),
         "p0:1 v0:101 n0:64 d1/4 o64")
     # Then with patch and volume in reverse order
     t1 = Track()
     t1.set_volume(101)
     t1.set_patch(1)
     t1.note(4, 64)
     self.assertEquals(
         MidiEventStream(t1).str_repr(details=1),
         "p0:1 v0:101 n0:64 d1/4 o64")
Пример #6
0
 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")
Пример #7
0
 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")
Пример #8
0
 def test_str_repr(self):
     t1 = Track()
     t1.set_volume(88)
     t1.set_patch(3)
     t1.note(4, 93, 127)
     t2 = Track()
     t2.set_patch(4)
     t2.note(4, 94, 127)
     t3 = Track()
     t3.set_patch(5)
     t3.note(4, 95, 127)
     self.assertEqual(list(MidiEventStream(t1, t2, t3)),
                      [('program-change', 0, 3), ('program-change', 1, 4),
                       ('program-change', 2, 5), ('volume', 0, 88),
                       ('note-on', 0, 93, 127), ('volume', 1, 100),
                       ('note-on', 1, 94, 127), ('volume', 2, 100),
                       ('note-on', 2, 95, 127), ('notelen-time', Rat(1, 4)),
                       ('note-off', 0, 93, 127), ('note-off', 1, 94, 127),
                       ('note-off', 2, 95, 127)])
     self.assertEqual(
         MidiEventStream(t1, t2, t3).str_repr(details=1),
         "p0:3 p1:4 p2:5 v0:88 n0:93 v1:100 n1:94 v2:100 n2:95 d1/4 o93 o94 o95"
     )