Skip to main content

Module wav

Module wav 

Source
Expand description

WAV (RIFF PCM / IEEE-float) container decoder backed by hound.

WavDecoder runs on a worker thread: it performs blocking file I/O and heap allocation, and is explicitly not real-time safe. Decoded frames must be handed to a lock-free ring buffer so the RT audio thread never calls into this module.

§Sample normalisation

Every decoded sample is normalised to planar f32 in the range [-1.0, 1.0] (approximately):

  • 8-bit unsigned PCMhound returns the value centred around zero (it applies u8 → i8 sign-extension internally), so we scale by 1/128.
  • Signed N-bit integer PCM — scaled by 1 / 2^(N-1) (i16 / 32768.0, i32 / 2_147_483_648.0, etc.).
  • 32-bit IEEE float — passed through unchanged; non-finite samples (NaN/±Inf) are coerced to 0.0 so the RT graph never sees a poison value.

§Planar layout

hound yields interleaved samples (ch0,ch1,ch0,ch1,…). The decoder de-interleaves them into the planar layout required by audio_core_bsd::AudioFrame ([ch0…, ch1…]) before construction. This is the single highest-risk correctness step and is covered by a dedicated stereo property test in self.

Structs§

WavDecoder
A hound-backed decoder for RIFF WAVE containers.