Table Lookup for tanh() versus other solutions

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

2DaT wrote: Thu May 23, 2024 7:51 pm Then we can't reuse the antiderivative from the last sample and still need to do double the work? I don't see how 0/0 ill-conditioning is resolved in that case.
Yes.. unfortunately that means you do need double work, but 0/0 is resolved because the range is always at least 2*epsilon.

ps. The point is not necessarily that this is the "best" approach, but it works and resolves the 0/0 and does away with requiring the original function.

Post

192kHz != 1.92MHz?!?

That said, 4x oversampling @ 48kHz is not uncommon at all.

Post

Urs wrote: Thu May 23, 2024 9:52 pm 192kHz != 1.92MHz?!?

That said, 4x oversampling @ 48kHz is not uncommon at all.
Also.. I'm going to tell you a highly guarded secret: You don't need to choose between ADAA and 4x oversampling, you can actually do both. ;)

Post

Urs wrote: Thu May 23, 2024 9:52 pm 192kHz != 1.92MHz?!?

...
Maybe he ended up to use 1.92MHz to get the graph lifted few dB for visualization purposes.

Post

mystran wrote: Thu May 23, 2024 10:20 pm
Urs wrote: Thu May 23, 2024 9:52 pm 192kHz != 1.92MHz?!?

That said, 4x oversampling @ 48kHz is not uncommon at all.
Also.. I'm going to tell you a highly guarded secret: You don't need to choose between ADAA and 4x oversampling, you can actually do both. ;)
You kind of have to anyway... ADAA attenuates high frequencies, so you'll want to run things at least at 88.2/96kHz...

Post

juha_p wrote: Fri May 24, 2024 5:31 am
Urs wrote: Thu May 23, 2024 9:52 pm 192kHz != 1.92MHz?!?

...
Maybe he ended up to use 1.92MHz to get the graph lifted few dB for visualization purposes.
Ok, sorry, I found what you're referencing, and I'm fairly sure he just typed a 0 too many for what he wanted. I'll contact him and ask...

Post

Again, pretty sure it’s intentional to show what the spectrum looks like without aliasing.

Post

Sorry, this is a duplicate post. Please ignore. :bang:
Last edited by martinvicanek on Fri May 24, 2024 2:48 pm, edited 1 time in total.

Post

Urs wrote: Fri May 24, 2024 5:36 am ADAA attenuates high frequencies
It does not have to: https://vicanek.de/articles/AADistortion.pdf
But I agree, it is a good idea to do both ADAA and oversampling.

Post

Dogue wrote: Thu May 23, 2024 10:36 am Thanks! Perhaps I should clarify: in particular I’m looking for not only a relatively close approximation on tanh but also one that is relatively fast, and whose antiderivatives are relatively easy to calculate and are also relatively fast.
I stumbled on an interesting topic regarding an old saturation plugin (https://forum.cockos.com/showthread.php?t=256286&page=6) and found the sigmoid trick quite elegant. It inspired me to do this => https://www.desmos.com/calculator/0p8mq8fiq9. From (almost) hard clipper(v=0) to sin-like waveshaper (v=0.815) using only one parameter and simple equations. Not sure if it fits your needs but worth a try maybe?

Post

martinvicanek wrote: Fri May 24, 2024 12:20 pm
Urs wrote: Fri May 24, 2024 5:36 am ADAA attenuates high frequencies
It does not have to: https://vicanek.de/articles/AADistortion.pdf
But I agree, it is a good idea to do both ADAA and oversampling.
Very clear paper – thanks for sharing it!

The x / sqrt(1 + x^2) shaper works pretty well in my initial tests with ADAA, fairly comparable to tanh ADAA but with less attenuation of high frequencies and therefore slightly higher aliased components. Quite elegant, too, in that my version uses just five lines of code! When oversampled, this seems quite good.

I am curious about doing a second-order ADAA with this. F2 looks like:

Code: Select all

0.5x * sqrt(1+x^2) + 0.5ln|x + sqrt(1+x^2)|
Have you done second-order ADAA with this?

Post

This should be of some use.

viewtopic.php?p=8744169#p8744169

It's pretty accurate. I didn't test very thoroughly, but it seems to be at the limit of what's possible to do with single precision calculations, this exact approach at least.

One thing to notice is that it still needs a tanh(x) if the antiderivative is ill-conditioned. That means if we process SIMD, in unlucky cases we need to compute both tanh and tanh antiderivative at the same time, which kinda defeats the purpose, as the method is barely more effective than just doing the 2x oversampling.

Maybe some magical method exists for stitching these ill-conditioned values, because calculation of antiderivatives (even of higher order) is not THAT expensive, it's a straightforward rational function with some limiting. Which is computed using rational minmax (relative weighted) algorithm pretty easily.
Interesting, thanks. Its output seems to be basically indistinguishable from tanh ADAA. Using gen~ in Max, its average CPU is higher than tanh AA, although (in my implementation anyways) tanh has higher CPU spikes. EDIT: after more evaluation, its CPU is indeed lower than tanh AA's.

Post

Dogue wrote: Fri May 24, 2024 5:29 pm I am curious about doing a second-order ADAA with this. F2 looks like:

Code: Select all

0.5x * sqrt(1+x^2) + 0.5ln|x + sqrt(1+x^2)|
Have you done second-order ADAA with this?
Frankly no, I never implemented 2nd order ADAA. The expressions grow quickly with increasing order. In my opinion, it is more efficient to stick to 1st order ADAA and increase oversampling if needed.

Post

martinvicanek wrote: Sun May 26, 2024 8:59 am Frankly no, I never implemented 2nd order ADAA. The expressions grow quickly with increasing order. In my opinion, it is more efficient to stick to 1st order ADAA and increase oversampling if needed.
Thanks for your paper, I started looking into higher order operators to flatten out the response but couldn't work it out quickly and got sidetracked, your approach is great :)

I agree that 1st order with increasing oversampling is the best approach most of the time, as this also de-cramps phase responses, and further flattens out the amplitude response.
The Glue, The Drop - www.cytomic.com

Post

andy-cytomic wrote: Sun May 26, 2024 11:30 am I agree that 1st order with increasing oversampling is the best approach most of the time, as this also de-cramps phase responses, and further flattens out the amplitude response.
I feel like the biggest advantage of ADAA, even the 1st order case is that it helps break the (worst-case, say if we use a step-function as the non-linearity) "double the oversampling to lower aliasing by 6dB/oct" rule. I think the beauty of the technique, more so than the actual aliasing reduction it provides on it's own, is the synergy with oversampling where ADAA places zeroes at the multiples of the sampling rate and oversampling then allows us to take a narrower and narrower slice of the spectrum around the point where aliasing is zero, effectively giving us more out of oversampling than just the asymptotic decay of the spectrum.

Post Reply

Return to “DSP and Plugin Development”