-
Notifications
You must be signed in to change notification settings - Fork 286
feat: add optional 64-bit sample precision #821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Replace hardcoded f32 types with Sample/Float type aliases throughout the codebase for consistency. Add compile-time configurability for sample precision via a 64bit feature flag. Tise 64bit mode addresses precision drift in long-running signal generators and accumulated operations, following an approach similar to CamillaDSP's compile-time precision selection.
9ef64b1 to
1089228
Compare
d9cd210 to
282da56
Compare
|
Nothing against spreading the use of the Sample alias further, however changing so many public APIs from
I'm having trouble imagining how to lose 8 bits of precision (24bit mantissa need 16bit for transparent audio). Could you give some examples (we can also reuse those in the docs). I could see how naively mixing 512 songs each at higher then 50% gain could overflow but is that now a fault in the mixer algorithm then? |
I can kind of see how in public documentation it could throw users off for a second, only to see that it's just a type alias to Advanced users can type their
The anchor shouldn't be "is 16-bit transparent?" (it is), but rather "does our processing preserve the input fidelity?" If someone feeds in 24-bit audio, they shouldn't get lower quality back out, particularly when recording, editing, or mixing. Each floating-point operation rounds to Another case is long-running operations that accumulate error over time. For example, Finally, by analogy, CamillaDSP (a reference Rust DSP library) actually defaults to |
Thank you for that proof, its better then anything I could find with a quick google last night. The audio world is so full of bigger number thus better that it can be hard to decern whats makes sense. This is clearly a change worth having. I also would not mind having this example in the code. Both so any future maintainer does not rip it out and such that users can understand when its needed. If you agree could you please add that? I'm also good with merging as is though! |
This started as a code quality journey when I noticed that in some places we still had
Item = f32hardcoded where we should have been using theSampletype alias. While fixing those inconsistencies, I realized we could make sample precision configurable at compile time.I know we've discussed that 32-bit floating point should be sufficient for all audio applications, and I agree that's true for the vast majority of use cases. However, similar to how CamillaDSP does it, rodio can now be built with either
f32(default) orf64samples using the64bitfeature flag. The 64-bit mode helps when precision drift accumulates, like when chaining many audio operations together.