I’m trying to implement a user-selectable oversampling factor in my plugin. Pretty much like this: Switchable dsp::Oversampling Factor. Let’s say 2x/4x/8x. The proposed solution there is to just create a new Oversampler instance and call initProcessing() on it when the factor changes, but I really want something that is usable on-the-fly from withing the audio thread (i.e., does not allocate memory).
My current solution is to create 3 Oversampling instances up-front and then select one based on user input inside the audio loop. Works fine, but it’s kind of wasteful, memory-wise. I’d rather just manually provide the buffers that are large enough for the maximum oversampling factor and have juce::Oversampling work with them. Is this possible? Or, even better, have i overlooked something, and is it possible to have an Oversampling instance that was set to factor 8, do 2 or 4x oversampling, re-using the buffers for the lower oversampling stages ?
I get that this probably produces some pops/clicks when switching since the oversampler state has some internal history but that’s not a problem (and for that matter, so does my current solution).