Skip to main content

flexaudio_encode/
lib.rs

1//! flexaudio-encode — an add-on that compresses recording chunks into FLAC files as they arrive.
2//!
3//! It does not depend on `flexaudio-core` and accepts only interleaved `&[f32]` samples.
4//! Encoding uses the pure Rust `flacenc` crate, with no system libraries or runtime
5//! network access. It can losslessly compress long recordings to roughly half the size
6//! of WAV (for example, a 3-hour meeting recording of about 2 GB becomes a few hundred MB).
7//!
8//! Each incoming chunk is encoded in blocks and streamed to a file, so memory use stays
9//! constant regardless of recording length. Stream metadata (total sample count, MD5,
10//! etc.) is finalized in the header by [`FlacWriter::finalize`].
11//!
12//! # Example
13//! ```no_run
14//! use flexaudio_encode::FlacWriter;
15//!
16//! // Pass flexaudio's canonical format (48 kHz / stereo) directly.
17//! let mut writer = FlacWriter::create("meeting.flac", 48_000, 2).unwrap();
18//! for chunk in some_audio_chunks() {
19//!     writer.write_chunk(chunk).unwrap();
20//! }
21//! writer.finalize().unwrap();
22//! # fn some_audio_chunks() -> Vec<&'static [f32]> { vec![] }
23//! ```
24
25#![warn(missing_docs)]
26
27mod error;
28mod writer;
29
30pub use error::{EncodeError, Result};
31pub use writer::FlacWriter;