Class LevelMeter
- Namespace
- PluginUI
- Assembly
- PluginUI.dll
Multi-channel level meter: vertical or horizontal, dB scale with marks, gradient / LED segments / solid bars, peak-hold markers, latched clip indicators (click to reset), optional RMS + peak dual display, gain-reduction mode.
public class LevelMeter : Control
- Inheritance
-
LevelMeter
- Inherited Members
Remarks
Feed it on the UI thread with SetLevels(params float[]) (and SetRmsLevels(params float[])), or give it PeakValue Sources written by the audio thread: they are polled on every frame.
Ballistics (instant attack, dB/s release, peak hold) come from LevelBallistics.
Constructors
LevelMeter()
Creates a stereo meter.
public LevelMeter()
Properties
ChannelCount
Number of channels.
public int ChannelCount { get; set; }
Property Value
ChannelGap
Gap between channel bars in DIPs.
public float ChannelGap { get; set; }
Property Value
ClipDb
Level at which the clip indicator latches (dB).
public float ClipDb { get; set; }
Property Value
DangerColor
High-level color (null = theme danger).
public Color? DangerColor { get; set; }
Property Value
DangerDb
Level where the gradient turns red (dB).
public float DangerDb { get; set; }
Property Value
DefaultSize
Natural size used when no explicit size is given.
protected override Size DefaultSize { get; }
Property Value
HoldSeconds
Peak-hold time in seconds.
public float HoldSeconds { get; set; }
Property Value
InputUnit
Unit of the values passed to SetLevels(params float[]).
public LevelUnit InputUnit { get; set; }
Property Value
LowColor
Low-level color (null = green).
public Color? LowColor { get; set; }
Property Value
MaxDb
Top of the scale in dB.
public float MaxDb { get; set; }
Property Value
MaxReductionDb
Full scale of the gain-reduction mode (dB).
public float MaxReductionDb { get; set; }
Property Value
MeterStyle
Drawing style.
public MeterStyle MeterStyle { get; set; }
Property Value
MinDb
Bottom of the scale in dB.
public float MinDb { get; set; }
Property Value
Mode
Level or gain-reduction meter.
public MeterMode Mode { get; set; }
Property Value
Orientation
Bar orientation.
public Orientation Orientation { get; set; }
Property Value
ReleaseDbPerSecond
Peak release speed in dB per second.
public float ReleaseDbPerSecond { get; set; }
Property Value
RmsSources
Optional audio-thread RMS sources (one per channel).
[Browsable(false)]
public IReadOnlyList<PeakValue>? RmsSources { get; set; }
Property Value
ScaleMarks
Scale marks in dB (null = automatic set).
public IReadOnlyList<float>? ScaleMarks { get; set; }
Property Value
SegmentGap
Gap between LED segments in DIPs.
public float SegmentGap { get; set; }
Property Value
SegmentLength
LED segment length in DIPs (segment style).
public float SegmentLength { get; set; }
Property Value
ShowClipIndicator
Draws latched clip indicators above the bars (click to reset).
public bool ShowClipIndicator { get; set; }
Property Value
ShowPeakHold
Draws peak-hold markers.
public bool ShowPeakHold { get; set; }
Property Value
ShowScale
Draws the dB scale (marks and labels) beside the bars.
public bool ShowScale { get; set; }
Property Value
Sources
Audio-thread level sources polled every frame (one per channel; null = use SetLevels(params float[])).
[Browsable(false)]
public IReadOnlyList<PeakValue>? Sources { get; set; }
Property Value
WarningColor
Warning color (null = theme warning).
public Color? WarningColor { get; set; }
Property Value
WarningDb
Level where the gradient turns yellow (dB).
public float WarningDb { get; set; }
Property Value
Methods
ColorForDb(float)
Color of a level (gradient zones).
protected Color ColorForDb(float db)
Parameters
dbfloat
Returns
Fraction(float)
Position of a dB value along the bar, 0 (empty end) → 1 (full end).
protected float Fraction(float db)
Parameters
dbfloat
Returns
GetDisplayedLevel(int)
Peak level (dB) currently displayed for a channel.
public float GetDisplayedLevel(int channel)
Parameters
channelint
Returns
IsClipped(int)
true if the channel's clip indicator is latched.
public bool IsClipped(int channel)
Parameters
channelint
Returns
OnAttached()
Called when the element joins a host (subscribe to external events here).
protected override void OnAttached()
OnDetached()
Called when the element leaves its host (unsubscribe here).
protected override void OnDetached()
OnMouseDown(MouseEventArgs)
Mouse button pressed over the element (or captured).
protected override void OnMouseDown(MouseEventArgs e)
Parameters
OnRender(DrawingContext)
Draws the meter. With a Skin (for example a FilmStripSkin whose frame follows the level), the skin draws each channel in its own bar area: Value is the channel level mapped to [0, 1] over MinDb…MaxDb (or the reduction range in gain-reduction mode) and StateIndex is 1 while the channel's clip indicator is latched. The scale is still drawn.
protected override void OnRender(DrawingContext dc)
Parameters
dcDrawingContextDrawing context.
RenderVector(DrawingContext, Rect, VectorStyle)
Vector rendering of the widget area.
protected override void RenderVector(DrawingContext dc, Rect widget, VectorStyle style)
Parameters
dcDrawingContextwidgetRectstyleVectorStyle
Reset()
Resets levels, holds and clip indicators.
public void Reset()
ResetClip()
Resets the clip indicators.
public void ResetClip()
SetLevels(params float[])
Sets the current peak levels (UI thread), one per channel, in InputUnit. In gain-reduction mode, pass the reduction in positive dB (or linear gain ≤ 1).
public void SetLevels(params float[] levels)
Parameters
levelsfloat[]
SetRmsLevels(params float[])
Sets the current RMS levels (enables the dual peak/RMS display).
public void SetRmsLevels(params float[] levels)
Parameters
levelsfloat[]
Events
ClipReset
Raised when the user resets the clip indicators.
public event Action<LevelMeter>? ClipReset