From f67d37ec91323e1599d709b58ecf4d78b60d563b Mon Sep 17 00:00:00 2001 From: ben Date: Tue, 31 Oct 2017 12:26:28 +0100 Subject: [PATCH] Fix quad midi pedal handling --- src/core/QuadMidiToCV.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/core/QuadMidiToCV.cpp b/src/core/QuadMidiToCV.cpp index 01b8aa06..ee9aa4ef 100644 --- a/src/core/QuadMidiToCV.cpp +++ b/src/core/QuadMidiToCV.cpp @@ -164,6 +164,7 @@ void QuadMIDIToCVInterface::processMidi(std::vector msg) { if (data1 == 0x40) { // pedal pedal = (data2 >= 64); if (!pedal) { + open.clear(); for (int i = 0; i < 4; i++) { activeKeys[i].gate = false; open.push_back(i); @@ -175,7 +176,11 @@ void QuadMIDIToCVInterface::processMidi(std::vector msg) { return; } - if (!pedal && !gate) { + if (pedal && !gate) { + return; + } + + if (!gate) { for (int i = 0; i < 4; i++) { if (activeKeys[i].pitch == data1) { activeKeys[i].gate = false; @@ -189,13 +194,21 @@ void QuadMIDIToCVInterface::processMidi(std::vector msg) { return; } + if (pedal) { + for (int i = 0; i < 4 ; i++) { + if (activeKeys[i].pitch == data1 && activeKeys[i].gate) { + activeKeys[i].vel = data2; + return; + } + } + } + if (open.empty()) { for (int i = 0; i < 4; i++) { open.push_back(i); } } - if (!activeKeys[0].gate && !activeKeys[1].gate && !activeKeys[2].gate && !activeKeys[3].gate) { open.sort(); @@ -215,8 +228,6 @@ void QuadMIDIToCVInterface::processMidi(std::vector msg) { break; case ROTATE: break; - default: - fprintf(stderr, "No mode selected?!\n"); } activeKeys[open.front()].gate = true;