Login / Register 0 items | $0.00 New @ KVR
Ivan_C
KVRian
 
1056 posts since 11 Aug, 2004, from Marcoussis, France

Postby Ivan_C; Wed Jan 10, 2018 12:55 am Multi-stage oversampling and tuning of associated high order filters

Hello guys !

I have never found relevant enough information about a specific topic related with oversampling, so I'd would to ask you a question.

Let's imagine that we have some oversampling library, allowing to oversample from 2 times up to 32 times using a multi-stage approach. That means that the whole process is divided in multiple sub processes oversampling 2 times only with low pass half-band filters.

Now, I would like to choose the best options for every filter being used there. I can choose between two polyphase approaches, FIR (linear phase so a lot of latency) vs IIR (minimum/nonlinear phase). And whatever the approach, I can choose for every single stage the attenuation and the bandwidth of the half-band filters (both up and down filters).

So my question is the following. What are the best practices in your opinion, or related with your current uses, for the choice of attenuation + bandwidth in oversampling filters ?

My current thoughts :

  • The main goal of multi-stage oversampling is to reduce CPU load thanks to half-band filters properties and associated polyphase implementation. Such an approach allows also to choose different filter constraints for each stage, so intuitively it makes sense to have "strong" filters in the first stage, and weaker filters after.
  • Upsampling filter and downsampling filter don't have the same purpose : upsampling filter is there to remove the zero stuffing artefacts before the actual oversampled process, and downsampling filter purpose is to remove the useless information after Fs/4 to prevent aliasing.

Thanks in advance !
Last edited by Ivan_C on Wed Jan 10, 2018 8:37 am, edited 1 time in total.
matt42
KVRian
 
996 posts since 9 Jan, 2006

Postby matt42; Wed Jan 10, 2018 1:33 am Re: Multi-stage oversampling and tuning of associated high order filters

Ivan_C wrote:Upsampling filter and downsampling filter don't have the same purpose : upsampling filter is there to remove the zero stuffing artefacts before the actual oversampled process, and downsampling filter purpose is to remove the useless information after Fs/4 to prevent aliasing
you also need to consider intermodulation distortion, or extra aliasing resulting from higher partials not removed by the oversampling filter and then balance that against the efficiency of various schemes
Ivan_C
KVRian
 
1056 posts since 11 Aug, 2004, from Marcoussis, France

Postby Ivan_C; Wed Jan 10, 2018 6:43 am Re: Multi-stage oversampling and tuning of associated high order filters

matt42 wrote:you also need to consider intermodulation distortion, or extra aliasing resulting from higher partials not removed by the oversampling filter and then balance that against the efficiency of various schemes

Why any frequency content not removed by an anti-aliasing filter would be labelled "extra aliasing" ? I can understand that some intermodulation distortion happening from a sine say at 28 kHz through a nonlinear audio effect could generate something under 22.05 kHz, but this has nothing to do with oversampling right ?

For me, it's about choosing to care or not in the nonlinear process itself about what happens for frequencies higher than the audio range. Maybe a synth filter might sound more interesting or closer from one given analog synth filter if such intermodulation distortion happens...

Or maybe I don't understand what you meant ?
matt42
KVRian
 
996 posts since 9 Jan, 2006

Postby matt42; Wed Jan 10, 2018 8:26 am Re: Multi-stage oversampling and tuning of associated high order filters

I mean if you zero pad then we get spectral mirroring. If the upsampling filter is weak a lot of the mirroring will be retained. So the remaining mirrored frequencies will cause intermodulation distortion from inharmonic partials, so will introduce inharmonic noise in the audio band. That was my thought process could be wrong.

Perhaps I misunderstood exactly what you meant in the section I quoted
Ivan_C
KVRian
 
1056 posts since 11 Aug, 2004, from Marcoussis, France

Postby Ivan_C; Wed Jan 10, 2018 8:33 am Re: Multi-stage oversampling and tuning of associated high order filters

