Skip to content

Commit

Permalink
Clear MPE channel assignments on allnotesoff msg
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiDrange committed Jul 7, 2021
1 parent 7e51978 commit 4044dca
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
19 changes: 13 additions & 6 deletions ECMapper/Source/Data/MidiGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,8 @@ void MidiGenerator::createMidiMsgOn(ConfigLookup::Key &keyLookup, KeyState *stat
else
state->midiChannel = (int)keyLookup.output;

if (keyLookup.msgType == 4) {
for (int i = 1; i < 17; i++) {
buffer.addEvent(juce::MidiMessage::allNotesOff(i), buffer.getLastEventTime()+8);
chanNotePri[i-1].clear();
}
}
if (keyLookup.msgType == 4)
createAllNotesOff(keyLookup, state, buffer, outgoingOscMsg);
else if (keyLookup.msgType == 1)
buffer.addEvent(juce::MidiMessage::controllerEvent(state->midiChannel, keyLookup.cmdCC, keyLookup.cmdOn), buffer.getLastEventTime()+8);
else if (keyLookup.msgType == 2)
Expand Down Expand Up @@ -281,6 +277,17 @@ void MidiGenerator::createMidiMsgOn(ConfigLookup::Key &keyLookup, KeyState *stat
}
}

void MidiGenerator::createAllNotesOff(ConfigLookup::Key &keyLookup, KeyState *state, juce::MidiBuffer &buffer, OSC::Message &outgoingOscMsg) {
for (int i = 1; i < 17; i++) {
buffer.addEvent(juce::MidiMessage::allNotesOff(i), buffer.getLastEventTime()+8);
chanNotePri[i-1].clear();
}
if (lowerChanAssigner != nullptr)
lowerChanAssigner->allNotesOff();
if (upperChanAssigner != nullptr)
upperChanAssigner->allNotesOff();
}

void MidiGenerator::createMidiMsgOff(ConfigLookup::Key &keyLookup, KeyState *state, juce::MidiBuffer &buffer, OSC::Message &outgoingOscMsg) {
if (keyLookup.cmdType != 3) { // "trigger" commands shouldn´t send anything on key off
if (keyLookup.msgType == 4) {
Expand Down
1 change: 1 addition & 0 deletions ECMapper/Source/Data/MidiGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class MidiGenerator {
void createBreath(int deviceIndex, ConfigLookup &keyLookup, juce::MidiBuffer &buffer);
void createStripAbsolute(int deviceIndex, int stripIndex, int zoneIndex, ConfigLookup &keyLookup, juce::MidiBuffer &buffer);
void createStripRelative(int deviceIndex, int stripIndex, int zoneIndex, ConfigLookup &keyLookup, juce::MidiBuffer &buffer);
void createAllNotesOff(ConfigLookup::Key &keyLookup, KeyState *state, juce::MidiBuffer &buffer, OSC::Message &outgoingOscMsg);

inline float clamp(float v, float mn, float mx) { return (std::max(std::min(v, mx), mn)); }
float unipolar(int val) { return std::min(float(val) / 4096.0f, 1.0f); }
Expand Down
2 changes: 1 addition & 1 deletion EigenCore/Source/EigenCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class EigenCore : public juce::JUCEApplication {
public:
EigenCore();
const juce::String getApplicationName() override { return "EigenCore"; }
const juce::String getApplicationVersion() override { return "0.9.1"; }
const juce::String getApplicationVersion() override { return "1.0.1"; }
void initialise(const juce::String &) override;
void shutdown() override;

Expand Down

0 comments on commit 4044dca

Please sign in to comment.