vsariola / sointu

Fork of 4klang that can target 386, amd64 and WebAssembly. Tools run on Windows, Mac & Linux
MIT License
239 stars 15 forks source link

Empty voices max out CPU in native VST plugin. #137

Closed LeStahL closed 3 weeks ago

LeStahL commented 3 weeks ago

When using the native VST plugin in FL studio, having too many empty voices results in the CPU being maxed out (and consequently, noisy & laggy playback). When using long releases, this can lead to the FL Studio UI freezing.

When exporting the track to assembly, track plays back fine.

(I can work around this using less voices for composing and only increasing voice count for the export, or by frequently using the "panic" button, but might be something with an easy fix, so I figured I'd report it).

I use Sointu as in current master (https://github.com/vsariola/sointu/commit/a14e21dff6215be618a6d25e4baaa094470ecedd)

vsariola commented 3 weeks ago

Can't be sure but this is probably duplicate of #68

vsariola commented 3 weeks ago

TL;DR: Any exponential decay will eventually reach subnormal numbers, and subnormals trigger software computation of floats even in modern processor = slow. x87 does not support flooring subnormals to zero, so we need to find where the exponential decay is and do x += 1; x -= 1 (or any other number) to reduce the tiny decimals so subnormal numbers don't appear

vsariola commented 3 weeks ago

I posted the potential solution to the other issue; can you check if that solution solves this issue also and if so, I'll close this with the other one & mark that this really was a duplicate.

LeStahL commented 3 weeks ago

The latest version in the branch related to the other issue fixes the problem with CPU maxed out for me.