midi: fix receiving pitchbend messages
This commit is contained in:
parent
4af045fbd8
commit
33fac98f64
3 changed files with 5 additions and 2 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue