From d795561e97b249448bc1c5c5fda1452dc272eb95 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Mon, 24 Jan 2022 17:03:30 -0500 Subject: [PATCH] Fix MIDI module learned note/CC bugs --- src/core/CV_MIDICC.cpp | 3 +++ src/core/MIDICC_CV.cpp | 10 +++++++--- src/core/plugin.hpp | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/core/CV_MIDICC.cpp b/src/core/CV_MIDICC.cpp index 4f63e82b..85359dd3 100644 --- a/src/core/CV_MIDICC.cpp +++ b/src/core/CV_MIDICC.cpp @@ -86,6 +86,9 @@ struct CV_MIDICC : Module { midiOutput.setFrame(args.frame); for (int id = 0; id < 16; id++) { + if (learnedCcs[id] < 0) + continue; + uint8_t value = (uint8_t) clamp(std::round(inputs[CC_INPUTS + id].getVoltage() / 10.f * 127), 0.f, 127.f); midiOutput.setValue(value, learnedCcs[id]); } diff --git a/src/core/MIDICC_CV.cpp b/src/core/MIDICC_CV.cpp index 2097af95..f7d126dc 100644 --- a/src/core/MIDICC_CV.cpp +++ b/src/core/MIDICC_CV.cpp @@ -50,12 +50,12 @@ struct MIDICC_CV : Module { } void onReset() override { - for (int8_t cc = 0; cc < 128; cc++) { + for (uint8_t cc = 0; cc < 128; cc++) { for (int c = 0; c < 16; c++) { ccValues[cc][c] = 0; } } - for (int8_t cc = 0; cc < 32; cc++) { + for (uint8_t cc = 0; cc < 32; cc++) { for (int c = 0; c < 16; c++) { msbValues[cc][c] = 0; } @@ -83,7 +83,11 @@ struct MIDICC_CV : Module { continue; outputs[CC_OUTPUT + id].setChannels(channels); - int cc = learnedCcs[id]; + int8_t cc = learnedCcs[id]; + if (cc < 0) { + outputs[CC_OUTPUT + id].clearVoltages(); + continue; + } for (int c = 0; c < channels; c++) { int16_t cellValue = int16_t(ccValues[cc][c]) * 128; diff --git a/src/core/plugin.hpp b/src/core/plugin.hpp index 01eb47ee..a5e5789a 100644 --- a/src/core/plugin.hpp +++ b/src/core/plugin.hpp @@ -147,7 +147,7 @@ template struct NoteChoice : LedDisplayChoice { TModule* module; int id; - uint8_t focusNote; + int focusNote; NoteChoice() { box.size.y = mm2px(6.666);