Skip to content
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

Switch to floating point audio and control data #351

Open
olofson opened this issue Oct 9, 2022 · 0 comments
Open

Switch to floating point audio and control data #351

olofson opened this issue Oct 9, 2022 · 0 comments
Labels
enhancement Minor features, and improvements on existing functionality optimization Code optimizations, and performance oriented refactoring refactor Redesign of code without significant changes in functionality

Comments

@olofson
Copy link
Owner

olofson commented Oct 9, 2022

It's about time to go where everyone else have long since gone: Floating point.

(See also #28.)

Implementing any non-trivial DSP code in integer/fixed point is an absolute PITA, even with 64 bit integers, which are probably still less portable than floating point. Thought it used to be a bit of a gray zone, I'm pretty certain that by now, the constant renormalizing and over/underflow avoidance hacks also make integer/fixed point slower than floating point on any non-ancient hardware.

The potential downsides of floating point, that we need to watch for:

  • Denormal processing
    AFAIK, falling outside the dynamic range of the exponent field still results in EXTREMELY expensive special handling in most/all FPUs, and absolutely needs to be avoided. On some platforms, denormals can be disabled (automatically truncated to 0, I presume?), whereas on other platforms, "risky" DSP code needs to actively avoid generating denormals, by adding a microscopic (-300 dB ballpark for 32 bit float) DC offset, noise or similar, cut processing when effectively silent, or similar.
  • Determinism
    We can't rely on things to nicely truncate to 0 (or any particular target value) at exact points in time, and maybe we shouldn't rely on subtle details of the FPU at hand either, even though most seem to implement the same standard these days. There are probably a bunch of cases where we need to be more explicit about states and conditions than the current code.
  • Integer/floating point casting performance hits.
    Arrays and tables still need to be indexed, and we still deal in integer numbers of samples. Conversion can be quite expensive, so it may make sense to run oscillator indices and the like with both integer (index) and floating point (DSP) "iterators" in parallel where applicable. Obviously, it's real handy to already have the working integer/fixed point code needed for this!
    Wrapping is not a thing with floating point, so we might just keep the event timestamps as is...? 256th sample resolution "should" be enough, I think, and the current problem areas (long time deltas for envelopes and the like, and iterative updates of oscillator phase) could probably be handled with floating point code.
@olofson olofson added enhancement Minor features, and improvements on existing functionality refactor Redesign of code without significant changes in functionality optimization Code optimizations, and performance oriented refactoring labels Oct 9, 2022
@olofson olofson added this to the Float All The Points milestone Oct 11, 2022
olofson added a commit that referenced this issue Oct 18, 2022
  * All audio and control data is now floating point
  * Waves are 32 bit floating point internally
  * Script VM registers and operations are now FP
  * Timestamps are still 24:8 fixed point
  * wtosc and fm phase accumulators remain fixed point
  * Public and plugin APIs updated accordingly

Closes #351.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Minor features, and improvements on existing functionality optimization Code optimizations, and performance oriented refactoring refactor Redesign of code without significant changes in functionality
Projects
None yet
Development

No branches or pull requests

1 participant