From 1cb555f33519422d7b25ae30124754ed6905c25f Mon Sep 17 00:00:00 2001 From: bordun Date: Fri, 28 Aug 2020 13:26:03 +0200 Subject: [PATCH] midi: add key pressure and channel pressure --- CHANGELOG.md | 5 +++++ resources/docs/docs/midi/midi-messages.md | 22 ++++++++++++++++++++++ src/python/utils.py | 12 ++++++++++-- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 520335b7..ce3575f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## next + +- midi + - added support for channel pressure and key pressure messages + ## 1.0.4 - bug fixes diff --git a/resources/docs/docs/midi/midi-messages.md b/resources/docs/docs/midi/midi-messages.md index c6852caf..92692d77 100644 --- a/resources/docs/docs/midi/midi-messages.md +++ b/resources/docs/docs/midi/midi-messages.md @@ -69,3 +69,25 @@ System exclusive message. - `msg`: hexadecimal sysex data string of the form `f0 ... f7`. You may include placeholders of the form `nn` which will be replaced by `v1, .., vN` respectively. - `v1, .., vN`: values encoded as hexadecimal data strings to include in `msg`. Most probably, you will need to sepcify a [custom module](/docs/custom-module/) in order to convert numeric widget values into the required hexadecimal format. In general, this conversion will be different for each manufacturer / device. + +---- + +#### `/channel_pressure channel pressure` + +Channel pressure event. + +- `channel`: integer between 1 and 16 +- `pressure`: integer between 0 and 127 + +---- + + +#### `/key_pressure channel note pressure` + +Polyphonic key pressure event. + +- `channel`: integer between 1 and 16 +- `note`: integer between 0 and 127 +- `pressure`: integer between 0 and 127 + +---- diff --git a/src/python/utils.py b/src/python/utils.py index bdf01f80..81a8e518 100644 --- a/src/python/utils.py +++ b/src/python/utils.py @@ -6,7 +6,9 @@ MIDI_TO_OSC = { CONTROL_CHANGE: '/control', PROGRAM_CHANGE: '/program', PITCH_BEND: '/pitch', - SYSTEM_EXCLUSIVE: '/sysex' + SYSTEM_EXCLUSIVE: '/sysex', + CHANNEL_PRESSURE: '/channel_pressure', + POLY_PRESSURE: '/key_pressure' } OSC_TO_MIDI = { @@ -14,7 +16,9 @@ OSC_TO_MIDI = { '/control': CONTROL_CHANGE, '/program': PROGRAM_CHANGE, '/pitch': PITCH_BEND, - '/sysex': SYSTEM_EXCLUSIVE + '/sysex': SYSTEM_EXCLUSIVE, + '/channel_pressure': CHANNEL_PRESSURE, + '/key_pressure': POLY_PRESSURE } def midi_str(message): @@ -43,6 +47,10 @@ def midi_str(message): s = 'PROGRAM_CHANGE: channel=%i, program=%i' % (channel, message[1]) elif mtype == PITCH_BEND: s = 'PITCH_BEND: channel=%i, pitch=%i' % (channel, message[1] + message[2] * 128 if len(message) == 3 else message[1]) + elif mtype == CHANNEL_PRESSURE: + s = 'CHANNEL_PRESSURE: channel=%i, pressure=%i' % (channel, message[1]) + elif mtype == POLY_PRESSURE: + s = 'KEY_PRESSURE: channel=%i, note=%i, pressure=%i' % (channel, message[1], message[2]) except IndexError: