Skip to content

Commit

Permalink
MIdi-Cat Mem, Ctx - fixed broken button-prcessing #356
Browse files Browse the repository at this point in the history
  • Loading branch information
stoermelder committed Apr 22, 2024
1 parent 6e04c7b commit 9eccc55
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 20 deletions.
12 changes: 8 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
- Fixed knob reset on double-click in Semitone/Octave-mode (#387)
- Module [GOTO](./docs/Goto.md)
- Implemented smooth transition for "top left" jump destination (#388)
- Module [MIDI-CAT CTX](./docs/MidiCat.md#ctx-expander)
- Fixed broken button-handling when triggered by MIDI-mapping
- Module [MIDI-CAT MEM](./docs/MidiCat.md#mem-expander)
- Fixed broken button-handling when triggered by MIDI-mapping (#356)
- Module [MIDI-MON](./docs/MidiMon.md)
- Added support for CC 14-bit/RPN/NRPN messages
- Module [MIDI-STEP](./docs/MidiStep.md)
Expand Down Expand Up @@ -301,9 +305,6 @@
- Fixed crash on locking more than 32 parameters (#176)
- Module [INTERMIX](./docs/Intermix.md)
- Added support for polyphony (#199)
- Module [MEM](./docs/MidiCat.md#mem-expander)
- Added support for MIDI-CAT's new slew-limiting and scaling options ([manual](./docs/MidiCat.md#slew-limiting-and-input-scaling))
- Added scanning for next or previous modules with stored mapping ([manual](./docs/MidiCat.md#mem-scan)) (#200)
- Module [µMAP](./docs/CVMapMicro.md)
- Added input voltage display
- Module [MIDI-CAT](./docs/MidiCat.md)
Expand All @@ -317,6 +318,9 @@
- Fixed broken "Re-send MIDI feedback" option
- Added context menu option for re-sending MIDI feedback periodically ([manual](./docs/MidiCat.md#feedback-periodically))
- Added note-mode "Toggle + Velocity" ([manual](./docs/MidiCat.md#toggle-velocity))
- Module [MIDI-CAT MEM](./docs/MidiCat.md#mem-expander)
- Added support for MIDI-CAT's new slew-limiting and scaling options ([manual](./docs/MidiCat.md#slew-limiting-and-input-scaling))
- Added scanning for next or previous modules with stored mapping ([manual](./docs/MidiCat.md#mem-scan)) (#200)
- Module [MIDI-STEP](./docs/MidiStep.md)
- Added option for Akai MPD218 ([manual](./docs/MidiStep.md#akai-mpd218))
- Module [MIRROR](./docs/Mirror.md)
Expand Down Expand Up @@ -350,7 +354,7 @@

## 1.7.0

- Module [MEM](./docs/MidiCat.md#mem-expander)
- Module [MIDI-CAT MEM](./docs/MidiCat.md#mem-expander)
- New expander-module for MIDI-CAT, storage-unit for MIDI mapping-presets with MIDI-CAT
- Module [SPIN](./docs/Spin.md)
- New module, converts mouse-wheel or middle mouse-button events into triggers
Expand Down
12 changes: 4 additions & 8 deletions src/MidiCat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1671,15 +1671,11 @@ struct MidiCatWidget : ThemedModuleWidget<MidiCatModule>, ParamWidgetContextExte

Module* expMem;
BufferedSwitchQuantity* expMemPrevQuantity;
dsp::SchmittTrigger expMemPrevTrigger;
BufferedSwitchQuantity* expMemNextQuantity;
dsp::SchmittTrigger expMemNextTrigger;
BufferedSwitchQuantity* expMemParamQuantity;
dsp::SchmittTrigger expMemParamTrigger;

MidiCatCtxBase* expCtx;
BufferedSwitchQuantity* expCtxMapQuantity;
dsp::SchmittTrigger expCtxMapTrigger;

enum class LEARN_MODE {
OFF = 0,
Expand Down Expand Up @@ -1817,15 +1813,15 @@ struct MidiCatWidget : ThemedModuleWidget<MidiCatModule>, ParamWidgetContextExte
}
}
if (expMem) {
if (expMemPrevTrigger.process(expMemPrevQuantity->buffer)) {
if (expMemPrevQuantity->getBuffer()) {
expMemPrevQuantity->resetBuffer();
expMemPrevModule();
}
if (expMemNextTrigger.process(expMemNextQuantity->buffer)) {
if (expMemNextQuantity->getBuffer()) {
expMemNextQuantity->resetBuffer();
expMemNextModule();
}
if (expMemParamTrigger.process(expMemParamQuantity->buffer)) {
if (expMemParamQuantity->getBuffer()) {
expMemParamQuantity->resetBuffer();
enableLearn(LEARN_MODE::MEM);
}
Expand All @@ -1841,7 +1837,7 @@ struct MidiCatWidget : ThemedModuleWidget<MidiCatModule>, ParamWidgetContextExte
}
}
if (expCtx) {
if (expCtxMapTrigger.process(expCtxMapQuantity->buffer)) {
if (expCtxMapQuantity->getBuffer()) {
expCtxMapQuantity->resetBuffer();
module->enableLearn(-1, true);
}
Expand Down
12 changes: 12 additions & 0 deletions src/MidiCatCtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ struct MidiCatCtxModule : MidiCatCtxBase {
/** [Stored to JSON] */
std::string midiCatId;

dsp::ClockDivider processDivider;
dsp::SchmittTrigger mapTrigger;

MidiCatCtxModule() {
panelTheme = pluginSettings.panelThemeDefault;
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
configSwitch<BufferedSwitchQuantity>(PARAM_MAP, 0.f, 1.f, 0.f, "Start parameter mapping");
processDivider.setDivision(48);
onReset();
}

Expand All @@ -42,6 +46,14 @@ struct MidiCatCtxModule : MidiCatCtxBase {
return midiCatId;
}

void process(const ProcessArgs& args) override {
if (processDivider.process()) {
if (mapTrigger.process(params[PARAM_MAP].getValue())) {
reinterpret_cast<BufferedSwitchQuantity*>(paramQuantities[PARAM_MAP])->setBuffer();
}
}
}

json_t* dataToJson() override {
json_t *rootJ = json_object();
json_object_set_new(rootJ, "panelTheme", json_integer(panelTheme));
Expand Down
18 changes: 18 additions & 0 deletions src/MidiCatMem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@ struct MidiCatMemModule : Module {
/** [Stored to JSON] */
std::map<std::pair<std::string, std::string>, MemModule*> midiMap;

dsp::ClockDivider processDivider;
dsp::SchmittTrigger prevTrigger;
dsp::SchmittTrigger nextTrigger;
dsp::SchmittTrigger applyTrigger;

MidiCatMemModule() {
panelTheme = pluginSettings.panelThemeDefault;
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
configSwitch<BufferedSwitchQuantity>(PARAM_PREV, 0.f, 1.f, 0.f, "Scan for previous module mapping");
configSwitch<BufferedSwitchQuantity>(PARAM_NEXT, 0.f, 1.f, 0.f, "Scan for next module mapping");
configSwitch<BufferedSwitchQuantity>(PARAM_APPLY, 0.f, 1.f, 0.f, "Apply mapping");
processDivider.setDivision(48);
onReset();
}

Expand All @@ -51,6 +57,18 @@ struct MidiCatMemModule : Module {
void process(const ProcessArgs& args) override {
leftExpander.producerMessage = &midiMap;
leftExpander.messageFlipRequested = true;

if (processDivider.process()) {
if (prevTrigger.process(params[PARAM_PREV].getValue())) {
reinterpret_cast<BufferedSwitchQuantity*>(paramQuantities[PARAM_PREV])->setBuffer();
}
if (nextTrigger.process(params[PARAM_NEXT].getValue())) {
reinterpret_cast<BufferedSwitchQuantity*>(paramQuantities[PARAM_NEXT])->setBuffer();
}
if (applyTrigger.process(params[PARAM_APPLY].getValue())) {
reinterpret_cast<BufferedSwitchQuantity*>(paramQuantities[PARAM_APPLY])->setBuffer();
}
}
}

json_t* dataToJson() override {
Expand Down
12 changes: 4 additions & 8 deletions src/components.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,10 @@ struct TriggerParamQuantity : ParamQuantity {
};

struct BufferedSwitchQuantity : SwitchQuantity {
float buffer = false;
void setValue(float value) override {
if (value >= 1.f) buffer = true;
SwitchQuantity::setValue(value);
}
void resetBuffer() {
buffer = false;
}
bool buffer = false;
inline bool getBuffer() { return buffer; }
inline void setBuffer() { buffer = true; }
inline void resetBuffer() { buffer = false; }
};


Expand Down

0 comments on commit 9eccc55

Please sign in to comment.