pub fn fsq_quantize(
input: &[f32],
levels: &[u16],
lo: f32,
hi: f32,
out_tokens: &mut [u16],
) -> Result<usize, AudioError>Expand description
Quantize each component of input to its per-dimension level grid, writing level indices.
input: at leastlevels.len()floats.levels: per-dimension level countsL_d(each≥ 1);dim = levels.len().lo,hi: shared inclusive bounds for the grid (hi > lo).out_tokens: at leastdimslots; slotdreceives the level index in0..L_d.
For dim d with L levels the step is (hi - lo)/(L - 1); the index is
round((x - lo)/step) clamped to 0..=L-1. A degenerate L == 1 collapses to index 0.
Returns the number of tokens written (dim). Zero-heap.
§Errors
AudioError::InvalidParameteriflevelsis empty, anyL_d == 0, orhi <= lo.AudioError::OutputBufferTooSmallifinputorout_tokensare shorter thandim.