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