gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

commit f43c069a6f07bfe894132bad4a8f9e5551e5da51
parent f4f0c99912fab64975b96c855d8bad4e2adca7e1
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Fri, 24 Sep 2021 16:49:01 +0200

Merge remote-tracking branch 'gearmulator/dsp56300' into dsp56300

Diffstat:
Msource/jucePlugin/VirusParameter.cpp | 4++--
Msource/jucePlugin/VirusParameter.h | 10++++++++--
2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/source/jucePlugin/VirusParameter.cpp b/source/jucePlugin/VirusParameter.cpp @@ -17,8 +17,8 @@ namespace Virus void Parameter::valueChanged(juce::Value &) { - const uint8_t value = static_cast<int>(m_value.getValue()); - jassert (m_range.getRange().contains(value) || m_range.end == value); + const uint8_t value = roundToInt(m_value.getValue()); + jassert (m_range.getRange().contains(value) || m_range.end == value); if (value != m_lastValue) { m_ctrl.sendSysEx( diff --git a/source/jucePlugin/VirusParameter.h b/source/jucePlugin/VirusParameter.h @@ -65,8 +65,14 @@ namespace Virus { if (m_desc.textToValueFunction) return convertTo0to1(m_desc.textToValueFunction(text, m_desc)); - else - return convertTo0to1(text.getFloatValue()); + if (m_desc.valueToTextFunction) + { + // brute force but this should be O(1) of 128... + for (auto i = 0; i < 128; i++) + if (m_desc.valueToTextFunction(i, m_desc) == text) + return convertTo0to1(i); + } + return convertTo0to1(text.getFloatValue()); } juce::String getText(float normalisedValue, int /*maximumStringLength*/) const override