Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: ppaez/alsaseq
base: 88803abfb9
...
head fork: ppaez/alsaseq
compare: f985ef483a
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 111 additions and 2 deletions.
  1. +2 −2 alsamidi.py
  2. +109 −0 test_alsamidi.py
View
4 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,
View
109 test_alsamidi.py
@@ -51,6 +51,82 @@ 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 Tuple2Time(TestCase):
+
+ def test(self):
+ from alsamidi import tuple2time
+
+ self.assertEqual(1.5, tuple2time((1, 500000000)))
+
+
+class Time2Tuple(TestCase):
+
+ def test(self):
+ from alsamidi import time2tuple
+
+ self.assertEqual((1, 500000000), time2tuple(1.5))
+
+
+class ModifyEvent(TestCase):
+
+ def test(self):
+ from alsamidi import modifyevent
+
+ data = (1, 60, 127, 0, 10)
+ event = (5, 1, 0, 0, (1, 0), (0, 0), (0, 0), data)
+ modified_data = (15, 72, 127, 0, 10)
+ modified_event = (5, 1, 0, 250, (2, 0), (2, 0), (3, 0), modified_data)
+ self.assertEqual(modified_event, modifyevent(event, timedelta=1,
+ ch=15, dest=(3, 0), source=(2, 0), queue=250, keydelta=12))
+
+
+class ModifyEvents(TestCase):
+
+ def test(self):
+ from alsamidi import modifyevents
+
+ data = (1, 60, 127, 0, 10)
+ event = (5, 1, 0, 0, (1, 0), (0, 0), (0, 0), data)
+ modified_data = (15, 72, 127, 0, 10)
+ modified_event = (5, 1, 0, 250, (2, 0), (2, 0), (3, 0), modified_data)
+ self.assertEqual([modified_event], modifyevents([event], timedelta=1,
+ ch=15, dest=(3, 0), source=(2, 0), queue=250, keydelta=12))
+
+
class Merge(TestCase):
def test_no_tracks(self):
@@ -64,5 +140,38 @@ def test_track(self):
event = (0, 0, 0, 0, 0)
self.assertEqual([event], merge([[event]]))
+
+class UniqueNotes(TestCase):
+
+ def test(self):
+ from alsamidi import uniquenotes
+
+ data = (1, 60, 127, 0, 10)
+ event = (5, 1, 0, 0, (1, 0), (0, 0), (0, 0), data)
+ expected = {1: [60]}
+ self.assertEqual(expected, uniquenotes([event]))
+
+
+class TestSeq(TestCase):
+
+ def test_instance(self):
+ from alsamidi import Seq
+
+ self.assertTrue(isinstance(Seq(), Seq))
+
+ def test_info(self):
+ from alsamidi import Seq
+
+ data = (9, 60, 127, 0, 10)
+ event = (5, 1, 0, 0, (1, 0), (0, 0), (0, 0), data)
+ track = [event]
+
+ seq = Seq()
+ seq.names = ['name']
+ seq.tags = 'tags'
+ seq.tracks = [track]
+ print(seq.info())
+
+
if __name__ == '__main__':
unittest.main()

No commit comments for this range

Something went wrong with that request. Please try again.