Skip to content

Commit

Permalink
Fixed a bug found by the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ppaez committed Jan 20, 2014
1 parent 88803ab commit f9e5518
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
4 changes: 2 additions & 2 deletions alsamidi.py
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
34 changes: 34 additions & 0 deletions test_alsamidi.py
Expand Up @@ -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):
Expand Down

0 comments on commit f9e5518

Please sign in to comment.