Correct usage of dsp::Oversampling class...?

Hello everyone. I was having a hard time finding a concrete example of the dsp::Oversampling class being put to use. I’ve put together a dummy implementation that seems like it might be doing what it’s supposed to. I was hoping someone might have a quick look and see if anything looks horribly wrong before I begin a large refactoring of my existing source code to implement the oversampling into my pipeline.

Here’s what I have so far:

size_t numChannels = 2ULL;
size_t factor = 2ULL;
juce::dsp::Oversampling<float> oversampler(numChannels, factor, getFilterType(), true);
double sourceSampleRate = 44'100.0;
double sourceLengthInSeconds = 0.600;
int sourceLengthInSamples = static_cast<int>(sourceSampleRate * sourceLengthInSeconds);
AudioBuffer<float> sourceBuffer;
sourceBuffer.setSize(2, sourceLengthInSamples);
juce::dsp::AudioBlock<float> inputBlock(sourceBuffer);
auto blockToProcess = oversampler.processSamplesUp(inputBlock);
for (int blockPosition = 0; blockPosition < blockToProcess.getNumSamples(); blockPosition++)
    for (int chIdx = 0; chIdx < static_cast<int>(numChannels); chIdx++)
        float processedSampleToAdd = 0; // dummy representing the processing result
        blockToProcess.addSample(chIdx, blockPosition, processedSampleToAdd);
AudioBuffer<float> processedBuffer;
processedBuffer.setSize(2, blockToProcess.getNumSamples());
juce::dsp::AudioBlock<float> outputBlock(sourceBuffer);
auto latency = oversampler.getLatencyInSamples();
AudioBuffer<float> hostBuffer;
hostBuffer.setSize(2, 512);
for (int blockPosition = 0; blockPosition < outputBlock.getNumSamples(); blockPosition++)
    auto hostPosition = blockPosition - static_cast<int>(std::round(latency));
    if (hostPosition >= 0 && hostPosition < hostBuffer.getNumSamples())
        for (int chIdx = 0; chIdx < static_cast<int>(numChannels); chIdx++)
            hostBuffer.addSample(chIdx, hostPosition, outputBlock.getSample(chIdx, blockPosition));

Any insights, corrections, etc., would be appreciated.