55 AudioProcessorParameter(), name_(name), value_(value), listener_(nullptr),
56 source_changed_(false) {
58 span_ = details_.
max - details_.
min;
60 span_ = std::round(span_);
81 if (listener_ && !source_changed_) {
82 source_changed_ =
true;
85 source_changed_ =
false;
113 String
getName(
int maximumStringLength)
const override {
114 return String(details_.
display_name).substring(0, maximumStringLength);
139 String
getText(
float value,
int maximumStringLength)
const override {
143 result = details_.
string_lookup[std::max<int>(0, std::min(adjusted, details_.
max))];
148 return result.substring(0, maximumStringLength).trim();
182 return 1 + (int)span_;
183 return AudioProcessorParameter::getNumSteps();
192 static constexpr int kMaxIndexedSteps = 300;
212 return (synth_value - details_.
min) / span_;
224 float value = plugin_value * span_ + details_.
min;
227 return std::round(value);
238 if (!source_changed_) {
239 source_changed_ =
true;
240 setValueNotifyingHost(new_value);
241 source_changed_ =
false;
251 float getSkewedValue()
const {
252 return skewValue(value_->
value());
265 float skewValue(
float value)
const {
268 return value * value;
270 return value * value * value;
273 return value * value;
276 return 1.0f / powf(2.0f, value);
277 return powf(2.0f, value);
291 float unskewValue(
float value)
const {
296 return powf(value, 1.0f / 3.0f);
298 return powf(value, 1.0f / 4.0f);
301 return log2(1.0f / value);
313 bool source_changed_;
315 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(
ValueBridge)
An interface for receiving parameter change notifications from the ValueBridge.
Definition value_bridge.h:27
virtual void parameterChanged(std::string name, vital::mono_float value)=0
Called when the parameter value changes.
virtual ~Listener()
Virtual destructor.
Definition value_bridge.h:32
A parameter bridge that connects a vital::Value to an AudioProcessorParameter, allowing the host to m...
Definition value_bridge.h:17
bool isDiscrete() const override
Checks if this parameter is discrete (indexed steps) or continuous.
Definition value_bridge.h:191
float convertToEngineValue(vital::mono_float plugin_value) const
Converts a normalized (0.0 to 1.0) parameter value back into the engine's range.
Definition value_bridge.h:223
String getText(float value, int maximumStringLength) const override
Converts a normalized value into a user-facing text string.
Definition value_bridge.h:139
float convertToPluginValue(vital::mono_float synth_value) const
Converts the internal engine value to a normalized value from 0.0 to 1.0.
Definition value_bridge.h:211
int getNumSteps() const override
Returns the number of discrete steps this parameter has, if any.
Definition value_bridge.h:180
void setValueNotifyHost(float new_value)
Sets the parameter value and notifies the host, preventing recursive updates.
Definition value_bridge.h:237
float getValue() const override
Gets the current normalized (0.0 to 1.0) value of the parameter.
Definition value_bridge.h:68
void setValue(float value) override
Sets the parameter value from a normalized (0.0 to 1.0) float.
Definition value_bridge.h:80
ValueBridge(std::string name, vital::Value *value)
Constructs a ValueBridge to expose a Vital parameter as a host-automatable parameter.
Definition value_bridge.h:54
float getValueForText(const String &text) const override
Converts a user-facing string back into a normalized parameter value.
Definition value_bridge.h:159
ValueBridge()=delete
Deleted default constructor.
void setListener(Listener *listener)
Sets a listener to receive parameter change callbacks.
Definition value_bridge.h:94
bool isAutomatable() const override
Indicates whether this parameter can be automated by the host.
Definition value_bridge.h:168
String getName(int maximumStringLength) const override
Returns the display name of this parameter, truncated to a given length.
Definition value_bridge.h:113
float getDefaultValue() const override
Returns the default normalized value of this parameter.
Definition value_bridge.h:103
String getLabel() const override
Returns the label (unit) associated with this parameter.
Definition value_bridge.h:124
bool isBoolean() const override
Checks if this parameter is essentially a boolean (on/off) parameter.
Definition value_bridge.h:201
static const ValueDetails & getDetails(const std::string &name)
Definition synth_parameters.h:200
A Processor that maintains and outputs a constant poly_float value.
Definition value.h:24
force_inline mono_float value() const
Returns the current mono_float value of the first lane.
Definition value.h:60
force_inline poly_float log2(poly_float value)
Approximates log2(value) for poly_float values using a polynomial approximation.
Definition futils.h:68
float mono_float
Definition common.h:33
Holds metadata about a single parameter (control) in the Vital synthesizer.
Definition synth_parameters.h:23
mono_float max
Maximum parameter value.
Definition synth_parameters.h:41
mono_float display_multiply
Multiplier for converting internal values to display units.
Definition synth_parameters.h:44
bool display_invert
If true, invert the displayed value range.
Definition synth_parameters.h:46
mono_float post_offset
Offset applied after scaling (for certain scale types).
Definition synth_parameters.h:43
@ kQuartic
Parameter value transformed by a quartic curve.
Definition synth_parameters.h:33
@ kSquareRoot
Parameter value transformed by a square root function.
Definition synth_parameters.h:34
@ kCubic
Parameter value transformed by a cubic curve.
Definition synth_parameters.h:32
@ kExponential
Parameter value transformed by an exponential function.
Definition synth_parameters.h:35
@ kIndexed
Parameter steps through discrete indexed values.
Definition synth_parameters.h:29
@ kQuadratic
Parameter value transformed by a quadratic curve.
Definition synth_parameters.h:31
mono_float min
Minimum parameter value.
Definition synth_parameters.h:40
std::string display_name
Human-readable name for display in UI.
Definition synth_parameters.h:48
const std::string * string_lookup
Optional lookup table for indexed parameter names.
Definition synth_parameters.h:49
mono_float default_value
Default value for the parameter.
Definition synth_parameters.h:42
ValueScale value_scale
The scaling mode of the parameter value.
Definition synth_parameters.h:45
std::string display_units
Units to display next to the parameter (e.g., "Hz", "dB").
Definition synth_parameters.h:47
Declares Value processors that output a constant value and can be dynamically set.