Reducing aliasing of waveshaping using convolution

DSP related issues, mathematics, processing and techniques
stw
Posts: 111
Joined: Tue Jul 13, 2010 11:09 am
Contact:

Reducing aliasing of waveshaping using convolution

Post by stw »

This is a proof of concept of REDUCING ALIASING OF NONLINEAR WAVESHAPING USING CONVOLUTION
I recently stumbled over that conference paper and implemented the method in my upcoming plug.
However i found it surprisingly efficient compared to the cost of CPU (well, at least if done in C++ :mrgreen: )
So i mocked up the given tanh example in fsm to let you guys take a look at it.
Maybe someone wants to dig deeper into this or implement some other waveshaping functions.
The code is absolutely non optimized and much room for improvement is left ;)

The full paper can be found here:
https://www.researchgate.net/publication/308020367

Some interesting related and other projects and papers can be found there as well!

cheers, stw

conv tanh.fsm
Reducing aliasing of nonlinear waveshaping using convolution
(867.53 KiB) Downloaded 1817 times
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: Reducing aliasing of waveshaping using convolution

Post by martinvicanek »

Thanks for sharing this, stw!
Funny I never perceived aliasing in digital distortion as something bad. If anything, it adds some extra dirt and may enhance expression. Anyway, thanks!
BTW it would be interesting to compare this method with oversampling performance wise. If done right with polyphase filters and such, it is not obvious to me which is more efficient.
User avatar
Spogg
Posts: 3368
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England
Contact:

Re: Reducing aliasing of waveshaping using convolution

Post by Spogg »

Not directly related but, thanks to Adam Szabo, I recently discovered Roland’s technique of using a tracking HPF set to the fundamental pitch of an oscillator. This all but eliminates the aliasing frequencies below the fundamental but still keeps the higher enharmonics created and, to my ears, sounds quite nice.

Of course if you don't know the fundmental then you'd have to find it and that takes time, but you could use a look-ahead system I guess.

Cheers

Spogg
stw
Posts: 111
Joined: Tue Jul 13, 2010 11:09 am
Contact:

Re: Reducing aliasing of waveshaping using convolution

Post by stw »

Hi Martin,
well i'd say it's a matter of taste. Maybe if you like to have it less digital and more analogueish style it'll become an issue.
Depending on the input source this "extra dirt" sometimes can be annoying. But you're right, in case of wave shaping it's less important than in other effects.
The cost will always be dependant on the antiderivative you get from the original function. I'd guess most times it'll be less expensive compared to oversampling. At least if you're doing it more than 2x.
Anyway, i think it's an interesting concept.
stw
Posts: 111
Joined: Tue Jul 13, 2010 11:09 am
Contact:

Re: Reducing aliasing of waveshaping using convolution

Post by stw »

Spogg wrote:Not directly related but, thanks to Adam Szabo, I recently discovered Roland’s technique of using a tracking HPF set to the fundamental pitch of an oscillator. This all but eliminates the aliasing frequencies below the fundamental but still keeps the higher enharmonics created and, to my ears, sounds quite nice.

Of course if you don't know the fundmental then you'd have to find it and that takes time, but you could use a look-ahead system I guess.

Cheers

Spogg


Yes, that's a good approach if you're dealing with synths or other environments which provide single fundamental frequencies. But in case of e.g. an general effect plugin which runs on any audio mix that wouldn't work.
Beside that you always get aliasing above the fundamental frequency too.
Iainmf
Posts: 10
Joined: Fri May 01, 2015 7:17 am

Re: Reducing aliasing of waveshaping using convolution

Post by Iainmf »

I've played around with pre-filtering with a low-pass filter before the waveshaping. The idea is that the content in the top octave or so will be masked by the harmonics of the distortion and the ear is not very sensitive in this range anyway. You could think of it resampling to half the sample rate and then using 2x oversampling (which is the original sample rate). You can push it a little bit more with guitar amp applications because guitar amp speakers typically roll off quite low.

Maybe something else to add to the tool box.
francoisreme
Posts: 29
Joined: Wed Feb 15, 2017 4:01 pm

Re: Reducing aliasing of waveshaping using convolution

Post by francoisreme »

hi stw.

I also was really interested about this paper.
Did you manage to implement higher order kernel schemes ?
User avatar
gvalletto
Posts: 117
Joined: Fri Jul 09, 2010 10:15 pm
Location: Argentina
Contact:

Re: Reducing aliasing of waveshaping using convolution

Post by gvalletto »

Spogg wrote:Not directly related but, thanks to Adam Szabo, I recently discovered Roland’s technique of using a tracking HPF set to the fundamental pitch of an oscillator. This all but eliminates the aliasing frequencies below the fundamental but still keeps the higher enharmonics created and, to my ears, sounds quite nice.

Hi Spogg, can you where you found "Roland’s technique of using a tracking HPF..."?
User avatar
Spogg
Posts: 3368
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England
Contact:

Re: Reducing aliasing of waveshaping using convolution

Post by Spogg »

User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: Reducing aliasing of waveshaping using convolution

Post by martinvicanek »

So I had a closer look at this and I see it a bit different now. After some thorough a/b testing I have changed my mind about the aliasing dirt, I like the clean alias suppressed sound better. :)

I have also done some comparisons with oversampling, which showed that this method is clearly superior, not only in terms of CPU but, more importantly, in the amount of suppression at high gain. The reason why the convolution method performs so well lies in a subtlety about the particular kernel shape (one sample wide rectangle). The result is, in the continuous time domain, a lowpass filter function with zeros at even multiples of the Nyquist frequency. Now this is very neat, because in the digital domain, these even multiples are folded back to DC, which means that the chosen lowpass filter will suppress low-frequency aliases (the most annoying ones) particularly well. You won't get this with oversampling.

So I tossed a few waveshaping functions and found that the Sigmoid x/sqrt(1 + x^2) results in ridiculously simple math and implementation. I am also including low-CPU implementations of the popular tanh(x) and a hard clipper although I like the sigmoid better. One recent track of mine, "I still remember", may serve as a showcase.
Attachments
AADistortion.fsm
(58.68 KiB) Downloaded 1631 times
Post Reply