Skip to main content

Module simd

Module simd 

Source
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 (wide::f32x4) 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). t for sample i is (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). t for sample i is (start_t + i as f32 * dt).clamp(0.0, 1.0).
clamp_inplace
Clamp every element to [min, max].
convert_i8_to_f32
Convert i8 samples to f32 and scale by gain. dst must be at least as long as src.
convert_i16_to_f32
Convert i16 samples to f32 and scale by gain. dst must be at least as long as src.
convert_i32_to_f32
Convert i32 samples to f32 and scale by gain. dst must be at least as long as src.
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.