Skip to main content

Module audio_io

Module audio_io 

Source
Expand description

Audio source/sink traits.

These are the seam the WaveKat audio pipeline is drawn against: whatever produces audio (a microphone, a TTS engine, a WAV file) implements AudioSource; whatever consumes it (a speaker, an RTP encoder, an ASR worker) implements AudioSink. Concrete impls live in the consuming crates — cpal-backed mic/speaker in wavekat-voice, a future agent-driven impl in wavekat-agent, and so on — so that adding a new producer or consumer is “implement the trait” rather than “rewrite the RTP path.”

The traits speak in AudioFrame<'static>: sample-rate-tagged frames so consumers can resample to whatever rate the codec wants without either side of the trait having to know the codec exists.

Traits§

AudioSink
Consumes audio frames. Implementations may drop frames on backpressure rather than block the caller; the alternative — stalling — is worse on the RTP receive path, where it stalls the whole pipeline.
AudioSource
Produces owned AudioFrames. next_frame().await returns the next frame when one is available, or None once the source has run out (file ended, device closed, dialogue terminated). Each frame’s AudioFrame::sample_rate is set by the implementation — consumers resample as needed.