OK I got it, yes you are totally right the upsampling filter needs to be very good to prevent anything bad happening because of the zero stuffing artefacts ;)

Which makes me think that maybe zero stuffing should be used only in the first stage with a strong upsampling filter, and then anything else such as linear interpolation (or any better FIR polynomial interpolator like Lagrange) might be fine to do the upsampling itself. My main concern about linear interpolation is the fact that it adds a low pass filtering on the signal, but that filtering might be neglectible in the second stage for the audio range frequencies.
matt42
KVRian
 
996 posts since 9 Jan, 2006

Postby matt42; Wed Jan 10, 2018 8:42 am Re: Multi-stage oversampling and tuning of associated high order filters

Once oversampled additional linear interpolation is equivalent to zero padding again and the applying a very cheap low pass. Aside from pass band attenuation perhaps you also wont get enough attenuation to remove the newly introduced mirroring?

Image from Polynomial Interpolators for High-Quality Resampling - Olli Niemitalo
matt42
KVRian
 
996 posts since 9 Jan, 2006

Postby matt42; Wed Jan 10, 2018 9:06 am Re: Multi-stage oversampling and tuning of associated high order filters

Also, unless you need non integer ratios, why use an interpolator? I would design a FIR that met whatever criteria was needed. For example after x2 unpsample we could zero pad and then need a FIR that starts attenuating some point after 22050 and reaches full attenuation (however much we decide is good enough) by 0.75 of nyquist.
Ivan_C
KVRian
 
1056 posts since 11 Aug, 2004, from Marcoussis, France

Postby Ivan_C; Wed Jan 10, 2018 9:12 am Re: Multi-stage oversampling and tuning of associated high order filters

I meant linear interpolation plus high order filtering instead of zero padding + high order filtering sorry ;) Anyway, I don't know if it might be a good thing to use that for stages 2+, I should do some tests. Obviously zero padding + filtering is the proper way to do the upsampling in the first stage.

For example after x2 unpsample we could zero pad and then need a FIR that starts attenuating some point after 22050 and reaches full attenuation (however much we decide is good enough) by 0.75 of nyquist

So my original question was how to decide how much full attenuation is good enough, and why 0.75 instead of something else :D
matt42
KVRian
 
996 posts since 9 Jan, 2006

Postby matt42; Wed Jan 10, 2018 9:17 am Re: Multi-stage oversampling and tuning of associated high order filters

I see, I think. But why linear interpolation? If we zero pad again we only need to process half the samples
matt42
KVRian
 
996 posts since 9 Jan, 2006

Postby matt42; Wed Jan 10, 2018 9:21 am Re: Multi-stage oversampling and tuning of associated high order filters

Ivan_C wrote:So my original question was how to decide how much full attenuation is good enough, and why 0.75 instead of something else :D
yeah how much is enough! Guess it depends what youre doing and personl taste, listening tests? Maybe just push everything beneath the noise floor?

Above 0.75 should work i think, because at the fist stage we erase everything above 0.5. Then when we zero pad again the mirrored frequencies will be between 0.75 and 1? I'm tired and thinking of the top of my head, but seems like it should be right....
Ivan_C
KVRian
 
1056 posts since 11 Aug, 2004, from Marcoussis, France

Postby Ivan_C; Wed Jan 10, 2018 11:21 pm Re: Multi-stage oversampling and tuning of associated high order filters

I see, I think. But why linear interpolation? If we zero pad again we only need to process half the samples

Indeed if we do linear interpolation, we have to process 2 times more samples in the filtering part, so maybe we should just keep the zero stuffing and deal with the resulting artefacts to remove.
sault
KVRist
 
44 posts since 4 Sep, 2014

Postby sault; Thu Jan 11, 2018 2:22 am Re: Multi-stage oversampling and tuning of associated high order filters

Well, if you don't have to design for nonlinearities, e.g. it's just for filter stability and accuracy near Nyquist, then 2x or 4x might be plenty. Minimum design requirements to me would be 30 dB Attentuation and making sure 15 kHz didn't get attenuated too much. Once you hit nonlinearities though you'll start to need more attenuation with a steeper filter...

