From 4da68c3f4f48f10826253f1ed2a7437e2a8dd124 Mon Sep 17 00:00:00 2001 From: dreamer Date: Mon, 20 Nov 2023 09:26:49 +0100 Subject: [PATCH] add polytouchin/out to daisy --- CHANGELOG.md | 2 +- hvcc/generators/c2daisy/c2daisy.py | 1 + .../c2daisy/templates/HeavyDaisy.cpp | 26 +++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8707b17..9f2171f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Next Release * Objects: `[bang~]` * Documentation fixes/additions * Daisy: ability to set samplerate and blocksize -* Daisy: midirealtimein support +* Daisy: adding midirealtimein, polytouchin/out * DPF: enum for UI parameter IDs * DPF bugfixes: correct input PortGroup names; correct UI slider updates * Cleanup: remove deprecated build.json diff --git a/hvcc/generators/c2daisy/c2daisy.py b/hvcc/generators/c2daisy/c2daisy.py index 524708ae..693d5312 100644 --- a/hvcc/generators/c2daisy/c2daisy.py +++ b/hvcc/generators/c2daisy/c2daisy.py @@ -13,6 +13,7 @@ hv_midi_messages = { "__hv_noteout", "__hv_ctlout", + "__hv_polytouchout", "__hv_pgmout", "__hv_touchout", "__hv_bendout", diff --git a/hvcc/generators/c2daisy/templates/HeavyDaisy.cpp b/hvcc/generators/c2daisy/templates/HeavyDaisy.cpp index 244234ca..90d20d10 100644 --- a/hvcc/generators/c2daisy/templates/HeavyDaisy.cpp +++ b/hvcc/generators/c2daisy/templates/HeavyDaisy.cpp @@ -9,6 +9,7 @@ {% if has_midi or usb_midi %} #define HV_HASH_NOTEIN 0x67E37CA3 #define HV_HASH_CTLIN 0x41BE0f9C +#define HV_HASH_POLYTOUCHIN 0xBC530F59 #define HV_HASH_PGMIN 0x2E1EA03D #define HV_HASH_TOUCHIN 0x553925BD #define HV_HASH_BENDIN 0x3083F0F7 @@ -17,6 +18,7 @@ #define HV_HASH_NOTEOUT 0xD1D4AC2 #define HV_HASH_CTLOUT 0xE5e2A040 +#define HV_HASH_POLYTOUCHOUT 0xD5ACA9D1 #define HV_HASH_PGMOUT 0x8753E39E #define HV_HASH_TOUCHOUT 0x476D4387 #define HV_HASH_BENDOUT 0xE8458013 @@ -142,6 +144,14 @@ void HandleMidiMessage(MidiEvent m) (float) p.channel); break; } + case PolyphonicKeyPressure: { // polyphonic aftertouch + PolyphonicKeyPressureEvent p = m.AsPolyphonicKeyPressure(); + hv.sendMessageToReceiverV(HV_HASH_POLYTOUCHIN, 0, "fff", + (float) p.pressure, // pressure + (float) p.note, // note + (float) p.channel); + break; + } case ControlChange: { ControlChangeEvent p = m.AsControlChange(); hv.sendMessageToReceiverV(HV_HASH_CTLIN, 0, "fff", @@ -312,6 +322,22 @@ void HandleMidiSend(uint32_t sendHash, const HvMessage *m) HandleMidiOut(midiData, numElements); break; } + case HV_HASH_POLYTOUCHOUT: + { + uint8_t value = hv_msg_getFloat(m, 0); + uint8_t note = hv_msg_getFloat(m, 1); + uint8_t ch = hv_msg_getFloat(m, 2); + ch %= 16; // drop any pd "ports" + + const uint8_t numElements = 3; + uint8_t midiData[numElements]; + midiData[0] = 0xA0 | ch; // send Poly Aftertouch + midiData[1] = note; + midiData[2] = value; + + HandleMidiOut(midiData, numElements); + break; + } case HV_HASH_CTLOUT: { uint8_t value = hv_msg_getFloat(m, 0);