Skip to main content

quantize_i16

Function quantize_i16 

Source
pub fn quantize_i16(x: f32) -> i16
Expand description

Quantize one f32 sample to signed 16-bit PCM (no dither).

The scale factor 32768 uses the full negative range (-1.0 maps to -32768); +1.0 cannot be represented and clamps to 32767. Inputs outside [-1.0, 1.0] saturate to the range bounds. Non-finite inputs saturate through the as cast (NaN -> 0, +inf -> 32767, -inf -> -32768). Rounding is round-half-away-from-zero.