midi: fix receiving pitchbend messages

This commit is contained in:
bordun 2019-07-19 10:34:57 +02:00
parent b6da8333a0
commit a459ec0f0a
3 changed files with 5 additions and 2 deletions

View file

@ -86,6 +86,9 @@ def create_callback(name):
if mtype == NOTE_OFF:
message[2] = 0
elif mtype is PITCH_BEND:
message = message[:1] + [message[1] + message[2] * 128] # convert 0-127 pair -> 0-16384 ->
elif mtype is PROGRAM_CHANGE and PROGRAM_CHANGE_OFFSET:
message[-1] = message[-1] + 1

View file

@ -42,8 +42,7 @@ def midi_str(message):
elif mtype is PROGRAM_CHANGE:
s = 'PROGRAM_CHANGE: channel=%i, program=%i' % (channel, message[1])
elif mtype is PITCH_BEND:
print(channel, message)
s = 'PITCH_BEND: channel=%i, pitch=%i' % (channel, message[1] + message[2] * 128)
s = 'PITCH_BEND: channel=%i, pitch=%i' % (channel, message[1] + message[2] * 128 if len(message) == 3 else message[1])
except IndexError: