Commit 07d82e4
committed
fix(standalone): enable flush-to-zero on the JACK RT thread
Denormal (subnormal) float arithmetic is extremely slow, especially on ARM
(Raspberry Pi). As signals decay toward silence, the IR convolver and filter
tails can drive intermediate values into the denormal range, causing erratic
CPU spikes that don't track IR length — some IRs run fine, others struggle, with
no relation to how heavily they're trimmed.
There was no global flush-to-zero anywhere; only a few amp stages manually flush
their state at 1e-20 (itself a normal f32, and not covering the convolver). The
VST3/CLAP plugin already gets FTZ from nih-plug's process wrapper, but the
standalone JACK thread set nothing.
Set the CPU flush-to-zero flag on the JACK process thread (MXCSR bit 15 on x86
SSE, FPCR bit 24 on AArch64), mirroring nih-plug's approach via inline asm since
Rust 1.75 deprecated the _mm_setcsr intrinsics. Idempotent and cheap, so it runs
each process callback. The per-stage manual flushes stay as belt-and-suspenders.
Refs #251.1 parent a8cc930 commit 07d82e4
3 files changed
Lines changed: 56 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
67 | 72 | | |
68 | 73 | | |
69 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
0 commit comments