PcmFrame class

One PCM frame: raw post-DSP audio samples captured at the player's output, before they're handed to the OS audio driver.

Emitted on PlayerStream.pcm at the rate configured in SpectrumSettings.emitInterval (default ~30 Hz). Use this for time-domain visualisations the FFT pipeline can't express: accurate VU and peak meters, oscilloscopes, vectorscopes, custom feature extractors that need raw amplitude.

A frame holds the latest audio the tap saw, up to 4096 frames per channel, whatever came before: consecutive frames overlap (about 60 % on PlayerStream.pcm at the default 33 ms), so they cannot be appended one after the other into a continuous signal.

For a frequency-domain visualizer (spectrum bars, glow effects), prefer FftFrame from PlayerStream.fft. The two streams share the same upstream tap, so subscribing to both costs only the duplicate FFT computation, not a second tap.

Example: a peak-hold VU meter:

double peak = 0;
player.stream.pcm.listen((frame) {
  for (final s in frame.samples) {
    if (s.abs() > peak) peak = s.abs();
  }
  peak *= 0.92; // decay
  _vuController.value = peak;
});

Constructors

PcmFrame({required Float32List samples, required Duration timestamp, required int sampleRate, required int channels})
Creates a frame. The player's pipelines build them, and an app can build one to run through a BandProcessor.
const

Properties

channels → int
Channel count: 1 for mono, 2 for stereo, 6 for 5.1, etc. Combine with samples.length to compute samplesPerChannel.
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 in Hz (typically 44100 or 48000).
final
samples → Float32List
Interleaved Float32 samples, nominally in [-1.0, +1.0] (float audio can exceed it, for example after a gain stage). For stereo audio the layout is L, R, L, R, …; for 5.1 it's L, R, C, LFE, Ls, Rs, …. Length is samplesPerChannel * channels. Total samples per channel: samples.length ~/ channels.
final
samplesPerChannel → int
Convenience: number of samples per channel (samples.length / channels).
no setter
timestamp → Duration
Engine-clock timestamp at which the audio output captured this frame. Process-monotonic: derived from libmpv's internal mp_time_ns(), which counts from the moment the engine initialised, not from the start of the track. Use it to detect fresh frames or to align side-effects in real time; for the playback PTS of these samples, read PlayerStream.position or PlayerStream.audioPts instead. Frames from PlayerStream.tap are the exception: their timestamp is the position in the track of the last sample.
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