From 0471cf58f54d81d0859fca82bf68b90ce62f1ef9 Mon Sep 17 00:00:00 2001 From: T-vK Date: Wed, 11 Dec 2024 20:10:18 +0100 Subject: [PATCH] Fix default channel bug for cc messages etc --- src/MidiCommon.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/MidiCommon.cpp b/src/MidiCommon.cpp index 9eb8ef0..62e158d 100644 --- a/src/MidiCommon.cpp +++ b/src/MidiCommon.cpp @@ -58,21 +58,24 @@ void MidiCommon :: pitchBend(uint16_t value, int8_t channelPar) { writeData(&outMessage, 2); } -void MidiCommon :: channelPressure(uint8_t valuePar, int8_t channel){ +void MidiCommon :: channelPressure(uint8_t valuePar, int8_t channelPar) { + uint8_t channel = channelPar != -1 ? channelPar : sendingChannel; uint8_t value = valuePar & 0b1111111; this->outMessage.status = 0b1101 << 4 | channel; this->outMessage.arg1 = value ; writeData(&outMessage, 1); } -void MidiCommon :: polyPressure(uint8_t valuePar, int8_t channel){ +void MidiCommon :: polyPressure(uint8_t valuePar, int8_t channelPar) { + uint8_t channel = channelPar != -1 ? channelPar : sendingChannel; uint8_t value = valuePar & 0b1111111; this->outMessage.status = 0b1010 << 4 | channel; this->outMessage.arg1 = value ; writeData(&outMessage, 1); } -void MidiCommon :: programChange(uint8_t program, int8_t channel){ +void MidiCommon :: programChange(uint8_t program, int8_t channelPar) { + uint8_t channel = channelPar != -1 ? channelPar : sendingChannel; uint8_t value = program & 0b1111111; this->outMessage.status = 0b1100 << 4 | channel; this->outMessage.arg1 = value ; @@ -91,7 +94,8 @@ void MidiCommon :: localControl( bool active, int8_t channel){ controlChange(122,active ? 127 : 0, channel); } -void MidiCommon :: controlChange(uint8_t msg, uint8_t value, int8_t channel){ +void MidiCommon :: controlChange(uint8_t msg, uint8_t value, int8_t channelPar) { + uint8_t channel = channelPar != -1 ? channelPar : sendingChannel; this->outMessage.status = 0b1011 << 4 | channel; this->outMessage.arg1 = msg; this->outMessage.arg2 = value;