Page 1 of 2

Reducing aliasing of waveshaping using convolution

PostPosted: Thu Jun 22, 2017 10:42 pm
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 1516 times

Re: Reducing aliasing of waveshaping using convolution

PostPosted: Sun Jun 25, 2017 10:06 pm
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.

Re: Reducing aliasing of waveshaping using convolution

PostPosted: Mon Jun 26, 2017 9:10 am
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

Re: Reducing aliasing of waveshaping using convolution

PostPosted: Mon Jun 26, 2017 11:50 am
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.

Re: Reducing aliasing of waveshaping using convolution

PostPosted: Mon Jun 26, 2017 11:58 am
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.

Re: Reducing aliasing of waveshaping using convolution

PostPosted: Mon Jun 26, 2017 12:59 pm
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.

Re: Reducing aliasing of waveshaping using convolution

PostPosted: Fri Dec 22, 2017 2:24 pm
by francoisreme
hi stw.

I also was really interested about this paper.
Did you manage to implement higher order kernel schemes ?

Re: Reducing aliasing of waveshaping using convolution

PostPosted: Wed Mar 14, 2018 10:11 pm
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..."?

Re: Reducing aliasing of waveshaping using convolution

PostPosted: Thu Mar 15, 2018 9:06 am
by Spogg

Re: Reducing aliasing of waveshaping using convolution

PostPosted: Wed May 09, 2018 8:53 pm
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.