midi: pc_offset option

This commit is contained in:
jean-emmanuel 2019-04-27 00:28:37 +02:00
parent 9a5f049d45
commit 8ea006a8d7
3 changed files with 13 additions and 2 deletions

View file

@ -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: