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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//! # blip25-mbe
//!
//! A clean-room implementation of the MBE vocoder family.
//!
//! ## Quick start
//!
//! Most consumers should use the chip-shaped [`vocoder::Vocoder`]
//! façade:
//!
//! ```rust
//! use blip25_mbe::vocoder::{Rate, Vocoder};
//!
//! // Open a P25 Phase 1 (full-rate IMBE) channel.
//! let mut tx = Vocoder::new(Rate::Imbe7200x4400);
//! let pcm: [i16; 160] = [0; 160];
//! let bits = tx.encode_pcm(&pcm).unwrap();
//! assert_eq!(bits.len(), 18);
//!
//! let mut rx = Vocoder::new(Rate::Imbe7200x4400);
//! let out = rx.decode_bits(&bits).unwrap();
//! assert_eq!(out.len(), 160);
//! ```
//!
//! Three streaming variants on top of the per-frame primitive:
//!
//! - [`vocoder::Vocoder::encode_stream`] / [`vocoder::Vocoder::decode_stream`]
//! — slice → `Iterator<Item = Result<…>>`, drops trailing partial frames.
//! - [`vocoder::LiveEncoder`] / [`vocoder::LiveDecoder`] — chunk-driven
//! with internal residue buffer for audio-callback / socket use.
//! - [`vocoder::VocoderBuilder`] — fluent configuration of optional
//! knobs (tone detection, beyond-spec repeat reset).
//!
//! See [`vocoder`] for the full API and `INTEGRATION.md` for the
//! AMBE-3000R protocol → Vocoder operation correspondence.
//!
//! ## Module organization
//!
//! See [`DESIGN.md`](https://github.com/) at the repository root for
//! the architectural model. The public API is organized around four
//! orthogonal axes joined at a common parameter type:
//!
//! - [`vocoder`] — chip-shaped façade. **Recommended entry point.**
//! - [`mbe_params`] — the parameter model. The interchange type and
//! the center of gravity of the crate.
//! - [`codecs`] — analysis and synthesis algorithms, one submodule
//! per codec generation (`mbe_baseline`, `ambe`, `ambe_plus`,
//! `ambe_plus2`).
//! - **Wire formats**, one module per protocol-rate combination:
//! [`imbe_wire`] (P25 Phase 1 IMBE, 144-bit), [`ambe_plus2_wire`]
//! (P25 Phase 2 AMBE+2, 72-bit), and [`dvsi_3000`] (DVSI chip
//! protocol, r0..r63). Future protocols (DMR, D-STAR, NXDN, …)
//! become sibling modules.
//! - [`rate_conversion`] — parameter-domain bits-to-bits conversion,
//! a peer of the codec and wire layers, not a sub-concern of either.
//!
//! Primitives shared across layers live in [`fec`] and [`bits`].
//!
//! ## Cargo features
//!
//! - `serde` (off by default) — derive `Serialize` / `Deserialize` on
//! the diagnostic types in [`vocoder`] (`Rate`, `FrameStats`,
//! `AnalysisStats`, `AnalysisOutputKind`, `DecodeStats`) plus
//! [`mbe_params::MbeParams`] and
//! [`codecs::mbe_baseline::FrameDisposition`]. Useful for shipping
//! stats / params over a future RPC layer (gRPC / protobuf / WS)
//! without hand-rolled converters.