Table of Contents

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

name string

Display name.

min double

Minimum plain value.

max double

Maximum plain value.

defaultValue double

Default plain value.

units string

Unit label.

scale ParameterScale

Mapping (linear if null).

stepCount int

0 = continuous; otherwise number of steps.

decimals int

Decimals of the default formatter.

Properties

Decimals

Decimals of the default formatter.

public int Decimals { get; set; }

Property Value

int

DefaultNormalizedValue

Default normalized value.

public double DefaultNormalizedValue { get; }

Property Value

double

Formatter

Custom formatter (plain value → text).

public Func<double, string>? Formatter { get; set; }

Property Value

Func<double, string>

IsEditing

true between BeginEdit() and EndEdit().

public bool IsEditing { get; }

Property Value

bool

Items

State labels for list parameters.

public IReadOnlyList<string>? Items { get; }

Property Value

IReadOnlyList<string>

Name

Display name.

public string Name { get; }

Property Value

string

NormalizedValue

Current normalized value.

public double NormalizedValue { get; set; }

Property Value

double

SelectedIndex

Selected index for list/stepped parameters.

public int SelectedIndex { get; set; }

Property Value

int

StepCount

0 = continuous; otherwise number of steps (states − 1).

public int StepCount { get; }

Property Value

int

Units

Unit label (Hz, dB, %, ms...).

public string Units { get; }

Property Value

string

Value

Current plain value.

public double Value { get; set; }

Property Value

double

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

name string
items IReadOnlyList<string>
defaultIndex int

Returns

LocalParameter

PerformEdit(double)

Sets the value during a gesture.

public void PerformEdit(double normalized)

Parameters

normalized double

ToDisplayString(double)

Text for a normalized value (without units).

public string ToDisplayString(double normalized)

Parameters

normalized double

Returns

string

ToNormalized(double)

Plain → normalized value.

public double ToNormalized(double plain)

Parameters

plain double

Returns

double

ToPlain(double)

Normalized → plain value.

public double ToPlain(double normalized)

Parameters

normalized double

Returns

double

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

name string
defaultOn bool

Returns

LocalParameter

TryParse(string, out double)

Parses user text (with or without units) into a normalized value.

public bool TryParse(string text, out double normalized)

Parameters

text string
normalized double

Returns

bool

Events

Changed

Raised after every value change.

public event Action<IParameter>? Changed

Event Type

Action<IParameter>

EditEnded

Raised by EndEdit().

public event Action<LocalParameter>? EditEnded

Event Type

Action<LocalParameter>

EditStarted

Raised by BeginEdit().

public event Action<LocalParameter>? EditStarted

Event Type

Action<LocalParameter>