1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! # melpe-rs
//!
//! Pure Rust implementation of the **MELPe** (Mixed Excitation Linear Prediction — enhanced)
//! vocoder, conforming to **STANAG 4591** / NATO narrowband voice coding at **600 bps**.
//!
//! ## Quick start
//!
//! ```rust
//! use melpe::encoder::Encoder;
//! use melpe::decoder::Decoder;
//! use melpe::core_types::{SUPERFRAME_SAMPLES, SUPERFRAME_BYTES_600};
//!
//! let mut enc = Encoder::new();
//! let mut dec = Decoder::new();
//!
//! let samples = [0.0f32; SUPERFRAME_SAMPLES];
//! let mut bitstream = [0u8; SUPERFRAME_BYTES_600];
//! enc.encode(&samples, &mut bitstream);
//!
//! let mut output = [0.0f32; SUPERFRAME_SAMPLES];
//! dec.decode(&bitstream, &mut output);
//! ```
//!
//! ## Feature flags
//!
//! - **`std`** (default) — native `f32` math, hardware-backed on x86_64
//! - **`embedded`** — `#![no_std]`, routes math through [`libm`](https://crates.io/crates/libm)
/// Floating-point math shim — dispatches to `std` or `libm` based on feature flags.
/// Constants, frame geometry, and superframe data structures.
/// LPC analysis: autocorrelation, Levinson-Durbin, LPC↔LSF conversion, windowing.
/// Pitch detection via normalized autocorrelation with parabolic interpolation.
/// 5-band bandpass voicing analysis and mixed excitation generation.
/// Scalar quantization of LSFs, pitch, gain, and voicing for 600 bps superframes.
/// Bit-level packing and unpacking of 41-bit superframes into 6 bytes.
/// All-pole synthesis filter, de-emphasis, and frame-level synthesis processor.
/// Top-level encoder: 540 samples → 6 bytes.
/// Top-level decoder: 6 bytes → 540 samples.