Shared types for the WaveKat audio processing ecosystem.
[!WARNING] Early development. API may change.
What's Inside
| Type | Description |
|---|---|
AudioFrame |
Audio samples with sample rate, accepts i16 and f32 in slice, Vec, or array form |
IntoSamples |
Trait for transparent sample format conversion |
AudioSource / AudioSink |
Async producer/consumer traits — the seam every WaveKat audio pipeline composes against |
codec::g711 |
G.711 μ-law (PCMU) and A-law (PCMA) — telephony codecs for SIP/RTP |
Quick Start
use AudioFrame;
// From f32 — zero-copy (slice, &Vec<f32>, or array)
let frame = new;
// From i16 — normalizes to f32 [-1.0, 1.0] automatically
let frame = new;
// From an owned Vec — zero-copy, produces AudioFrame<'static>
let frame = from_vec;
// Inspect the frame
let samples: & = frame.samples;
let rate: u32 = frame.sample_rate;
let n: usize = frame.len;
let empty: bool = frame.is_empty;
let secs: f64 = frame.duration_secs;
// Convert a borrowed frame to owned
let owned: = frame.into_owned;
Audio Format Standard
The WaveKat ecosystem standardizes on 16 kHz, mono, f32 [-1.0, 1.0].
AudioFrame handles the conversion so downstream crates don't have to.
Your audio (any format)
|
v
AudioFrame::new(samples, sample_rate)
|
+---> wavekat-vad
+---> wavekat-turn
+---> wavekat-asr (future)
Audio Sources and Sinks
AudioSource and AudioSink are the producer/consumer seam every WaveKat
audio pipeline composes against. Concrete impls (cpal-backed mic/speaker,
agent-driven sources, RTP-driven sinks, …) live in the consuming crates so
that adding a new producer or consumer is "implement the trait" rather than
"rewrite the RTP path."
use ;
G.711 Telephony Codec
PCMU (μ-law) and PCMA (A-law) — the two static codecs every SIP endpoint speaks. One 16-bit PCM sample ↔ one 8-bit codeword; a 20 ms RTP frame at 8 kHz is 160 samples / 160 bytes.
use ;
// Resolve the codec from a SIP/RTP payload type.
let codec = from_payload_type.unwrap; // 0 = PCMU, 8 = PCMA
// Encode a 20 ms frame of PCM into G.711 bytes.
let pcm: = vec!;
let mut bytes = Vecwith_capacity;
codec.encode;
assert_eq!;
// Decode the other direction.
let mut decoded = Vecwith_capacity;
codec.decode;
assert_eq!;
Optional Features
wav
Adds WAV file I/O via hound.
use AudioFrame;
// Read a WAV file (f32 or i16, normalized automatically)
let frame = from_wav?;
println!;
// Write a frame to a WAV file (mono f32 PCM)
frame.write_wav?;
resample
Adds sample-rate conversion via rubato (high-quality sinc interpolation).
use AudioFrame;
// Resample a 44.1 kHz frame to 24 kHz for TTS
let frame = from_vec;
let frame = frame.resample?;
assert_eq!;
// No-op if already at the target rate
let same = frame.resample?;
License
Licensed under Apache 2.0.
Copyright 2026 WaveKat.