E.g. I found a 61 tap quarterband filter (for 4x oversampling) I had designed where at 44.1 Khz is flat up to 17 kHz with over 55 dB of attenuation. Not a bad place to be, although I almost certainly would want more attenuation than that if it was aggressive hard clipping. This is one of those times where listening tests and looking at your spectrograms for aliasing would be beneficial.

Note that it takes a 10-12 pole IIR to do that same performance.

Also, it's worth noting that higher-order interpolation is less susceptible to the imaging. The 6 pt 3 order cubic algorithm taking from Olie's pdf (deip.pdf) is a good example of an algorithm that leaves very little spectral debris, and works very well when coupled with a nice, steep upsampler (e.g. that 61 pt mentioned above). Running it this way means lowering your overall latency, and as long as it's oversampled your imaging artifacts will all be filtered out by the decimator.
matt42
KVRian
 
996 posts since 9 Jan, 2006

Postby matt42; Thu Jan 11, 2018 4:53 am Re: Multi-stage oversampling and tuning of associated high order filters

Interpolators have a lot of overhead as you are calculating a polynomial function.

6 point 3rd order is 14 multiplies and 30 adds (edit: I got that wrong 30 is total math operations). That's a lot for a 6 point kernel, and performance is not great: -30 dB, according to the documentation, for an signal already at x2 oversampling

Just to contrast here's a 13 point FIR 13 multiplies 12 adds. 0.07 dB ripple in the pass band and -80 dB attenuation for a signal at x2. Plus only have to process half the data with zero padding, so way more efficient.

Code: Select all
0.006031537449190815
0.011791105655819036
-0.020186580280399553
-0.0630531002680806
0.03492542603817933
0.30077002773634703
0.45757434983660905
0.30077002773634703
0.03492542603817933
-0.0630531002680806
-0.020186580280399553
0.011791105655819036
0.006031537449190815


Took 5 mins to design on http://t-filter.engineerjs.com

Polynomial interpolators come into their own for non integer resampling
sault
KVRist
 
44 posts since 4 Sep, 2014

Postby sault; Thu Jan 11, 2018 11:28 pm Re: Multi-stage oversampling and tuning of associated high order filters

IIR filters - low latency but nonlinear phase, need to cascade (higher orders) for necessary steepness
FIR filters - (potentially) linear phase, can be very steep, but high latency
Interpolators - very low latency, more overhead, but can be fairly efficient at high rates of oversampling


If I need hi-fi quality then sure, I'm going to go with FIR filters. If I'm building a guitar pedal plugin and need as close to real-time as possible with 8x or 16x oversampling, then I'm building an interpolator on top of a min-phase FIR.

That's a lot for a 6 point kernel, and performance is not great: -30 dB, according to the documentation, for an signal already at x2 oversampling


Based on the tests that I've done it appears that the oversampling stacks - SNR is closer to 60 dB if the 2x kernel is run on top of a halfband filter, for instance. Either way, the spectral hash from the interpolation will be located in the part of the spectrum that will be filtered out by the decimator, so that particular issue isn't so much of a concern.
matt42
KVRian
 
996 posts since 9 Jan, 2006

Postby matt42; Fri Jan 12, 2018 12:10 am Re: Multi-stage oversampling and tuning of associated high order filters

sault wrote:Either way, the spectral hash from the interpolation will be located in the part of the spectrum that will be filtered out by the decimator, so that particular issue isn't so much of a concern.

True, but if your process is nonlinear this spectral hash will still cause noise. If you want to improve a linear filter performance near nyquist no need to do anything just zero pad then do the linear filter. Then remove unwanted spectra during decimation. Though probably more optimal to clean up on the up sampling.

Either way why use a suboptimal filter when you can reduce CPU load and improve attenuation with an easy to design tailor made FIR?
Next

Moderator: Moderators (Main)

Return to DSP and Plug-in Development