Hi, paying JUCE customer here. I was excited to learn of the new DSP modules – especially because of idea of using templates to string together small modules of code (gain, etc.) without any performance overhead, thanks to C++ templates and inlining.
Looking into Oscillator, however, I was dismayed to see the heavy lifting being done by a std::function
. I was hoping if someone could provide a rationale for why the class wasn’t simply templated on the generator functor itself, thus removing the need for a virtual call in a tight inner loop. Has anyone done any benchmarks as to the cost of extra indirection?
What’s particularly sad about this is the class helpfully offers to compute a lookup table based on the user-provided function, but this is stuffed inside the same costly std::function
. To my mind, it would make much more sense to either a) templatize on the generating functor, or b) accept a std::function
but only for the purposes of calculating a lookup table which itself is not hidden behind an std::function
(just call it directly!).
I hope my tone is not over-the-top here, but it feels like perf is left on the table for no reason here