Peter:
I replace tanh~ with un Euler approximation of 2.71828 : tanh(x)=(e^x - e^-x) / (e^x + e^-x) I'm not sure if it's ok, but it works:
#N canvas 224 224 483 354 12; #X obj 75 167 pow~; #X obj 75 98 sig~ 2.71828; #X obj 75 232 -~; #X obj 144 140 *~ -1; #X obj 123 167 pow~; #X obj 108 231 +~; #X obj 75 273 /~; #X obj 99 46 inlet~; #X obj 75 307 outlet~; #X text 114 15 tanh(x)=(e^x - e^-x) / (e^x + e^-x); #X text 201 100 euler; #X connect 0 0 2 0; #X connect 0 0 5 0; #X connect 1 0 0 0; #X connect 1 0 4 0; #X connect 2 0 6 0; #X connect 3 0 4 1; #X connect 4 0 2 1; #X connect 4 0 5 1; #X connect 5 0 6 1; #X connect 6 0 8 0; #X connect 7 0 0 1; #X connect 7 0 3 0;
Claudio.
El jue, 11 dic 2025 a las 17:31, pd-list-request@lists.iem.at escribió:
Send Pd-list mailing list submissions to pd-list@lists.iem.at
To subscribe or unsubscribe via email, send a message with subject or body 'help' to pd-list-request@lists.iem.at
You can reach the person managing the list at pd-list-owner@lists.iem.at
When replying, please edit your Subject line so it is more specific than "Re: Contents of Pd-list digest..."
Today's Topics:
- tanh~ distortion without expr~? (Peter P.)
- Re: tanh~ distortion without expr~? (cyrille henry)
- Re: tanh~ distortion without expr~? (Peter P.)
- Re: tanh~ distortion without expr~? (Simon Iten)
Message: 1 Date: Thu, 11 Dec 2025 12:01:41 +0100 From: "Peter P." peterparker@fastmail.com Subject: [PD] tanh~ distortion without expr~? To: pd-list pd-list@lists.iem.at Message-ID: hebj2lz6dhgl27j5az7tgohuiyfrlqwaily5ajdfbdy3rkkwzp@63oldhy2nqvh Content-Type: text/plain; charset=us-ascii
Hi,
is there a vanilla way to implement tanh~ distortion without using expr~?
Thanks! P
Message: 2 Date: Thu, 11 Dec 2025 12:11:16 +0100 From: cyrille henry ch@chnry.net Subject: [PD] Re: tanh~ distortion without expr~? To: pd-list@lists.iem.at Message-ID: b5a68476-51f8-4699-8e47-7742778702ef@chnry.net Content-Type: text/plain; charset="UTF-8"; format=flowed
hello,
For a distortion, you can use f(x) = x*(27 + x²) / (27 + 9*x²) as a good enough tanh approximation. (x need to be clipped between -3 and 3) https://www.desmos.com/calculator/dxg70xbtne?lang=fr
Cheers C
Le 11/12/2025 à 12:01, Peter P. a écrit :
Hi,
is there a vanilla way to implement tanh~ distortion without using expr~?
Thanks! P
pd-list@lists.iem.at - the Pure Data mailinglist
https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/WDXKOYLK6L...
To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.iem.at/
Message: 3 Date: Thu, 11 Dec 2025 12:35:45 +0100 From: "Peter P." peterparker@fastmail.com Subject: [PD] Re: tanh~ distortion without expr~? To: pd-list@lists.iem.at Message-ID: lkqildo72aqe6hikykbru7ahdtl5soz3foueyr33gh62pqfjxp@gl4zvkgw7d5z Content-Type: text/plain; charset=iso-8859-1
Wow, quick and neat -merci bien Cyrille! P
- cyrille henry ch@chnry.net [2025-12-11 12:11]:
hello,
For a distortion, you can use f(x) = x*(27 + x²) / (27 + 9*x²) as a good
enough tanh approximation. (x need to be clipped between -3 and 3)
https://www.desmos.com/calculator/dxg70xbtne?lang=fr
Cheers C
Le 11/12/2025 à 12:01, Peter P. a écrit :
Hi,
is there a vanilla way to implement tanh~ distortion without using
expr~?
Thanks! P
pd-list@lists.iem.at - the Pure Data mailinglist
https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/WDXKOYLK6L...
To unsubscribe send an email to pd-list-leave@lists.iem.at mailing
list
UNSUBSCRIBE and account-management -> https://lists.iem.at/
pd-list@lists.iem.at - the Pure Data mailinglist
https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/X3SMOHZDQU...
To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.iem.at/
Message: 4 Date: Thu, 11 Dec 2025 17:30:53 +0100 From: Simon Iten itensimon@gmail.com Subject: [PD] Re: tanh~ distortion without expr~? To: pd-list@lists.iem.at Message-ID: AB58DB6B-C33F-4D36-80B2-1975F5EDFC91@gmail.com Content-Type: multipart/mixed; boundary="Apple-Mail=_5EB4542B-EC40-47A5-A970-5F89EAC38A10"
Yep, this works great!! Here is the implementation and another one, that is also quite nice…
(It is a patch to be compiled with heavy, but you get the idea)
Thanks Claudio,
that looks like a good implementation as well!
best, P
Peter:
I replace tanh~ with un Euler approximation of 2.71828 : tanh(x)=(e^x - e^-x) / (e^x + e^-x) I'm not sure if it's ok, but it works:
#N canvas 224 224 483 354 12; #X obj 75 167 pow~; #X obj 75 98 sig~ 2.71828; #X obj 75 232 -~; #X obj 144 140 *~ -1; #X obj 123 167 pow~; #X obj 108 231 +~; #X obj 75 273 /~; #X obj 99 46 inlet~; #X obj 75 307 outlet~; #X text 114 15 tanh(x)=(e^x - e^-x) / (e^x + e^-x); #X text 201 100 euler; #X connect 0 0 2 0; #X connect 0 0 5 0; #X connect 1 0 0 0; #X connect 1 0 4 0; #X connect 2 0 6 0; #X connect 3 0 4 1; #X connect 4 0 2 1; #X connect 4 0 5 1; #X connect 5 0 6 1; #X connect 6 0 8 0; #X connect 7 0 0 1; #X connect 7 0 3 0;
Claudio.
El jue, 11 dic 2025 a las 17:31, pd-list-request@lists.iem.at escribió:
Send Pd-list mailing list submissions to pd-list@lists.iem.at
To subscribe or unsubscribe via email, send a message with subject or body 'help' to pd-list-request@lists.iem.at
You can reach the person managing the list at pd-list-owner@lists.iem.at
When replying, please edit your Subject line so it is more specific than "Re: Contents of Pd-list digest..."
Today's Topics:
- tanh~ distortion without expr~? (Peter P.)
- Re: tanh~ distortion without expr~? (cyrille henry)
- Re: tanh~ distortion without expr~? (Peter P.)
- Re: tanh~ distortion without expr~? (Simon Iten)
Message: 1 Date: Thu, 11 Dec 2025 12:01:41 +0100 From: "Peter P." peterparker@fastmail.com Subject: [PD] tanh~ distortion without expr~? To: pd-list pd-list@lists.iem.at Message-ID: hebj2lz6dhgl27j5az7tgohuiyfrlqwaily5ajdfbdy3rkkwzp@63oldhy2nqvh Content-Type: text/plain; charset=us-ascii
Hi,
is there a vanilla way to implement tanh~ distortion without using expr~?
Thanks! P
Message: 2 Date: Thu, 11 Dec 2025 12:11:16 +0100 From: cyrille henry ch@chnry.net Subject: [PD] Re: tanh~ distortion without expr~? To: pd-list@lists.iem.at Message-ID: b5a68476-51f8-4699-8e47-7742778702ef@chnry.net Content-Type: text/plain; charset="UTF-8"; format=flowed
hello,
For a distortion, you can use f(x) = x*(27 + x²) / (27 + 9*x²) as a good enough tanh approximation. (x need to be clipped between -3 and 3) https://www.desmos.com/calculator/dxg70xbtne?lang=fr
Cheers C
Le 11/12/2025 à 12:01, Peter P. a écrit :
Hi,
is there a vanilla way to implement tanh~ distortion without using expr~?
Thanks! P
pd-list@lists.iem.at - the Pure Data mailinglist
https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/WDXKOYLK6L...
To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.iem.at/
Message: 3 Date: Thu, 11 Dec 2025 12:35:45 +0100 From: "Peter P." peterparker@fastmail.com Subject: [PD] Re: tanh~ distortion without expr~? To: pd-list@lists.iem.at Message-ID: lkqildo72aqe6hikykbru7ahdtl5soz3foueyr33gh62pqfjxp@gl4zvkgw7d5z Content-Type: text/plain; charset=iso-8859-1
Wow, quick and neat -merci bien Cyrille! P
- cyrille henry ch@chnry.net [2025-12-11 12:11]:
hello,
For a distortion, you can use f(x) = x*(27 + x²) / (27 + 9*x²) as a good
enough tanh approximation. (x need to be clipped between -3 and 3)
https://www.desmos.com/calculator/dxg70xbtne?lang=fr
Cheers C
Le 11/12/2025 à 12:01, Peter P. a écrit :
Hi,
is there a vanilla way to implement tanh~ distortion without using
expr~?
Thanks! P
pd-list@lists.iem.at - the Pure Data mailinglist
https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/WDXKOYLK6L...
To unsubscribe send an email to pd-list-leave@lists.iem.at mailing
list
UNSUBSCRIBE and account-management -> https://lists.iem.at/
pd-list@lists.iem.at - the Pure Data mailinglist
https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/X3SMOHZDQU...
To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.iem.at/
Message: 4 Date: Thu, 11 Dec 2025 17:30:53 +0100 From: Simon Iten itensimon@gmail.com Subject: [PD] Re: tanh~ distortion without expr~? To: pd-list@lists.iem.at Message-ID: AB58DB6B-C33F-4D36-80B2-1975F5EDFC91@gmail.com Content-Type: multipart/mixed; boundary="Apple-Mail=_5EB4542B-EC40-47A5-A970-5F89EAC38A10"
Yep, this works great!! Here is the implementation and another one, that is also quite nice…
(It is a patch to be compiled with heavy, but you get the idea)