Expand description
AMBE-to-PCM-to-MP3 audio decode pipeline.
D-STAR voice transmissions encode speech using the AMBE 3600x2450 codec at 3600 bits/second (2450 bps voice + 1150 bps FEC). Each voice frame is 9 bytes, transmitted at 50 frames/second (one every 20 ms). The decoder pipeline converts these compressed frames into standard MP3 audio:
[u8; 9] x N mbelib-rs mp3lame-encoder
AMBE frames ------> PCM i16 @ 8 kHz ------> MP3 bytes
decode_frame() encode + flushยงPipeline stages
-
AMBE decode (
mbelib_rs::AmbeDecoder): Each 9-byte AMBE frame is decoded into 160 signed 16-bit PCM samples at 8000 Hz (20 ms of audio). The decoder carries inter-frame state for delta prediction and phase-continuous synthesis, so frames must be fed sequentially. -
PCM accumulation: All 160-sample chunks are concatenated into a single
Vec<i16>buffer. For a typical 3-second D-STAR transmission (150 frames), this is 24,000 samples. -
MP3 encoding (
mp3lame_encoder): The accumulated PCM buffer is encoded in one pass using LAME configured for mono, 8000 Hz input sample rate, CBR at the requested bitrate. A final flush writes any remaining LAME internal buffer to complete the MP3 stream.
Enumsยง
- Decode
Error ๐ - Errors that can occur during the AMBE-to-MP3 decode pipeline.
Functionsยง
- bitrate_
from_ ๐kbps - Maps a bitrate in kbps (u32) to the
mp3lame_encoder::Bitrateenum. - decode_
to_ ๐mp3 - Decodes a sequence of 9-byte AMBE voice frames into an MP3 byte buffer.