Expand description
Audio sample + chunk data model (M-MEDIA.3 / AUT-99).
Audio in this crate is normalized f32 end-to-end: that’s the
shape every downstream visualization (audio-histogram quantization in
M-MEDIA.8, waveform geometry in M-MEDIA.9) expects, and the shape
GStreamer’s audioconvert ! audio/x-raw,format=F32LE produces
natively.
§Types
AudioFormat— sample-rate + channel-count + sample-format triple.AudioChunk— aTimestamped<Vec<f32>>carrying itsAudioFormat+ a derivedMediaDuration.
Interleave order is planar-per-frame: [L₀, R₀, L₁, R₁, …] for
stereo. Mono is just [s₀, s₁, …]. Matches the GStreamer raw audio
convention; matches what cpal / coreaudio emit too, so future device
capture won’t need to re-layout buffers.
§Quick start
use media::audio::{AudioChunk, AudioFormat, SampleFormat};
use media::clock::MediaTime;
let fmt = AudioFormat::mono_f32(48_000);
let samples = vec![0.0_f32; 48_000]; // 1.0 s of silence at 48 kHz mono.
let chunk = AudioChunk::new(fmt, samples, MediaTime::ZERO).expect("valid");
assert!((chunk.duration().as_seconds() - 1.0).abs() < 1e-9);Structs§
- Audio
Chunk - One timestamped chunk of normalized
f32audio. - Audio
Format - Sample-rate + channels + sample-format triple. Describes the layout
of an
AudioChunk’s sample buffer.
Enums§
- Audio
Chunk Error - Validation failure for
AudioChunk::new. - Sample
Format - Internal sample format. Today every code path normalizes to
F32; the enum exists so external GStreamer / cpal capture paths can declare their input layout before normalization.
Constants§
- METER_
FLOOR_ DBFS - Floor of the meter scale, in dBFS. Levels at or below this map to
0.0; full-scale (
rms = 1.0, i.e.0 dBFS) maps to 1.0. -60 dBFS is a standard digital audio meter floor — anything below is barely audible.
Functions§
- rms_
to_ meter_ level - Convert a linear RMS value (
[0, 1]) into a UI-meter level ([0, 1]) on a logarithmic dBFS scale, with0 dBFSmapping to1.0andMETER_FLOOR_DBFSmapping to0.0.