Skip to main content

Module audio

Module audio 

Source
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

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§

AudioChunk
One timestamped chunk of normalized f32 audio.
AudioFormat
Sample-rate + channels + sample-format triple. Describes the layout of an AudioChunk’s sample buffer.

Enums§

AudioChunkError
Validation failure for AudioChunk::new.
SampleFormat
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, with 0 dBFS mapping to 1.0 and METER_FLOOR_DBFS mapping to 0.0.