Closed ndonald2 closed 6 months ago
Nice! This is a great idea, and a nice little optimization. That type of performance improvement definitely adds up.
Thanks for the PR!
We'll review this and do some light testing, but I think it looks good as is. I'll let you know if there's anything to do before we merge it.
Looks great! Thank you for the thorough PR. 🎸
Summary
Adds a
fastmod1f
method to the dsp utils header which is significantly faster thanfmodf(x, 1.0f)
, and use this inOscillator
for nontrivial performance gains.Details
This optimization really adds up when processing multiple oscillators in more complex applications and when using block-based DSP instead of sample-by-sample, but even with DaisySP defaults the savings are obvious.
I neglected to add this optimization to
BlOsc
because:fmodf
invocation has a variable second argument (not just 1.0f)Performance Metrics
Measured using
CpuLoadMeter
and the basic seed oscillator example fromDaisyExamples
at Sample Rate 48kHz and Block Size 4, with the POLYBLEP_TRI waveform.Before:
After: