AmbeDecoder

Struct AmbeDecoder 

Source
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 frame
  • prev — previous frame’s parameters (before enhancement), used as the prediction reference for delta decoding
  • prev_enhanced — previous frame’s parameters (after spectral enhancement), used as the cross-fade source during synthesis

§Invariants

  • Create one AmbeDecoder per voice stream (per D-STAR StreamId).
  • Feed frames sequentially in receive order.
  • Discard the decoder when the stream ends (VoiceEnd event).
  • The decoder is deterministic: same input sequence always produces the same output.

Implementations§

Source§

impl AmbeDecoder

Source

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.

Source

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

Source§

fn clone(&self) -> AmbeDecoder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AmbeDecoder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AmbeDecoder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.