Treatment encodeMonoFlac
audio/encode::encodeMonoFlac
Parameters
↳ var sample_rate: u32
Inputs
⇥ signal: Stream<f32>
Outputs
↦ data: Stream<byte>
↦ errors: Stream<string>
↦ failed: Block<void>
Encode a normalised mono f32 signal into a FLAC byte stream.
Samples arrive through signal as f32 values in the range [-1.0, 1.0]. They are
quantised to 24-bit signed integer PCM (preserving full audible dynamic range) and
encoded with the FLAC lossless codec. The resulting bytes are emitted through data.
sample_rate must match the rate at which the samples in signal were produced.
Because FLAC requires the full sample buffer before the stream header can be written,
all samples are buffered in memory before any bytes are emitted on data.
errors emits a message if encoding fails. failed triggers on any fatal error.
graph LR
T("encodeMonoFlac()")
S["−0.3 … 0.7"] -->|signal| T
T -->|data| D["🟦 … 🟥"]
T -->|errors| E["…"]
T -->|failed| F["⬛"]
style S fill:#ffff,stroke:#ffff
style D fill:#ffff,stroke:#ffff
style E fill:#ffff,stroke:#ffff
style F fill:#ffff,stroke:#ffff