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 208337feb73d308e8f6c4b6caf89c519eaa7fbaa
parent 2392bf87c7f3e60ac24a315acd97f1a3a39664ad
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Tue,  6 Aug 2024 22:55:31 +0200

fix value to text / text to value functions for parameters with min < 0

Diffstat:
Msource/jucePluginLib/parameter.cpp | 14++++++++++++++
Msource/jucePluginLib/parameter.h | 12++----------
2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/source/jucePluginLib/parameter.cpp b/source/jucePluginLib/parameter.cpp @@ -226,6 +226,14 @@ namespace pluginLib return juce::String::formatted("%d_%d_%d", static_cast<int>(d.page), part, d.index); } + float Parameter::getValueForText(const juce::String& _text) const + { + auto res = m_desc.valueList.textToValue(std::string(_text.getCharPointer())); + if(m_desc.range.getStart() < 0) + res += m_desc.range.getStart(); + return convertTo0to1(static_cast<float>(res)); + } + ParamValue Parameter::getDefault() const { if(m_desc.defaultValue != Description::NoDefaultValue) @@ -233,6 +241,12 @@ namespace pluginLib return 0; } + juce::String Parameter::getText(const float _normalisedValue, int _i) const + { + const auto v = convertFrom0to1(_normalisedValue); + return m_desc.valueList.valueToText(juce::roundToInt(v) - std::min(0, m_desc.range.getStart())); + } + void Parameter::setLocked(const bool _locked) { if(m_isLocked == _locked) diff --git a/source/jucePluginLib/parameter.h b/source/jucePluginLib/parameter.h @@ -58,11 +58,7 @@ namespace pluginLib bool isBoolean() const override { return m_desc.isBool; } bool isBipolar() const { return m_desc.isBipolar; } - float getValueForText(const juce::String &text) const override - { - const auto res = m_desc.valueList.textToValue(std::string(text.getCharPointer())); - return convertTo0to1(static_cast<float>(res)); - } + float getValueForText(const juce::String& _text) const override; float getDefaultValue() const override { @@ -71,11 +67,7 @@ namespace pluginLib virtual ParamValue getDefault() const; - juce::String getText(float normalisedValue, int /*maximumStringLength*/) const override - { - const auto v = convertFrom0to1(normalisedValue); - return m_desc.valueList.valueToText(juce::roundToInt(v)); - } + juce::String getText(float _normalisedValue, int /*maximumStringLength*/) const override; void setLocked(bool _locked); bool isLocked() const { return m_isLocked; }