pub struct AmbeDecoder { /* private fields */ }Expand description
Stateful AMBE 3600×2400 voice frame decoder.
The AMBE codec uses inter-frame prediction: each frame’s gain and spectral magnitudes are delta-coded against the previous frame. This decoder maintains three parameter snapshots to support that:
cur— parameters decoded from the current frameprev— previous frame’s parameters (before enhancement), used as the prediction reference for delta decodingprev_enhanced— previous frame’s parameters (after spectral enhancement), used as the cross-fade source during synthesis
§Invariants
- Create one
AmbeDecoderper voice stream (per D-STARStreamId). - Feed frames sequentially in receive order.
- Discard the decoder when the stream ends (
VoiceEndevent). - The decoder is deterministic: same input sequence always produces the same output.
Implementations§
Source§impl AmbeDecoder
impl AmbeDecoder
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a new decoder with zeroed initial state.
The first decoded frame will use silence as its prediction reference, which may produce a brief transient. This matches the behavior of hardware DVSI vocoders.
Sourcepub fn decode_frame(&mut self, ambe: &[u8; 9]) -> [i16; 160]
pub fn decode_frame(&mut self, ambe: &[u8; 9]) -> [i16; 160]
Decodes a single 9-byte AMBE frame into 160 PCM samples.
Returns 160 signed 16-bit samples at 8000 Hz (20 ms of audio).
A gain factor of 7.0 is applied and samples are clamped to
±32767 × 0.95 to match JMBE soft-clipping semantics.
If the frame contains excessive bit errors (more than the FEC can correct) or the decoder has hit the maximum repeat count, comfort noise is output instead of synthesized speech.
Trait Implementations§
Source§impl Clone for AmbeDecoder
impl Clone for AmbeDecoder
Source§fn clone(&self) -> AmbeDecoder
fn clone(&self) -> AmbeDecoder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more