midi: pc_offset option
This commit is contained in:
parent
bc1e6e13d1
commit
3d9dd22a05
3 changed files with 13 additions and 2 deletions
|
|
@ -5,6 +5,9 @@ from utils import *
|
|||
if 'list' in argv:
|
||||
list()
|
||||
|
||||
# option: act as if displayed program is between 1-128 instead of 0-127
|
||||
PROGRAM_CHANGE_OFFSET = 'pc_offset' in argv
|
||||
|
||||
inputs = {}
|
||||
outputs = {}
|
||||
|
||||
|
|
@ -83,6 +86,9 @@ def create_callback(name):
|
|||
if mtype == NOTE_OFF:
|
||||
message[2] = 0
|
||||
|
||||
elif mtype is PROGRAM_CHANGE and PROGRAM_CHANGE_OFFSET:
|
||||
message[-1] = message[-1] + 1
|
||||
|
||||
for data in message[1:]:
|
||||
osc['args'].append({'type': 'i', 'value': data})
|
||||
|
||||
|
|
@ -174,6 +180,9 @@ def send_midi(name, event, *args):
|
|||
elif mtype is PITCH_BEND:
|
||||
args = args[:1] + [args[1] & 0x7f, (args[1] >> 7) & 0x7f] # convert 0-16384 -> 0-127 pair
|
||||
|
||||
elif mtype is PROGRAM_CHANGE and PROGRAM_CHANGE_OFFSET:
|
||||
args[-1] = args[-1] - 1
|
||||
|
||||
m = midi_message(mtype, *args)
|
||||
|
||||
if m is None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue