Table of Contents

Class SpectrumAnalyzer

Namespace
PluginUI
Assembly
PluginUI.dll

Real-time FFT spectrum analyzer reading an AudioRingBuffer: logarithmic frequency axis, dB range, per-column attack/release smoothing, peak-hold curve, slope compensation (dB/octave around 1 kHz), line or fractional-octave bar display, labeled grid. iPlug2 IVSpectrumAnalyzerControl.

public class SpectrumAnalyzer : Control
Inheritance
SpectrumAnalyzer
Inherited Members

Remarks

The FFT runs on the UI thread at frame rate, only when new audio arrived. Buffers are preallocated.

Constructors

SpectrumAnalyzer()

Creates an analyzer.

public SpectrumAnalyzer()

Properties

AttackSeconds

Attack time constant in seconds.

public float AttackSeconds { get; set; }

Property Value

float

BandsPerOctave

Bars per octave in Bars (1, 2, 3, 6...).

public int BandsPerOctave { get; set; }

Property Value

int

CurveColor

Curve color (null = theme accent).

public Color? CurveColor { get; set; }

Property Value

Color?

DefaultSize

Natural size used when no explicit size is given.

protected override Size DefaultSize { get; }

Property Value

Size

FftSize

FFT size (power of two, 256..16384).

public int FftSize { get; set; }

Property Value

int

IsFrozen

Stops updating.

public bool IsFrozen { get; set; }

Property Value

bool

MaxDb

Top of the dB range.

public float MaxDb { get; set; }

Property Value

float

MaxFrequency

Highest displayed frequency.

public float MaxFrequency { get; set; }

Property Value

float

MinDb

Bottom of the dB range.

public float MinDb { get; set; }

Property Value

float

MinFrequency

Lowest displayed frequency.

public float MinFrequency { get; set; }

Property Value

float

Mode

Line or bars.

public SpectrumMode Mode { get; set; }

Property Value

SpectrumMode

PeakDecayDbPerSecond

Peak curve decay in dB per second.

public float PeakDecayDbPerSecond { get; set; }

Property Value

float

ReleaseDbPerSecond

Release speed in dB per second.

public float ReleaseDbPerSecond { get; set; }

Property Value

float

SampleRate

Sample rate of the source in Hz.

public float SampleRate { get; set; }

Property Value

float

ShowGrid

Draws the frequency/dB grid and labels.

public bool ShowGrid { get; set; }

Property Value

bool

ShowPeakHold

Draws a slowly decaying peak curve.

public bool ShowPeakHold { get; set; }

Property Value

bool

SlopeDbPerOctave

Tilt added to the spectrum in dB per octave around 1 kHz (4.5 makes pink noise look flat).

public float SlopeDbPerOctave { get; set; }

Property Value

float

Source

Sample source.

[Browsable(false)]
public AudioRingBuffer? Source { get; set; }

Property Value

AudioRingBuffer

Window

Analysis window.

public WindowFunction Window { get; set; }

Property Value

WindowFunction

Methods

FrequencyToX(float, Rect)

X position of a frequency inside an area (log axis).

public float FrequencyToX(float hz, Rect area)

Parameters

hz float
area Rect

Returns

float

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()

RenderVector(DrawingContext, Rect, VectorStyle)

Vector rendering of the widget area.

protected override void RenderVector(DrawingContext dc, Rect widget, VectorStyle style)

Parameters

dc DrawingContext
widget Rect
style VectorStyle

XToFrequency(float, Rect)

Frequency at an X position inside an area.

public float XToFrequency(float x, Rect area)

Parameters

x float
area Rect

Returns

float