Efficient antialiasing for distortion of any input

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

Hi,

First post in a very long while.

I recently worked on the topic of anti-aliasing distortion stages.
I believe I got interesting results but due to my non-academic profile and lack of basic knowledge I was not sure if what I compare them to is relevant enough.
So I need some feedback from more educated people.

Say I want to anti-alias a hard clipper, the traditional approach AFAIK is to duplicate my distortion N times and feed each instance with the input delayed by 1/N of a sample, and then average the outputs. At least that is what I was doing when I was doing my Mokafix distortions.
Am I correct thinking this is the most common way to do it ?
I know also about Hermite interpolation but from what I could test a Hermite interpolation using 2 instances of the distortion was only a subtle improvement over simple X2 oversampling. Simple oversampling X4 is always better than Hermite X2 for example. Is that also correct?

Is there a known DSP method to anti alias a hard clipper or other distortion like tanh etc. that does not take more cpu than simple oversampling x2 but sounds like oversampling x16 or more ?

Thanks,
Efflam

Post

Mokafix wrote:Say I want to anti-alias a hard clipper, the traditional approach AFAIK is to duplicate my distortion N times and feed each instance with the input delayed by 1/N of a sample, and then average the outputs. At least that is what I was doing when I was doing my Mokafix distortions.
Averaging n samples together does not make a good LP filter, unfortunately. The best way is still to oversample enough so that the aliasing is small near 20kHz (that's why you do oversampling x16 rather than x2, because no matter how you do your oversampling, this is the limitation). And then use a proper LP filter, not averaging.

Post

Mokafix wrote:Say I want to anti-alias a hard clipper, the traditional approach AFAIK is to duplicate my distortion N times and feed each instance with the input delayed by 1/N of a sample, and then average the outputs.
where did get from, that this is the "traditional" approach? i never heard about that. thinking about it, i would say that this is simply equivalent to applying an N-tap moving average filter after the distortion unit (which i assume to be a memoryless waveshaper, otherwise it might not be equivalent). thus: waveshaping plus moving-average lowpass, all done at the normal input sample-rate. this should not get rid of any aliasing, it's just lowpassing the already aliased distortion output somewhat. certainly not in any way similar to oversampling, unless i'm missing something
My website: rs-met.com, My presences on: YouTube, GitHub, Facebook

Post

oversampling works like this: insert (N-1) zero-valued samples between any two input samples. this gives you a signal with N-times as many samples as before (your oversampling factor is N). then, apply a lowpass filter tuned to your old nyquist frequency, operating at the new samplerate - so, essentialy an 1/N-th band filter, halfband filter for 2x, quarterband filter for 4x, etc. then, apply your distortion at the oversampled rate. then, use your 1/N-th band filter again (another instance of it) for lowpassing the distortion output. finally, take every N-th sample from the output to get back to your original samplerate (take one sample, discard N-1, take another one, discard N-1, etc.)
Last edited by Music Engineer on Wed Sep 02, 2015 9:48 pm, edited 1 time in total.
My website: rs-met.com, My presences on: YouTube, GitHub, Facebook

Post

Agreed, except for the way of doing the oversampling, there are several strategies, I'm for the oversampling on the fly without 0-values which have to be filtered out (should be less computationally intensive).

Post

Miles1981 wrote:Agreed, except for the way of doing the oversampling, there are several strategies, I'm for the oversampling on the fly without 0-values which have to be filtered out (should be less computationally intensive).
can explain that some more? what do you mean by "on-the-fly"?
Last edited by Music Engineer on Wed Sep 02, 2015 9:53 pm, edited 1 time in total.
My website: rs-met.com, My presences on: YouTube, GitHub, Facebook

Post

It's the approach I'm using in https://github.com/mbrucher/AudioTK/blo ... ngFilter.h from http://yehar.com/blog/wp-content/upload ... 8/deip.pdf
Basically, I'm interpolating the signal, so it's more or less padding with a better value (as if I used 0 and then filtered the resulting signal in some way. Not the optimal one, but close enough. And it should also be better in terms of CPU/memory bandwidth/register usage, as the same data is used for neighbor samples. But then, it's a matter of taste, I think ;)

Post

ok, yes, i see. it's basically the same as stuffing zeros and then using a certain kind of (short) FIR filter as lowpass, i think. i'm not sure, if the quality/efficiency trade-off is better for that, since IIR filters give you actually more "bang for the buck". but i didn't really try. i typically use elliptic filters for their superior steepness.
My website: rs-met.com, My presences on: YouTube, GitHub, Facebook

Post

The issue that I would have with using the "Polynomial Interpolators for High-Quality Resampling of Oversampled Audio" is that the author specifically is talking about resampling oversampled audio. To quote,

"Also, it shall only be commented that using polynomial interpolators
with unoversampled input is a choice that can only be made when the quality is not
that important but speed is essential, the most useful interpolators in that case being
linear and 4-point Hermite, and Watte tri-linear, which is somewhere between those
two in both quality and computational complexity."


As far as computational savings over other methods, it's hard to say. 23 multiplies for a total of 47 operations per sample isn't an insignificant amount, although I totally acknowledge that the specs on it are impressive. I suppose in final analysis it depends upon the application.

Food for thought. At least we have options, no?

Post

For a real "hard" clipper, as in the digital sort where we have an infinitely sharp edge, it should be possible to identify the exact position at which the delta of the signal is set to zero or returns to unity and anti-alias only these edges with a FIR filter.

While the signal is outside the range where it is passed linearly it doesn't make sense to apply any processing as we know that the signal will always have a delta equal to zero.

While the signal is within the range it is passed linearly, likewise it does not make sense to apply any processing.

Only at the exact points at which the signal crosses this threshold (infinitely sharp) from linear to "hard clipped" should any processing need to be applied.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

this is interesting! so, at the point where we enter the clipped range, we see a discontinuous change in the signal's derivative (from whatever to zero) - so that means, to anti-alias, we would have to insert a (scaled) bandlimited ramp (BLAMP?)? but we would need to do the same thing, when the signal re-enters the linear range, right? for every crossing of the clipping threshold (upward or downward), we would insert an appropriately scaled BLAMP?
My website: rs-met.com, My presences on: YouTube, GitHub, Facebook

Post

aciddose wrote:For a real "hard" clipper, as in the digital sort where we have an infinitely sharp edge, it should be possible to identify the exact position at which the delta of the signal is set to zero or returns to unity and anti-alias only these edges with a FIR filter.

While the signal is outside the range where it is passed linearly it doesn't make sense to apply any processing as we know that the signal will always have a delta equal to zero.

While the signal is within the range it is passed linearly, likewise it does not make sense to apply any processing.

Only at the exact points at which the signal crosses this threshold (infinitely sharp) from linear to "hard clipped" should any processing need to be applied.
Or use a lookahead method and crossfade from dry to clipped signal.

Post

That's just a really, really poor filter.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

Music Engineer wrote:an appropriately scaled BLAMP?
Well, no.

Since the signal itself is composed of potentially components up to infinite order, at best we can approximate by convolving with the impulse at up to some limited order.

Zero, first and second order (sinc + blep + blamp) may do reasonably well although higher orders will be needed to improve the filter.

The problem breaks down to being something similar to the oversampling ratio, although we can eliminate the need to do so much unnecessary processing anywhere other than those exact points at which it is needed.

It just so happens that due to the infinitely sharp edge of a "hard clip" in the digital sense (no such analog-analog exists) this is the absolute best case.

For any other type of shaping this may not apply the same way.

For example it is possible to construct an arbitrary shaper from piecewise linear sections where inside each section the signal is passed linearly. In these cases we can anti-alias only the instantaneous change at the edge of each section.

Note that any piecewise linear function can be anti-aliased this way. Abs() is a piecewise linear function, therefore limit() is a piecewise linear function.

Image

x/Abs(x) is = 1 for any positive value and = -1 for any negative value of x while = 0 for x = 0.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

Thanks for the replies!1
I will need to read some of them more than once ;)
Music Engineer wrote: ... this should not get rid of any aliasing, it's just lowpassing the already aliased distortion output somewhat. certainly not in any way similar to oversampling, unless i'm missing something
Maybe I did not explain well then because it is definitely getting rid of some aliasing.
But I realize my assumption of what is traditional approach was definitely off.
So in the following example I used a better reference I think.

In those images SR is 44.1k, and a sine wave around 10kHz with amplitude -40/+40 goes through a clipper set to -0.5/+0.5.
edit : added one more exemple from ADSR tutorials.
antialiasing.png
1- has no anti aliasing.
2- uses the downsampling /upsampling macros from http://www.adsrsounds.com/reaktor-tutor ... -part-iii/
3- uses the downsampling /upsampling macros from "too-b overdrive" :
http://www.native-instruments.com/en/co ... show/4541/
4- is custom made.
5- is the same custom made but using two instances, so x2 on top of the custom algorithm so to say.

Not sure how states of the art "too-b overdrive" is in terms of oversampling and how relevant a comparison it makes.
You do not have the required permissions to view the files attached to this post.
Last edited by Mokafix on Thu Sep 03, 2015 8:25 am, edited 1 time in total.

Post Reply

Return to “DSP and Plugin Development”