From 9c58316f849b8fc8711603c112689aa0cac82690 Mon Sep 17 00:00:00 2001 From: ben Date: Sat, 23 Dec 2017 16:40:05 +0100 Subject: [PATCH 1/4] Implement single message per step for all midi modules and Fix quad midi reset bug --- src/core/MidiCCToCV.cpp | 4 ++-- src/core/MidiClockToCV.cpp | 3 +-- src/core/MidiToCV.cpp | 3 +-- src/core/MidiTriggerToCV.cpp | 3 +-- src/core/QuadMidiToCV.cpp | 10 +++------- 5 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/core/MidiCCToCV.cpp b/src/core/MidiCCToCV.cpp index de651a1b..6e60e5f3 100644 --- a/src/core/MidiCCToCV.cpp +++ b/src/core/MidiCCToCV.cpp @@ -91,11 +91,11 @@ void MIDICCToCVInterface::step() { if (isPortOpen()) { std::vector message; + // midiIn->getMessage returns empty vector if there are no messages in the queue getMessage(&message); - while (message.size() > 0) { + if (message.size() > 0) { processMidi(message); - getMessage(&message); } } diff --git a/src/core/MidiClockToCV.cpp b/src/core/MidiClockToCV.cpp index 0fa146af..1b5186c7 100644 --- a/src/core/MidiClockToCV.cpp +++ b/src/core/MidiClockToCV.cpp @@ -101,9 +101,8 @@ void MIDIClockToCVInterface::step() { // midiIn->getMessage returns empty vector if there are no messages in the queue getMessage(&message); - while (message.size() > 0) { + if (message.size() > 0) { processMidi(message); - getMessage(&message); } } diff --git a/src/core/MidiToCV.cpp b/src/core/MidiToCV.cpp index 783a78ce..df8accd9 100644 --- a/src/core/MidiToCV.cpp +++ b/src/core/MidiToCV.cpp @@ -100,9 +100,8 @@ void MIDIToCVInterface::step() { // midiIn->getMessage returns empty vector if there are no messages in the queue getMessage(&message); - while (message.size() > 0) { + if (message.size() > 0) { processMidi(message); - getMessage(&message); } } diff --git a/src/core/MidiTriggerToCV.cpp b/src/core/MidiTriggerToCV.cpp index 376dccf3..3fb0f1c1 100644 --- a/src/core/MidiTriggerToCV.cpp +++ b/src/core/MidiTriggerToCV.cpp @@ -75,9 +75,8 @@ void MIDITriggerToCVInterface::step() { // midiIn->getMessage returns empty vector if there are no messages in the queue getMessage(&message); - while (message.size() > 0) { + if (message.size() > 0) { processMidi(message); - getMessage(&message); } } diff --git a/src/core/QuadMidiToCV.cpp b/src/core/QuadMidiToCV.cpp index 99009699..d6b865c7 100644 --- a/src/core/QuadMidiToCV.cpp +++ b/src/core/QuadMidiToCV.cpp @@ -98,16 +98,11 @@ void QuadMIDIToCVInterface::resetMidi() { void QuadMIDIToCVInterface::step() { if (isPortOpen()) { std::vector message; - int msgsProcessed = 0; // midiIn->getMessage returns empty vector if there are no messages in the queue - // NOTE: For the quadmidi we will process max 4 midi messages per step to avoid - // problems with parallel input. getMessage(&message); - while (msgsProcessed < 4 && message.size() > 0) { + if (message.size() > 0) { processMidi(message); - getMessage(&message); - msgsProcessed++; } } @@ -183,7 +178,7 @@ void QuadMIDIToCVInterface::processMidi(std::vector msg) { if (!gate) { for (int i = 0; i < 4; i++) { - if (activeKeys[i].pitch == data1) { + if (activeKeys[i].pitch == data1 && activeKeys[i].gate) { activeKeys[i].gate = false; activeKeys[i].vel = data2; if (std::find(open.begin(), open.end(), i) != open.end()) { @@ -210,6 +205,7 @@ void QuadMIDIToCVInterface::processMidi(std::vector msg) { switch (mode) { case RESET: if (open.size() >= 4) { + open.clear(); for (int i = 0; i < 4; i++) { activeKeys[i].gate = false; open.push_back(i); From 3945c1123ab211fdcefdff3319a64a06caf193c7 Mon Sep 17 00:00:00 2001 From: ben Date: Sat, 23 Dec 2017 16:43:23 +0100 Subject: [PATCH 2/4] Fix rtaudio link (pull from git) --- dep/Makefile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dep/Makefile b/dep/Makefile index 9218d608..d3c0525e 100755 --- a/dep/Makefile +++ b/dep/Makefile @@ -123,11 +123,10 @@ $(libzip): $(MAKE) -C libzip-1.2.0 install $(rtmidi): - $(WGET) http://www.music.mcgill.ca/~gary/rtmidi/release/rtmidi-3.0.0.tar.gz - $(UNTAR) rtmidi-3.0.0.tar.gz - cd rtmidi-3.0.0 && ./configure --prefix="$(LOCAL)" - $(MAKE) -C rtmidi-3.0.0 - $(MAKE) -C rtmidi-3.0.0 install + git clone https://github.com/thestk/rtmidi.git + cd rtmidi && ./autogen.sh --no-configure && ./configure --prefix="$(LOCAL)" + $(MAKE) -C rtmidi + $(MAKE) -C rtmidi install $(rtaudio): cd rtaudio && mkdir -p cmakebuild From 69869949da03d8fb1938f4b7b65ca996da62d584 Mon Sep 17 00:00:00 2001 From: ben Date: Sun, 24 Dec 2017 11:27:17 +0100 Subject: [PATCH 3/4] Fix quad midi pedal handling --- src/core/QuadMidiToCV.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/core/QuadMidiToCV.cpp b/src/core/QuadMidiToCV.cpp index d6b865c7..e3c7670a 100644 --- a/src/core/QuadMidiToCV.cpp +++ b/src/core/QuadMidiToCV.cpp @@ -10,6 +10,7 @@ struct MidiKey { int at = 0; // aftertouch int vel = 0; // velocity bool gate = false; + bool pedal_gate_released = false; }; struct QuadMIDIToCVInterface : MidiIO, Module { @@ -162,6 +163,10 @@ void QuadMIDIToCVInterface::processMidi(std::vector msg) { if (!pedal) { open.clear(); for (int i = 0; i < 4; i++) { + if (activeKeys[i].pedal_gate_released) { + activeKeys[i].pedal_gate_released = false; + continue; + } activeKeys[i].gate = false; open.push_back(i); } @@ -173,7 +178,12 @@ void QuadMIDIToCVInterface::processMidi(std::vector msg) { } if (pedal && !gate) { - return; + for (int i = 0; i < 4; i++) { + if (activeKeys[i].pitch == data1) { + activeKeys[i].pedal_gate_released = true; + return; + } + } } if (!gate) { @@ -197,7 +207,7 @@ void QuadMIDIToCVInterface::processMidi(std::vector msg) { } if (!activeKeys[0].gate && !activeKeys[1].gate && - !activeKeys[2].gate && !activeKeys[3].gate) { + !activeKeys[2].gate && !activeKeys[3].gate) { open.sort(); } @@ -310,7 +320,7 @@ QuadMidiToCVWidget::QuadMidiToCVWidget() { } addParam(createParam(Vec(12 * 15, labelHeight), module, QuadMIDIToCVInterface::RESET_PARAM, 0.0, 1.0, - 0.0)); + 0.0)); addChild(createLight>(Vec(12 * 15 + 5, labelHeight + 5), module, QuadMIDIToCVInterface::RESET_LIGHT)); { Label *label = new Label(); From 1fa2d90225a9bf6d6f2f86ef7c024f3655740db7 Mon Sep 17 00:00:00 2001 From: ben Date: Wed, 27 Dec 2017 19:37:05 +0100 Subject: [PATCH 4/4] fix pedal gate release --- src/core/QuadMidiToCV.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/core/QuadMidiToCV.cpp b/src/core/QuadMidiToCV.cpp index e3c7670a..84c7335b 100644 --- a/src/core/QuadMidiToCV.cpp +++ b/src/core/QuadMidiToCV.cpp @@ -161,14 +161,15 @@ void QuadMIDIToCVInterface::processMidi(std::vector msg) { if (data1 == 0x40) { // pedal pedal = (data2 >= 64); if (!pedal) { - open.clear(); for (int i = 0; i < 4; i++) { if (activeKeys[i].pedal_gate_released) { - activeKeys[i].pedal_gate_released = false; - continue; + activeKeys[i].gate = false; + activeKeys[i].pedal_gate_released = false; + if (std::find(open.begin(), open.end(), i) != open.end()) { + open.remove(i); + } + open.push_front(i); } - activeKeys[i].gate = false; - open.push_back(i); } } } @@ -179,11 +180,11 @@ void QuadMIDIToCVInterface::processMidi(std::vector msg) { if (pedal && !gate) { for (int i = 0; i < 4; i++) { - if (activeKeys[i].pitch == data1) { + if (activeKeys[i].pitch == data1 && activeKeys[i].gate) { activeKeys[i].pedal_gate_released = true; - return; } } + return; } if (!gate) { @@ -240,10 +241,12 @@ void QuadMIDIToCVInterface::processMidi(std::vector msg) { open.push_front(i); activeKeys[i].gate = false; + activeKeys[i].pedal_gate_released = false; } } activeKeys[next].gate = true; + activeKeys[next].pedal_gate_released = false; activeKeys[next].pitch = data1; activeKeys[next].vel = data2; }