Expand description
Portable SIMD helper routines for buffer math.
Uses runtime CPU feature detection to dispatch:
- AVX (
f32x8) on x86_64/x86 when available - SSE intrinsics as fallback on x86_64/x86
- Scalar loops on all other architectures
Functions§
- add_
inplace - dst[i] += src[i]
- add_
sanitized_ inplace - dst[i] += sanitize_finite(src[i])
- add_
scaled_ inplace - dst[i] += src[i] * gain
- apply_
fade_ in_ inplace - Apply a sine-based fade-in gain ramp in place:
gain = sin(t * π/2).tfor sampleiis(start_t + i as f32 * dt).clamp(0.0, 1.0). - apply_
fade_ out_ inplace - Apply a cosine-based fade-out gain ramp in place:
gain = cos(t * π/2).tfor sampleiis(start_t + i as f32 * dt).clamp(0.0, 1.0). - clamp_
inplace - Clamp every element to [min, max].
- convert_
f32_ to_ i8 - Convert f32 samples to i8 and scale by
gain. Uses truncation toward zero (matching Rustas i8).dstmust be at least as long assrc. - convert_
f32_ to_ i16 - Convert f32 samples to i16 and scale by
gain. Uses truncation toward zero (matching Rustas i16).dstmust be at least as long assrc. - convert_
f32_ to_ i24 - Convert f32 samples to i32 and scale by
gain, masking to lower 24 bits. Uses truncation toward zero (matching Rustas i32).dstmust be at least as long assrc. - convert_
f32_ to_ i32 - Convert f32 samples to i32 and scale by
gain. Uses truncation toward zero (matching Rustas i32).dstmust be at least as long assrc. - convert_
i8_ to_ f32 - Convert i8 samples to f32 and scale by
gain.dstmust be at least as long assrc. - convert_
i16_ to_ f32 - Convert i16 samples to f32 and scale by
gain.dstmust be at least as long assrc. - convert_
i24_ to_ f32 - Convert i32 samples with lower 24 bits valid to f32 and scale by
gain. Sign-extends the lower 24 bits of each i32 before conversion.dstmust be at least as long assrc. - convert_
i32_ to_ f32 - Convert i32 samples to f32 and scale by
gain.dstmust be at least as long assrc. - copy_
sanitized_ inplace - dst[i] = sanitize_finite(src[i])
- copy_
scaled_ inplace - dst[i] = src[i] * gain
- mul_
inplace - dst[i] *= gain
- peak_
abs - Horizontal max of abs(buf[i]).
- sanitize_
finite_ inplace - Replace NaN / ±Inf with 0.0 in place.