Class LocalParameter
- Namespace
- PluginUI
- Assembly
- PluginUI.dll
Self-contained IParameter for values that are not plug-in parameters (UI state, standalone applications, the gallery, tests).
public sealed class LocalParameter : IParameter
- Inheritance
-
LocalParameter
- Implements
- Inherited Members
- Extension Methods
Examples
var gain = new LocalParameter("Gain", -24, 24, 0, "dB", decimals: 1);
var cutoff = new LocalParameter("Cutoff", 20, 20000, 1000, "Hz", ParameterScale.Logarithmic(20, 20000), decimals: 0);
var mode = new LocalParameter("Mode", 0, 2, 0, stepCount: 2, decimals: 0);
cutoff.Value = 2400; // plain value
string text = cutoff.ToDisplayString(cutoff.NormalizedValue); // "2400" (the unit is in cutoff.Units)
Constructors
LocalParameter(string, double, double, double, string, ParameterScale?, int, int)
Creates a continuous (or stepped) parameter.
public LocalParameter(string name, double min = 0, double max = 1, double defaultValue = 0, string units = "", ParameterScale? scale = null, int stepCount = 0, int decimals = 2)
Parameters
namestringDisplay name.
mindoubleMinimum plain value.
maxdoubleMaximum plain value.
defaultValuedoubleDefault plain value.
unitsstringUnit label.
scaleParameterScaleMapping (linear if null).
stepCountint0 = continuous; otherwise number of steps.
decimalsintDecimals of the default formatter.
Properties
Decimals
Decimals of the default formatter.
public int Decimals { get; set; }
Property Value
DefaultNormalizedValue
Default normalized value.
public double DefaultNormalizedValue { get; }
Property Value
Formatter
Custom formatter (plain value → text).
public Func<double, string>? Formatter { get; set; }
Property Value
IsEditing
true between BeginEdit() and EndEdit().
public bool IsEditing { get; }
Property Value
Items
State labels for list parameters.
public IReadOnlyList<string>? Items { get; }
Property Value
Name
Display name.
public string Name { get; }
Property Value
NormalizedValue
Current normalized value.
public double NormalizedValue { get; set; }
Property Value
SelectedIndex
Selected index for list/stepped parameters.
public int SelectedIndex { get; set; }
Property Value
StepCount
0 = continuous; otherwise number of steps (states − 1).
public int StepCount { get; }
Property Value
Units
Unit label (Hz, dB, %, ms...).
public string Units { get; }
Property Value
Value
Current plain value.
public double Value { get; set; }
Property Value
Methods
BeginEdit()
Starts an edit gesture.
public void BeginEdit()
EndEdit()
Ends the edit gesture.
public void EndEdit()
FromList(string, IReadOnlyList<string>, int)
Discrete parameter whose states are labeled by items.
public static LocalParameter FromList(string name, IReadOnlyList<string> items, int defaultIndex = 0)
Parameters
namestringitemsIReadOnlyList<string>defaultIndexint
Returns
PerformEdit(double)
Sets the value during a gesture.
public void PerformEdit(double normalized)
Parameters
normalizeddouble
ToDisplayString(double)
Text for a normalized value (without units).
public string ToDisplayString(double normalized)
Parameters
normalizeddouble
Returns
ToNormalized(double)
Plain → normalized value.
public double ToNormalized(double plain)
Parameters
plaindouble
Returns
ToPlain(double)
Normalized → plain value.
public double ToPlain(double normalized)
Parameters
normalizeddouble
Returns
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
Toggle(string, bool)
On/off parameter.
public static LocalParameter Toggle(string name, bool defaultOn = false)
Parameters
Returns
TryParse(string, out double)
Parses user text (with or without units) into a normalized value.
public bool TryParse(string text, out double normalized)
Parameters
Returns
Events
Changed
Raised after every value change.
public event Action<IParameter>? Changed
Event Type
EditEnded
Raised by EndEdit().
public event Action<LocalParameter>? EditEnded
Event Type
EditStarted
Raised by BeginEdit().
public event Action<LocalParameter>? EditStarted