AUDIO
Source snapshot · 11 November 2026

API reference / ravet_audio_file::encode_flac

Function encode_flac 

pub fn encode_flac(
    samples: &[i32],
    format: FlacFormat,
) -> Result<Vec<u8>, AudioFileError>
Expand description

Encode a complete nonempty interleaved signed-PCM clip to owned FLAC bytes. Requires optional flac-encode (pinned Apache-2.0 flacenc, default features disabled). 1..4,194,304 input i32 samples (16 MiB), valid whole frames and precision ranges are checked before backend block copying/encoding. Encoded output is limited to 64 MiB through the incremental writer’s per-frame preflight. Fixed 4096-frame single-thread encoding with constant/verbatim fallback for excessive prediction sizes; backend allocations remain its own contract. No float conversion/clipping, implicit threads, file/network I/O or callback use. This is a complete-clip encoder, not a streaming recorder.