diff --git a/alsamidi.py b/alsamidi.py index 9610d7e..88e58df 100755 --- a/alsamidi.py +++ b/alsamidi.py @@ -95,7 +95,7 @@ def pitchbendevent( ch, value, start = -1 ): if start < 0: return ( alsaseq.SND_SEQ_EVENT_PITCHBEND, alsaseq.SND_SEQ_TIME_STAMP_REAL, - 0, SND_SEQ_QUEUE_DIRECT, ( start/1000, start%1000 * 1000000), + 0, SND_SEQ_QUEUE_DIRECT, (0, 0), ( 0, 0 ), ( 0,0 ), ( ch, 0, value ) ) else: return ( alsaseq.SND_SEQ_EVENT_PITCHBEND, alsaseq.SND_SEQ_TIME_STAMP_REAL, @@ -110,7 +110,7 @@ def chanpress( ch, value, start = -1 ): if start < 0: return ( alsaseq.SND_SEQ_EVENT_CHANPRESS, alsaseq.SND_SEQ_TIME_STAMP_REAL, - 0, SND_SEQ_QUEUE_DIRECT, ( start/1000, start%1000 * 1000000), + 0, SND_SEQ_QUEUE_DIRECT, (0, 0), ( 0, 0 ), ( 0,0 ), ( ch, 0, value ) ) else: return ( alsaseq.SND_SEQ_EVENT_CHANPRESS, alsaseq.SND_SEQ_TIME_STAMP_REAL, diff --git a/test_alsamidi.py b/test_alsamidi.py index 25e566b..cd26994 100644 --- a/test_alsamidi.py +++ b/test_alsamidi.py @@ -51,6 +51,40 @@ def test_scheduled(self): self.assertEqual(expected, pgmchangeevent(1, 9, 1000)) +class PitchbendEvent(TestCase): + + def test_sent_directly(self): + from alsamidi import pitchbendevent + + data = (1, 0, 9) + expected = (13, 1, 0, 253, (0, 0), (0, 0), (0, 0), data) + self.assertEqual(expected, pitchbendevent(1, 9)) + + def test_scheduled(self): + from alsamidi import pitchbendevent + + data = (1, 0, 9) + expected = (13, 1, 0, 0, (1, 0), (0, 0), (0, 0), data) + self.assertEqual(expected, pitchbendevent(1, 9, 1000)) + + +class ChanPress(TestCase): + + def test_sent_directly(self): + from alsamidi import chanpress + + data = (1, 0, 9) + expected = (12, 1, 0, 253, (0, 0), (0, 0), (0, 0), data) + self.assertEqual(expected, chanpress(1, 9)) + + def test_scheduled(self): + from alsamidi import chanpress + + data = (1, 0, 9) + expected = (12, 1, 0, 0, (1, 0), (0, 0), (0, 0), data) + self.assertEqual(expected, chanpress(1, 9, 1000)) + + class Merge(TestCase): def test_no_tracks(self):