Skip to main content

Module wav

Module wav 

Source
Expand description

WAV file reading and writing for audio recording and playback.

Supports 16-bit PCM mono WAV files at any sample rate (typically 8000 Hz for telephony).

Structs§

AudioRecorder
An audio recorder that accumulates PCM samples.
WavHeader
WAV file header parameters

Enums§

WavError

Functions§

compute_snr
Compute the signal-to-noise ratio (SNR) in dB between original and received audio. Higher values mean better fidelity. Typical telephony: >20 dB is acceptable.
cross_correlation
Compute normalized cross-correlation between two signals. Returns a value between -1.0 and 1.0. Values > 0.9 indicate strong similarity.
decode_wav
Read PCM samples from WAV bytes.
encode_wav
Write PCM samples to a WAV file (in memory as bytes).
generate_multi_tone
Generate a multi-tone signal with distinct frequencies (for fidelity testing).
generate_sine_tone
Generate a sine wave tone (for testing).
max_sample_error
Compute the maximum absolute sample-by-sample error.
read_wav
Read PCM samples from a WAV file on disk.
rms_error
Compute root-mean-square error between two signals.
write_wav
Write PCM samples to a WAV file on disk.