Skip to content

Commit

Permalink
Midi-Cat - fixed MIDI-feedback for snapped params #374
Browse files Browse the repository at this point in the history
  • Loading branch information
stoermelder committed Apr 24, 2024
1 parent 8e129e8 commit 3369bec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- Implemented smooth transition for "top left" jump destination (#388)
- Module [MIDI-CAT](./docs/MidiCat.md)
- Implemented response curves (logarithmic/exponential) (#258)
- Fixed MIDI-feedback for snapped parameters (#374)
- Module [MIDI-CAT CTX](./docs/MidiCat.md#ctx-expander)
- Fixed broken button-handling when triggered by Parameter-mapping
- Module [MIDI-CAT MEM](./docs/MidiCat.md#mem-expander)
Expand Down
10 changes: 7 additions & 3 deletions src/digital/ScaledMapParam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,18 @@ struct ScaledMapParam {

virtual T getValue() {
float f = paramQuantity->getScaledValue();
// Simply return the input-value if the Param's current value is almost unchanged
if (isNear(valueOut, f)) return valueIn;

// Reset the internal values to the actual parameter's value in case
// getValue() is called before setValue() - for proper MIDI feedback
if (valueOut == std::numeric_limits<float>::infinity()) value = valueOut = f;
// If a parameter is snapped then the returned value of ParaQuantity can't be trusted
// -> simply return the input value
if (paramQuantity->snapEnabled) f = valueOut;
// If a parameter is snapped then the returned value of ParamQuantity can't be trusted
// -> Use the parameter's actual value bypassing ParamQuantity
if (paramQuantity->snapEnabled) {
f = paramQuantity->getParam()->getValue();
f = math::rescale(f, paramQuantity->getMinValue(), paramQuantity->getMaxValue(), 0.f, 1.f);
}

f = processCurveInverse(f);
f = rescale(f, min, max, limitMin, limitMax);
Expand Down

0 comments on commit 3369bec

Please sign in to comment.