35 enum EParamType { kTypeNone, kTypeBool, kTypeInt, kTypeEnum, kTypeDouble };
38 enum EParamUnit { kUnitPercentage, kUnitSeconds, kUnitMilliseconds, kUnitSamples, kUnitDB, kUnitLinearGain, kUnitPan, kUnitPhase, kUnitDegrees, kUnitMeters, kUnitRate, kUnitRatio, kUnitFrequency, kUnitOctaves, kUnitCents, kUnitAbsCents, kUnitSemitones, kUnitMIDINote, kUnitMIDICtrlNum, kUnitBPM, kUnitBeats, kUnitCustom };
41 enum EDisplayType { kDisplayLinear, kDisplayLog, kDisplayExp, kDisplaySquared, kDisplaySquareRoot, kDisplayCubed, kDisplayCubeRoot };
144 void InitBool(
const char* name,
bool defaultValue,
const char* label =
"",
int flags = 0,
const char* group =
"",
const char* offText =
"off",
const char* onText =
"on");
154 void InitEnum(
const char* name,
int defaultValue,
int nEnums,
const char* label =
"",
int flags = 0,
const char* group =
"",
const char* listItems = 0, ...);
162 void InitEnum(
const char* name,
int defaultValue,
const std::initializer_list<const char*>& listItems,
int flags = 0,
const char* group =
"");
172 void InitInt(
const char* name,
int defaultValue,
int minVal,
int maxVal,
const char* label =
"",
int flags = 0,
const char* group =
"");
186 void InitDouble(
const char* name,
double defaultVal,
double minVal,
double maxVal,
double step,
const char* label =
"",
int flags = 0,
const char* group =
"",
const Shape& shape = ShapeLinear(),
EParamUnit unit = kUnitCustom,
DisplayFunc displayFunc =
nullptr);
196 void InitSeconds(
const char* name,
double defaultVal = 1.,
double minVal = 0.,
double maxVal = 10.,
double step = 0.1,
int flags = 0,
const char* group =
"");
206 void InitMilliseconds(
const char* name,
double defaultVal = 1.,
double minVal = 0.,
double maxVal = 100.,
int flags = 0,
const char* group =
"");
216 void InitFrequency(
const char* name,
double defaultVal = 1000.,
double minVal = 0.1,
double maxVal = 10000.,
double step = 0.1,
int flags = 0,
const char* group =
"");
225 void InitPitch(
const char* name,
int defaultVal = 60,
int minVal = 0,
int maxVal = 128,
int flags = 0,
const char* group =
"",
bool middleCisC4 =
false);
235 void InitGain(
const char* name,
double defaultVal = 0.,
double minVal = -70.,
double maxVal = 24.,
double step = 0.5,
int flags = 0,
const char* group =
"");
244 void InitPercentage(
const char* name,
double defaultVal = 0.,
double minVal = 0.,
double maxVal = 100.,
int flags = 0,
const char* group =
"");
253 void InitAngleDegrees(
const char* name,
double defaultVal = 0.,
double minVal = 0.,
double maxVal = 360.,
int flags = 0,
const char* group =
"");
260 void Init(
const IParam& p,
const char* searchStr =
"",
const char* replaceStr =
"",
const char* newGroup =
"");
272 return Clip((mFlags &
kFlagStepped ? std::round(value / mStep) * mStep : value), mMin, mMax);
280 return ToNormalized(mShape->NormalizedToValue(normalizedValue, *
this));
288 return Clip(mShape->ValueToNormalized(
Constrain(nonNormalizedValue), *
this), 0., 1.);
296 return Constrain(mShape->NormalizedToValue(normalizedValue, *
this));
329 void SetLabel(
const char* label) { strcpy(mLabel, label); }
337 double Value()
const {
return mValue.load(); }
341 bool Bool()
const {
return (mValue.load() >= 0.5); }
345 int Int()
const {
return static_cast<int>(mValue.load()); }
351 double DBToAmp()
const {
return iplug::DBToAmp(mValue.load()); }
360 void GetDisplay(WDL_String& display,
bool withDisplayText =
true)
const {
GetDisplay(mValue.load(),
false, display, withDisplayText); }
367 void GetDisplay(
double value,
bool normalized, WDL_String& display,
bool withDisplayText =
true)
const;
374 GetDisplay(mValue.load(),
false, display, withDisplayText);
376 if (CStringHasContents(hostlabel))
379 display.Append(hostlabel);
397 const char*
GetCustomUnit()
const {
return mUnit == kUnitCustom ? mLabel :
nullptr; }
451 void GetBounds(
double& lo,
double& hi)
const;
487 void GetJSON(WDL_String& json,
int idx)
const;
496 char mText[MAX_PARAM_DISPLAY_LEN];
501 std::atomic<double> mValue{0.0};
505 double mDefault = 0.0;
506 int mDisplayPrecision = 0;
509 char mName[MAX_PARAM_NAME_LEN];
510 char mLabel[MAX_PARAM_LABEL_LEN];
511 char mParamGroup[MAX_PARAM_GROUP_LEN];
513 std::unique_ptr<Shape> mShape;
516 WDL_TypedBuf<DisplayText> mDisplayTexts;
Utility functions and macros.
double GetStep() const
Returns the parameter's step size.
double GetDefault(bool normalized=false) const
Returns the parameter's default value.
void InitGain(const char *name, double defaultVal=0., double minVal=-70., double maxVal=24., double step=0.5, int flags=0, const char *group="")
Initialize the parameter as gain (units in decibels)
void InitAngleDegrees(const char *name, double defaultVal=0., double minVal=0., double maxVal=360., int flags=0, const char *group="")
Initialize the parameter as angle in degrees.
void SetToDefault()
Replaces the parameter's current value with the default one
EParamType Type() const
Get the parameter's type.
int GetFlags() const
Returns the parameter's flags.
double ToNormalized(double nonNormalizedValue) const
Convert a real value to normalized value for this parameter.
void InitPercentage(const char *name, double defaultVal=0., double minVal=0., double maxVal=100., int flags=0, const char *group="")
Initialize the parameter as percentage.
bool GetSignDisplay() const
EFlags
Flags to determine characteristics of the parameter.
@ kFlagSignDisplay
Indicates that the parameter should be displayed as a signed value.
@ kFlagCannotAutomate
Indicates that the parameter is not automatable.
@ kFlagMeta
Indicates that the parameter may influence the state of other parameters.
@ kFlagStepped
Indicates that the parameter is stepped
@ kFlagNegateDisplay
Indicates that the parameter should be displayed as a negative value.
void InitEnum(const char *name, int defaultValue, int nEnums, const char *label="", int flags=0, const char *group="", const char *listItems=0,...)
Initialize the parameter as an enumerated list.
int GetDisplayPrecision() const
Returns the parameter's precision.
bool GetCanAutomate() const
double ConstrainNormalized(double normalizedValue) const
Constrains a normalised input value similarly to Constrain()
void GetDisplay(WDL_String &display, bool withDisplayText=true) const
Get the current textual display for the current parameter value.
double GetMin() const
Returns the parameter's minimum value.
void InitDouble(const char *name, double defaultVal, double minVal, double maxVal, double step, const char *label="", int flags=0, const char *group="", const Shape &shape=ShapeLinear(), EParamUnit unit=kUnitCustom, DisplayFunc displayFunc=nullptr)
Initialize the parameter as double.
void Init(const IParam &p, const char *searchStr="", const char *replaceStr="", const char *newGroup="")
Initialize the parameter based on another parameter, replacing a CString in the name.
void SetDisplayFunc(DisplayFunc func)
Set the function to translate display values.
void GetBounds(double &lo, double &hi) const
Get the minimum and maximum real value of the parameter's range in one method call.
void Set(double value)
Sets the parameter value.
const char * GetLabel() const
Returns the parameter's label.
bool GetNegateDisplay() const
void SetDisplayText(double value, const char *str)
Set some text to display for a particular value, e.g.
std::function< void(double, WDL_String &)> DisplayFunc
DisplayFunc allows custom parameter display functions, defined by a lambda matching this signature.
double DBToAmp() const
Gain based on parameter's current value in dB.
double StringToValue(const char *str) const
Convert a textual representation of the parameter value to a double (real value)
EParamUnit Unit() const
Get the parameter's unit.
bool MapDisplayText(const char *str, double *pValue) const
Get the value of a particular display text.
void InitFrequency(const char *name, double defaultVal=1000., double minVal=0.1, double maxVal=10000., double step=0.1, int flags=0, const char *group="")
Initialize the parameter as frequency.
void SetNormalized(double normalizedValue)
Sets the parameter value from a normalized range (usually coming from the linked IControl)
EParamUnit
Used by AudioUnit plugins to determine the appearance of parameters, based on the kind of data they r...
void SetString(const char *str)
Set the parameter value using a textual representation.
const char * GetName() const
Returns the parameter's name.
EDisplayType DisplayType() const
Get the parameter's display type.
void InitSeconds(const char *name, double defaultVal=1., double minVal=0., double maxVal=10., double step=0.1, int flags=0, const char *group="")
Initialize the parameter as seconds.
double FromNormalized(double normalizedValue) const
Convert a normalized value to real value for this parameter.
bool Bool() const
Returns the parameter's value as a boolean.
void GetDisplayWithLabel(WDL_String &display, bool withDisplayText=true) const
Fills the WDL_String the value of the parameter along with the label, e.g.
void PrintDetails() const
Helper to print the parameter details to debug console in debug builds.
double GetNormalized() const
Returns the parameter's normalized value.
const char * GetDisplayTextAtIdx(int idx, double *pValue=nullptr) const
Get the display text at a particular index.
int Int() const
Returns the parameter's value as an integer.
double Constrain(double value) const
Constrains the input value between mMin and mMax and apply stepping if relevant.
void SetLabel(const char *label)
Set the parameters label after creation.
double GetRange() const
Returns the parameter's range.
const char * GetDisplayText(double value) const
Get the display text for a particular value.
const char * GetGroup() const
Returns the parameter's group.
void InitMilliseconds(const char *name, double defaultVal=1., double minVal=0., double maxVal=100., int flags=0, const char *group="")
Initialize the parameter as milliseconds.
void SetDisplayPrecision(int precision)
Set the parameters display precision.
EDisplayType
Used by AudioUnit plugins to determine the mapping of parameters.
void InitPitch(const char *name, int defaultVal=60, int minVal=0, int maxVal=128, int flags=0, const char *group="", bool middleCisC4=false)
Initialize the parameter as pitch.
double Value() const
Gets a readable value of the parameter.
int NDisplayTexts() const
Get the number of display texts for the parameter.
EParamType
Defines types or parameter.
double GetMax() const
Returns the parameter's maximum value.
void InitBool(const char *name, bool defaultValue, const char *label="", int flags=0, const char *group="", const char *offText="off", const char *onText="on")
Initialize the parameter as boolean.
void SetDefault(double value)
Set the parameter's default value, and set the parameter to that default.
const char * GetCustomUnit() const
Get parameter's label (unit suffix)
void InitInt(const char *name, int defaultValue, int minVal, int maxVal, const char *label="", int flags=0, const char *group="")
Initialize the parameter as integer.
void GetJSON(WDL_String &json, int idx) const
Get a JSON description of the parameter.
BEGIN_IPLUG_NAMESPACE T Clip(T x, T lo, T hi)
Clips the value x between lo and hi.
Exponential parameter shaping.
void Init(const IParam ¶m) override
Initializes the shape instance.
double NormalizedToValue(double value, const IParam ¶m) const override
Returns the real value from a normalized input, based on an IParam's settings.
double ValueToNormalized(double value, const IParam ¶m) const override
Returns the normalized value from a real value, based on an IParam's settings.
IParam::EDisplayType GetDisplayType() const override
Shape * Clone() const override
Base struct for parameter shaping.
virtual double NormalizedToValue(double value, const IParam ¶m) const =0
Returns the real value from a normalized input, based on an IParam's settings.
virtual Shape * Clone() const =0
virtual double ValueToNormalized(double value, const IParam ¶m) const =0
Returns the normalized value from a real value, based on an IParam's settings.
virtual EDisplayType GetDisplayType() const =0
virtual void Init(const IParam ¶m)
Initializes the shape instance.
Linear parameter shaping.
double ValueToNormalized(double value, const IParam ¶m) const override
Returns the normalized value from a real value, based on an IParam's settings.
double NormalizedToValue(double value, const IParam ¶m) const override
Returns the real value from a normalized input, based on an IParam's settings.
IParam::EDisplayType GetDisplayType() const override
Shape * Clone() const override
PowCurve parameter shaping.
Shape * Clone() const override
IParam::EDisplayType GetDisplayType() const override
double ValueToNormalized(double value, const IParam ¶m) const override
Returns the normalized value from a real value, based on an IParam's settings.
double NormalizedToValue(double value, const IParam ¶m) const override
Returns the real value from a normalized input, based on an IParam's settings.