Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect MIDI channel on control change mappings #344

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Source/PluginData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,11 @@ void DexedAudioProcessor::setStateInformation(const void* source, int sizeInByte
int cc = ccMapping->getIntAttribute("cc", -1);
String target = ccMapping->getStringAttribute("target", "");
if ( target.isNotEmpty() && cc != -1 ) {
if ((cc >> 8) == 0) {
// Simple migration logic lets old mappings without channel
// work on channel 1.
cc |= 1 << 8;
}
for(int i=0;i<ctrl.size();i++) {
if ( ctrl[i]->label == target) {
TRACE("mapping CC=%d to %s", cc, target.toRawUTF8());
Expand Down
2 changes: 1 addition & 1 deletion Source/PluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public :
this->target = target;
setMessage("Mapping: " + String(target->label) + ", waiting for midi controller change (CC) message...");
addButton("CANCEL", -1);
editor->processor->lastCCUsed.setValue(-1);
editor->processor->lastCCUsed.setValue(-1);
editor->processor->lastCCUsed.addListener(this);
}

Expand Down
9 changes: 5 additions & 4 deletions Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,16 +403,17 @@ void DexedAudioProcessor::processMidiMessage(const MidiMessage *msg) {
}
break;
default:
TRACE("handle CC %d %d", ctrl, value);
if ( mappedMidiCC.contains(ctrl) ) {
Ctrl *linkedCtrl = mappedMidiCC[ctrl];
TRACE("handle channel %d CC %d = %d", channel, ctrl, value);
int channel_cc = (channel << 8) | ctrl;
if ( mappedMidiCC.contains(channel_cc) ) {
Ctrl *linkedCtrl = mappedMidiCC[channel_cc];

// We are not publishing this in the DSP thread, moving that in the
// event thread
linkedCtrl->publishValueAsync((float) value / 127);
}
// this is used to notify the dialog that a CC value was received.
lastCCUsed.setValue(ctrl);
lastCCUsed.setValue(channel_cc);
}
}
return;
Expand Down