You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: use rounding for float-to-integer conversions
Replace truncating casts with proper rounding in float-to-integer sample
conversions to eliminate bias and preserve small signals.
Changes:
- Use f32::round() and f64::round() instead of truncating `as` casts
- Eliminates bias towards zero from truncation behavior
- Preserves small audio signals that would otherwise be truncated to zero
- Removes nonlinear distortion caused by signal values in (-1.0, 1.0)
all mapping to zero, creating an interval twice as large as any other
Inlines sqrt and round functions for performance.
Additional tests verify proper rounding behavior for cases that would
fail with truncation.
0 commit comments