atan distortion vs. tanh distortion

Masa's icon

Having a poor math background, I understood that tanh-driven distortion theoretically clips audio signal slightly 'harder' than atan-driven distortion. Is my understanding correct?
I came to that understanding by looking at the graph of this pdf.
https://ccrma.stanford.edu/~dtyeh/papers/yeh07_dafx_distortion.pdf

leafcutter's icon
Max Patch
Copy patch and select New From Clipboard in Max.

this is Max, why not test it for yourself?

Masa's icon

Thank you very much for your nice patch. I posted this because I wanted to understand this from a theoretical aspect as well as a practical aspect for my knowledge.
Thanks to your patch, I can confirm that there is slightly more distortion with tanh~ than with atan~, but the difference is very little.

Roman Thilenius's icon

tanh has become the "how you do it" method because it is very CPU friendly.

Masa's icon

I didn't know that it's CPU friendly. Thank a lot!
I'm afraid I'm not sure what you mean with "how you do it" method though.

stkr's icon

er, tanh is *** not *** cpu friendly. no msp trig is cpu friendly. that's why we look for approximations.

Masa's icon

Ah it's not? Could you kindly tell me a bit more about 'approximations'?

Roman Thilenius's icon

i actually referred to tanh versus atan, and he is right indeed: tanh requires 2x time more the processing power.

yet both of them are very cheap compared to traditional "professional" methods such as deconvolution and/or FIR based processes.

what works very well with tanh is to use it in a dynamic model. you can do *pi, tanh, or you can only process values outside of -0.5 and 0.5 with tanh, so that only louder levels are affected. this way you only need 2 additional + and * msp objects to have a dynamic curve which the user can adjust to his liking.

-110

Masa's icon

>yet both of them are very cheap compared to traditional "professional" methods such as deconvolution and/or FIR based processes.
I don't know how to interpret such professional methods in Max, but it's good the tanh method is cheaper for CPU.

>what works very well with tanh is to use it in a dynamic model. you can do *pi, tanh, or you can only process values outside of -0.5 and 0.5 with tanh, so that only louder levels are affected. this way you only need 2 additional + and * msp objects to have a dynamic curve which the user can adjust to his liking.
That additional tip is great. Thank you!