FftFrame class
One FFT frame — a frequency-domain snapshot of the audio currently playing through the player's output.
Emitted on PlayerStream.fft at the rate configured in
SpectrumSettings.emitInterval (default ~30 Hz). Each frame carries
both the raw FFT bins (linear frequency axis, post-window
magnitude, normalised to [0, 1]) and the perceptual bands
(log-spaced bucketing of the bins with asymmetric EMA smoothing —
the visualizer staple). Most callers only need bands; bins is
exposed for custom remappings (mel, Bark, constant-Q).
The frame is immutable and thread-safe to pass between isolates — the underlying Float32Lists are not aliased into the audio thread's ring buffer; they were copied out before this object was constructed.
Example — paint a 64-bar spectrum analyzer:
player.stream.fft.listen((frame) {
for (var i = 0; i < frame.bands.length; i++) {
final h = frame.bands[i] * canvasHeight;
// draw bar i with height h …
}
});
Constructors
- FftFrame({required Float32List bins, required Float32List bands, required Duration timestamp, required int sampleRate, required double bandLowHz, required double bandHighHz})
-
Creates a frame. Only used internally by the spectrum pipeline.
const
Properties
- bandHighHz → double
-
Upper edge of the band axis in Hz. Matches
SpectrumSettings.bandHighHz.
final
- bandLowHz → double
-
Lower edge of the band axis in Hz. Matches
SpectrumSettings.bandLowHz.
final
- bands → Float32List
-
Per-band magnitude on the configured perceptual axis (default:
log-spaced 64 bands from bandLowHz to bandHighHz). Length is
SpectrumSettings.bandCount.
final
- bins → Float32List
-
Magnitude per FFT bin, normalised to
[0, 1]after the power → log → clip → normalise pipeline. Length is half of SpectrumSettings.fftSize (the real FFT only returns the positive-frequency half). Binicoversi * sampleRate / fftSizeHz. No smoothing is applied here — it runs on bands only.final - hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sampleRate → int
-
Sample rate of the audio that produced this frame, in Hz.
Multiply bins indices by
sampleRate / fftSizeto map a bin to its centre frequency.final - timestamp → Duration
-
Playback position the samples backing this FFT correspond to —
derived from mpv's tap timestamp (
pts_nson thepcm-tap-frameproperty). Useful for syncing visual effects against the audio playhead.final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited