How to use dsp::Oversampling?

Hi!

I’m just starting with JUCE and I wanted to create a basic overdrive/distortion plugin just for learning.
I got the basic functionality working, but now I’d like to apply the non-linear processing after oversampling the signal in order to attenuate aliasing.

I’m feeling a little confused about AudioBuffer vs AudioBlock and how to manage buffers at the various processing stages.

Are there any good examples and/or sources for information regarding this functionality?

Vasco.

i’m also fairly new to juce so take anything i say with the smallest grain of salt.

as far as im aware, AudioBlock is just a light weight AudioBuffer that doesn’t own any memory from the original Buffer. Faster and easier.

again, as far as im aware, oversampling of x4 is just like using 48000 sample rate x4. so the new sample rate would be 192000. it processes the sample at the new rate then reverts back to 48000 and returns that.

Oversampling

this is what i just tried, and im pretty sure it works because using a factor of 4 (which equates to 16x oversampling) my CPU usage goes up to about 10%.

header file

    using OS = juce::dsp::Oversampling<float>;
    OS oversample{ getTotalNumOutputChannels(), 4, OS::FilterType::filterHalfBandFIREquiripple };

prepareToPlay

    oversample.initProcessing(maximumBlockSize);

process block

    juce::dsp::AudioBlock<float> block(buffer);
    juce::dsp::ProcessContextReplacing<float> context(block);

    // before procesing
    oversample.processSamplesUp(context.getInputBlock());
    
    // processing
    //--------------------------------------------------

    // after processing
    oversample.processSamplesDown(context.getOutputBlock());

of course, i didnt actually do any processing but what i think needs to be done is BEFORE you process anything you tell the oversampler to increase the rate by x then you process at the new rate, then you tell the oversampler to revert back to your original sample rate.

You can take my open source guitar overdrive as an example. Here is a dsp::Waveshaper wrapped into an oversampling instance:

Thank you @SourGummi and @PluginPenguin !
You have been a great help!