Clipping after dsp::Oversampling::processSamplesDown

Hey everyone,

I’m encountering a problem with the dsp::Oversampling class in JUCE. I’m oversampling audio, applying processing and a limiter, and then downsampling back using dsp::Oversampling::processSamplesDown. However, after downsampling, I’m observing unexpected clipping in the audio, despite having no clipping samples after the limiter at the higher sample rate.

This only happens when I have loud oversampled audio. The peaks after the limiter are at -0.5 dB, but after dsp::Oversampling::processSamplesDown the peaks reach 0.8 dB.

I tried different dsp::Oversampling settings: high quality mode (true/false) and both FilterTypes (IIR/FIR), but the result is always the same.

Any insights on why this might be happening and maybe how to avoid/compensate it properly?

I could move the limiter after downsampling but it would require important architectural changes that I’d like to avoid.

Thanks!

Sounds like you are hitting 0dB via inter-samples peaks, but I use dsp::Oversampling too and never met this situation. How are you doing oversampling → processing → downsampling?

I would say that also if it was happening when upsampling (getting past 0 dB on oversampled audio), but here the clipping occurs at the lower sample rate, after downsampling. So I don’t think it’s due to inter-samples peaks.

I’m simply calling processSamplesUp(my_audio_block), then I apply processing on the returned dsp::AudioBlock and I finally call processSamplesDown(my_audio_block).

This is to be expected and not something you’ve done wrong. Intersample peaks.

Imagine an analogue signal, your samples are taken at various places along that signal and are never guaranteed to be taken at the actual peak. When you apply your downsampling filter, the sample points are shifted to slightly different places on the hypothetical analogue signal, so sample peaks can change. It’s annoying but a thing.

Lookahead can help, but really if you want to make sure there are never overs, you need to look into true peak limiting (which imo sounds bad).

2 Likes

Thanks I think I understand now, it’s the downsampling filter that modifies/shifts the signal and that can cause the intersample peaks in the downsampled audio.