mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
AudioProcessorParameter: Add new ParameterID and Attributes types
This commit is contained in:
parent
26aa932e5f
commit
afe5199848
17 changed files with 692 additions and 221 deletions
|
|
@ -26,6 +26,13 @@
|
|||
namespace juce
|
||||
{
|
||||
|
||||
/** Properties of an AudioParameterFloat.
|
||||
|
||||
@see AudioParameterFloat(), RangedAudioParameterAttributes()
|
||||
*/
|
||||
class AudioParameterFloatAttributes : public RangedAudioParameterAttributes<AudioParameterFloatAttributes, float> {};
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
A subclass of AudioProcessorParameter that provides an easy way to create a
|
||||
parameter which maps onto a given NormalisableRange.
|
||||
|
|
@ -37,6 +44,30 @@ namespace juce
|
|||
class JUCE_API AudioParameterFloat : public RangedAudioParameter
|
||||
{
|
||||
public:
|
||||
/** Creates a AudioParameterFloat with the specified parameters.
|
||||
|
||||
Note that the attributes argument is optional and only needs to be
|
||||
supplied if you want to change options from their default values.
|
||||
|
||||
Example usage:
|
||||
@code
|
||||
auto attributes = AudioParameterFloatAttributes().withStringFromValueFunction ([] (auto x, auto) { return String (x * 100); })
|
||||
.withLabel ("%");
|
||||
auto param = std::make_unique<AudioParameterFloat> ("paramID", "Parameter Name", NormalisableRange<float>(), 0.5f, attributes);
|
||||
@endcode
|
||||
|
||||
@param parameterID The parameter ID to use
|
||||
@param parameterName The parameter name to use
|
||||
@param normalisableRange The NormalisableRange to use
|
||||
@param defaultValue The non-normalised default value
|
||||
@param attributes Optional characteristics
|
||||
*/
|
||||
AudioParameterFloat (const ParameterID& parameterID,
|
||||
const String& parameterName,
|
||||
NormalisableRange<float> normalisableRange,
|
||||
float defaultValue,
|
||||
const AudioParameterFloatAttributes& attributes = {});
|
||||
|
||||
/** Creates a AudioParameterFloat with the specified parameters.
|
||||
|
||||
@param parameterID The parameter ID to use
|
||||
|
|
@ -51,25 +82,34 @@ public:
|
|||
@param valueFromString An optional lambda function that parses a string and
|
||||
converts it into a non-normalised value. Some hosts use
|
||||
this to allow users to type in parameter values.
|
||||
@param versionHint See AudioProcessorParameter::getVersionHint()
|
||||
*/
|
||||
AudioParameterFloat (const String& parameterID,
|
||||
[[deprecated ("Prefer the signature taking an Attributes argument")]]
|
||||
AudioParameterFloat (const ParameterID& parameterID,
|
||||
const String& parameterName,
|
||||
NormalisableRange<float> normalisableRange,
|
||||
float defaultValue,
|
||||
const String& parameterLabel = String(),
|
||||
const String& parameterLabel,
|
||||
Category parameterCategory = AudioProcessorParameter::genericParameter,
|
||||
std::function<String (float value, int maximumStringLength)> stringFromValue = nullptr,
|
||||
std::function<float (const String& text)> valueFromString = nullptr,
|
||||
int versionHint = 0);
|
||||
std::function<float (const String& text)> valueFromString = nullptr)
|
||||
: AudioParameterFloat (parameterID,
|
||||
parameterName,
|
||||
std::move (normalisableRange),
|
||||
defaultValue,
|
||||
AudioParameterFloatAttributes().withLabel (parameterLabel)
|
||||
.withCategory (parameterCategory)
|
||||
.withStringFromValueFunction (std::move (stringFromValue))
|
||||
.withValueFromStringFunction (std::move (valueFromString)))
|
||||
{
|
||||
}
|
||||
|
||||
/** Creates a AudioParameterFloat with an ID, name, and range.
|
||||
On creation, its value is set to the default value.
|
||||
For control over skew factors, you can use the other
|
||||
constructor and provide a NormalisableRange.
|
||||
*/
|
||||
AudioParameterFloat (String parameterID,
|
||||
String parameterName,
|
||||
AudioParameterFloat (const ParameterID& parameterID,
|
||||
const String& parameterName,
|
||||
float minValue,
|
||||
float maxValue,
|
||||
float defaultValue);
|
||||
|
|
@ -108,7 +148,7 @@ private:
|
|||
float getValueForText (const String&) const override;
|
||||
|
||||
std::atomic<float> value;
|
||||
const float defaultValue;
|
||||
const float valueDefault;
|
||||
std::function<String (float, int)> stringFromValueFunction;
|
||||
std::function<float (const String&)> valueFromStringFunction;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue