38 stringFromValueFunction (attributes.getStringFromValueFunction()),
39 valueFromStringFunction (attributes.getValueFromStringFunction())
41 if (stringFromValueFunction ==
nullptr)
45 int numDecimalPlaces = 7;
54 while ((v % 10) == 0 && numDecimalPlaces > 0)
61 return numDecimalPlaces;
67 return length > 0 ?
asText.substring (0, length) :
asText;
71 if (valueFromStringFunction ==
nullptr)
72 valueFromStringFunction = [] (
const String& text) {
return text.getFloatValue(); };
82 #if __cpp_lib_atomic_is_always_lock_free
84 "AudioParameterFloat requires a lock-free std::atomic<float>");
88float AudioParameterFloat::getValue()
const {
return convertTo0to1 (value); }
90float AudioParameterFloat::getDefaultValue()
const {
return convertTo0to1 (valueDefault); }
92String AudioParameterFloat::getText (
float v,
int length)
const {
return stringFromValueFunction (
convertFrom0to1 (v), length); }
93float AudioParameterFloat::getValueForText (
const String& text)
const {
return convertTo0to1 (valueFromStringFunction (text)); }
Properties of an AudioParameterFloat.
A subclass of AudioProcessorParameter that provides an easy way to create a parameter which maps onto...
float get() const noexcept
Returns the parameter's current value.
AudioParameterFloat(const ParameterID ¶meterID, const String ¶meterName, NormalisableRange< float > normalisableRange, float defaultValue, const AudioParameterFloatAttributes &attributes={})
Creates a AudioParameterFloat with the specified parameters.
virtual void valueChanged(float newValue)
Override this method if you are interested in receiving callbacks when the parameter value changes.
AudioParameterFloat & operator=(float newValue)
Changes the parameter's current value.
~AudioParameterFloat() override
Destructor.
NormalisableRange< float > range
Provides access to the parameter's range.
virtual int getNumSteps() const
Returns the number of steps that this parameter's range should be quantised into.
void setValueNotifyingHost(float newValue)
A processor should call this when it needs to change one of its parameters.
Represents a mapping between an arbitrary range of values and a normalised 0->1 range.
ValueType interval
The snapping interval that should be used (for a non-normalised value).
Combines a parameter ID and a version hint.
This abstract base class is used by some AudioProcessorParameter helper classes.
float convertTo0to1(float v) const noexcept
Normalises and snaps a value based on the normalisable range.
float convertFrom0to1(float v) const noexcept
Denormalises and snaps a value based on the normalisable range.
constexpr bool approximatelyEqual(Type a, Type b, Tolerance< Type > tolerance=Tolerance< Type >{} .withAbsolute(std::numeric_limits< Type >::min()) .withRelative(std::numeric_limits< Type >::epsilon()))
Returns true if the two floating-point numbers are approximately equal.
@ valueChanged
Indicates that the UI element's value has changed.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.