Skip to content

Commit

Permalink
Use running status when available
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitov committed Feb 7, 2017
1 parent a36e169 commit dd35f65
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion samplerbox.py
Expand Up @@ -460,13 +460,17 @@ def display(s, l):

def MidiSerialCallback():
message = [0, 0, 0]
runningstatus = 0
while True:
i = 0
while i < 3:
data = ord(ser.read(1)) # read a byte
print data
if data >> 7 != 0:
i = 0 # status byte! this is the beginning of a midi message: http://www.midi.org/techspecs/midimessages.php
runningstatus = data
elif i == 0 and runningstatus > 0: # use stored running status if available
message[i] = runningstatus
i += 1
message[i] = data
i += 1
if i == 2 and message[0] >> 4 == 12: # program change: don't wait for a third byte: it has only 2 bytes
Expand Down

0 comments on commit dd35f65

Please sign in to comment.