diff --git a/CHANGELOG.md b/CHANGELOG.md index 1467261e..116d12a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 1.9.1 + +- midi + - allow sending note off with velocity + - add option for receiving note off with velocity + ## 1.9.0 **Warning** Sessions saved with this version will not open in older versions (sessions saved with older version will open in this version). diff --git a/resources/docs/docs/midi/midi-configuration.md b/resources/docs/docs/midi/midi-configuration.md index 989847f6..f27b4cb5 100644 --- a/resources/docs/docs/midi/midi-configuration.md +++ b/resources/docs/docs/midi/midi-configuration.md @@ -79,13 +79,16 @@ Enable parsing of midi time code messages (disabled by default). **`active_sensing`** -Enable parsing of midi active sensing messages (disabled by default). Active sensing messages will be received as sysex. - +Enable parsing of midi active sensing messages (disabled by default). Active sensing messages will be received as sysex. **`pc_offset`** Send program changes with a `-1` offset to match some software/hardware implementations +**`note_off_velocity`** + +Enable receiving noteOff messages with a velocity and on a different address than noteOn messages. + **`device_name:virtual`** (*Linux / Mac only*): creates a virtual midi device with one input port and one output port @@ -95,7 +98,9 @@ Send program changes with a `-1` offset to match some software/hardware implemen **`path=/path/to/python`** -Indicates where to find python binary in case open stage control doesn't (`Error: spawn python3 ENOENT`). *Only use this if you know what you are doing.* +*Only use this if you know what you are doing. This option should not be set when using the officla Linux / Windows / OSX packages.* + +Indicates where to find python binary in case open stage control doesn't (`Error: spawn python3 ENOENT`). ## Widget setup diff --git a/resources/docs/docs/midi/midi-messages.md b/resources/docs/docs/midi/midi-messages.md index 132e8404..f3e83dd0 100644 --- a/resources/docs/docs/midi/midi-messages.md +++ b/resources/docs/docs/midi/midi-messages.md @@ -5,7 +5,7 @@ #### `/note channel note velocity` -NoteOn event or noteOff if velocity equals `0`. +NoteOn event or noteOff if velocity equals `0`. Incoming noteOff events will be received as `/note` with velocity 0 if `note_off_velocity` is not set during [setup](../midi-configuration). - `channel`: integer between 1 and 16 - `note`: integer between 0 and 127 @@ -23,6 +23,12 @@ NoteOn event or noteOff if velocity equals `0`. ---- +#### `/note_off channel note velocity` + +NoteOff event with any velocity. Incoming noteOff events will be received as `/note_off` if `note_off_velocity` is set during [setup](../midi-configuration). + +---- + #### `/control channel cc value` Control change event. diff --git a/src/python/head.py b/src/python/head.py index cb59c2ec..1c96f5c7 100644 --- a/src/python/head.py +++ b/src/python/head.py @@ -30,4 +30,15 @@ except: if version_info.major == 3: raw_input = input +# option: print debug messages debug = 'debug' in argv +# option: act as if displayed program is between 1-128 instead of 0-127 +program_change_offset = 'pc_offset' in argv +# option: parse sysex +ignore_sysex = 'sysex' not in argv +# option: parse mtc +ignore_mtc = 'mtc' not in argv +# option: parse active sensing +ignore_active_sensing = 'active_sensing' not in argv +# option: note off velocity +note_off_velocity = 'note_off_velocity' in argv diff --git a/src/python/midi.py b/src/python/midi.py index 26aa2bd0..7424e493 100644 --- a/src/python/midi.py +++ b/src/python/midi.py @@ -14,14 +14,6 @@ if 'list-only' in argv: list() exit() -# option: act as if displayed program is between 1-128 instead of 0-127 -PROGRAM_CHANGE_OFFSET = 'pc_offset' in argv -# option: parse sysex -ignore_sysex = 'sysex' not in argv -# option: parse mtc -ignore_mtc = 'mtc' not in argv -# option: parse active sensing -ignore_active_sensing = 'active_sensing' not in argv inputs = {} outputs = {} @@ -140,12 +132,13 @@ def create_callback(name): osc['args'].append({'type': 'i', 'value': channel}) if mtype == NOTE_OFF: - message[2] = 0 + if not note_off_velocity: + message[2] = 0 elif mtype == PITCH_BEND: message = message[:1] + [message[1] + message[2] * 128] # convert 0-127 pair -> 0-16384 -> - elif mtype == PROGRAM_CHANGE and PROGRAM_CHANGE_OFFSET: + elif mtype == PROGRAM_CHANGE and program_change_offset: message[-1] = message[-1] + 1 for data in message[1:]: @@ -245,7 +238,7 @@ def send_midi(name, event, *args): elif mtype == PITCH_BEND: args = args[:1] + [args[1] & 0x7F, (args[1] >> 7) & 0x7F] # convert 0-16384 -> 0-127 pair - elif mtype == PROGRAM_CHANGE and PROGRAM_CHANGE_OFFSET: + elif mtype == PROGRAM_CHANGE and program_change_offset: args[-1] = args[-1] - 1 m = midi_message(mtype, *args) diff --git a/src/python/utils.py b/src/python/utils.py index 8709034b..b911ff1d 100644 --- a/src/python/utils.py +++ b/src/python/utils.py @@ -15,6 +15,7 @@ MIDI_TO_OSC = { OSC_TO_MIDI = { '/note': NOTE_ON, + '/note_off': NOTE_OFF, '/control': CONTROL_CHANGE, '/program': PROGRAM_CHANGE, '/pitch': PITCH_BEND, @@ -24,6 +25,10 @@ OSC_TO_MIDI = { '/key_pressure': POLY_PRESSURE } +if note_off_velocity: + MIDI_TO_OSC[NOTE_OFF] = '/note_off' + + def midi_str(message, port): mtype = message[0] & 0xF0 @@ -48,7 +53,7 @@ def midi_str(message, port): if mtype == NOTE_ON: s = 'NOTE_ON: channel=%i, note=%i, velocity=%i' % (channel, message[1], message[2]) elif mtype == NOTE_OFF: - s = 'NOTE_OFF: channel=%i, note=%i' % (channel, message[1]) + s = 'NOTE_OFF: channel=%i, note=%i, velocity=%i' % (channel, message[1], message[2]) elif mtype == CONTROL_CHANGE: s = 'CONTROL_CHANGE: channel=%i, cc=%i, value=%i'% (channel, message[1], message[2]) elif mtype == PROGRAM_CHANGE: diff --git a/src/server/options.js b/src/server/options.js index 2373da2d..6e13a7c2 100644 --- a/src/server/options.js +++ b/src/server/options.js @@ -51,7 +51,7 @@ module.exports = { }, 'm': {alias: 'midi', type: 'array', describe: 'midi router settings', check: (o)=>{ - var err = o.filter(item=>!item.match(/^(list|debug|jack|sysex|mtc|active_sensing|pc_offset|path=(.*)|[^:]+:(virtual|[^,]+,[^,]+))$/)) + var err = o.filter(item=>!item.match(/^(list|debug|jack|sysex|mtc|active_sensing|note_off_velocity|pc_offset|path=(.*)|[^:]+:(virtual|[^,]+,[^,]+))$/)) return err.length ? `Invalid option${err.length > 1 ? 's' : ''}: ${err.join(', ')}` : true } },