[Csnd] Purpose of Tanh Function in Moogladder Source Code

classic Classic list List threaded Threaded
29 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[Csnd] Purpose of Tanh Function in Moogladder Source Code

epalaima
Hi, as part of my research on filter design I have been studying the source code for the moogladder opcode (moogladder_process, fast_tanh, TanH, lines 30-153) and was wondering what purpose passing part of the feedback loop through a tanh function is serving. 

The signal is scaled down by thermal before being passed through the tanh (and scaled back afterwards by tune), which means that on a 0dbfs = 1 scale the tanh optimization given will always return the result return x * sign (the original value). 

I even tested this by implementing the code myself and putting a print statement inside the fast_tanh function, which was never called. 

What then is the purpose of including tanh? Is the opcode meant to function on another amplitude scale, and if so how does it account for users defining different amplitude scales?

Thanks,
Emmett


Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Purpose of Tanh Function in Moogladder Source Code

iron_attorney
I'd guess the accounting for different 0dbfs values probably is the reason for it. Have you tested different amplitudes through your example? Originally csound was based on 16bit int amplitudes

On 6 Sep 2017 6:41 p.m., "Emmett Palaima" <[hidden email]> wrote:
Hi, as part of my research on filter design I have been studying the source code for the moogladder opcode (moogladder_process, fast_tanh, TanH, lines 30-153) and was wondering what purpose passing part of the feedback loop through a tanh function is serving. 

The signal is scaled down by thermal before being passed through the tanh (and scaled back afterwards by tune), which means that on a 0dbfs = 1 scale the tanh optimization given will always return the result return x * sign (the original value). 

I even tested this by implementing the code myself and putting a print statement inside the fast_tanh function, which was never called. 

What then is the purpose of including tanh? Is the opcode meant to function on another amplitude scale, and if so how does it account for users defining different amplitude scales?

Thanks,
Emmett


Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Purpose of Tanh Function in Moogladder Source Code

epalaima
That would make sense if the transfer function was built for a different amplitude scale. The max value of 32,767 time 0.000025 would be 0.819175, which at least makes a little bit of use of the transfer function. 

The coefficient THERMAL is commented as transistor thermal voltage, which suggests that tanh is used to approximate the behavior of an analog transistor. 

On Wed, Sep 6, 2017 at 1:45 PM, Peter Burgess <[hidden email]> wrote:
I'd guess the accounting for different 0dbfs values probably is the reason for it. Have you tested different amplitudes through your example? Originally csound was based on 16bit int amplitudes

On 6 Sep 2017 6:41 p.m., "Emmett Palaima" <[hidden email]> wrote:
Hi, as part of my research on filter design I have been studying the source code for the moogladder opcode (moogladder_process, fast_tanh, TanH, lines 30-153) and was wondering what purpose passing part of the feedback loop through a tanh function is serving. 

The signal is scaled down by thermal before being passed through the tanh (and scaled back afterwards by tune), which means that on a 0dbfs = 1 scale the tanh optimization given will always return the result return x * sign (the original value). 

I even tested this by implementing the code myself and putting a print statement inside the fast_tanh function, which was never called. 

What then is the purpose of including tanh? Is the opcode meant to function on another amplitude scale, and if so how does it account for users defining different amplitude scales?

Thanks,
Emmett


Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Purpose of Tanh Function in Moogladder Source Code

iron_attorney
I haven't looked at the code. What's the 0.000025 from?

Transistor huh? That's interesting, I suppose if you're dealing with positive and negative values higher than 1, a tanh function will produce something similar to transistor ons and offs with a rise and fall time. That's a pretty clever idea!

On 6 Sep 2017 7:12 p.m., "Emmett Palaima" <[hidden email]> wrote:
That would make sense if the transfer function was built for a different amplitude scale. The max value of 32,767 time 0.000025 would be 0.819175, which at least makes a little bit of use of the transfer function. 

The coefficient THERMAL is commented as transistor thermal voltage, which suggests that tanh is used to approximate the behavior of an analog transistor. 

On Wed, Sep 6, 2017 at 1:45 PM, Peter Burgess <[hidden email]> wrote:
I'd guess the accounting for different 0dbfs values probably is the reason for it. Have you tested different amplitudes through your example? Originally csound was based on 16bit int amplitudes

On 6 Sep 2017 6:41 p.m., "Emmett Palaima" <[hidden email]> wrote:
Hi, as part of my research on filter design I have been studying the source code for the moogladder opcode (moogladder_process, fast_tanh, TanH, lines 30-153) and was wondering what purpose passing part of the feedback loop through a tanh function is serving. 

The signal is scaled down by thermal before being passed through the tanh (and scaled back afterwards by tune), which means that on a 0dbfs = 1 scale the tanh optimization given will always return the result return x * sign (the original value). 

I even tested this by implementing the code myself and putting a print statement inside the fast_tanh function, which was never called. 

What then is the purpose of including tanh? Is the opcode meant to function on another amplitude scale, and if so how does it account for users defining different amplitude scales?

Thanks,
Emmett


Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Purpose of Tanh Function in Moogladder Source Code

Victor Lazzarini-2
In reply to this post by epalaima
Tanh() is the non-linear waveshaper used to clip the signal in the filter. If you look in the manual, you will see the reference from where the design comes from. I wrote the original code, but John implemented the optimisations so if the question is related to that, he should be able to answer them.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 19:12, Emmett Palaima <[hidden email]> wrote:

That would make sense if the transfer function was built for a different amplitude scale. The max value of 32,767 time 0.000025 would be 0.819175, which at least makes a little bit of use of the transfer function. 

The coefficient THERMAL is commented as transistor thermal voltage, which suggests that tanh is used to approximate the behavior of an analog transistor. 

On Wed, Sep 6, 2017 at 1:45 PM, Peter Burgess <[hidden email]> wrote:
I'd guess the accounting for different 0dbfs values probably is the reason for it. Have you tested different amplitudes through your example? Originally csound was based on 16bit int amplitudes

On 6 Sep 2017 6:41 p.m., "Emmett Palaima" <[hidden email]> wrote:
Hi, as part of my research on filter design I have been studying the source code for the moogladder opcode (moogladder_process, fast_tanh, TanH, lines 30-153) and was wondering what purpose passing part of the feedback loop through a tanh function is serving. 

The signal is scaled down by thermal before being passed through the tanh (and scaled back afterwards by tune), which means that on a 0dbfs = 1 scale the tanh optimization given will always return the result return x * sign (the original value). 

I even tested this by implementing the code myself and putting a print statement inside the fast_tanh function, which was never called. 

What then is the purpose of including tanh? Is the opcode meant to function on another amplitude scale, and if so how does it account for users defining different amplitude scales?

Thanks,
Emmett


Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Purpose of Tanh Function in Moogladder Source Code

iron_attorney
Ah right, tanh is used as a distortion function then. That makes sense

On 6 Sep 2017 7:49 p.m., "Victor Lazzarini" <[hidden email]> wrote:
Tanh() is the non-linear waveshaper used to clip the signal in the filter. If you look in the manual, you will see the reference from where the design comes from. I wrote the original code, but John implemented the optimisations so if the question is related to that, he should be able to answer them.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 19:12, Emmett Palaima <[hidden email]> wrote:

That would make sense if the transfer function was built for a different amplitude scale. The max value of 32,767 time 0.000025 would be 0.819175, which at least makes a little bit of use of the transfer function. 

The coefficient THERMAL is commented as transistor thermal voltage, which suggests that tanh is used to approximate the behavior of an analog transistor. 

On Wed, Sep 6, 2017 at 1:45 PM, Peter Burgess <[hidden email]> wrote:
I'd guess the accounting for different 0dbfs values probably is the reason for it. Have you tested different amplitudes through your example? Originally csound was based on 16bit int amplitudes

On 6 Sep 2017 6:41 p.m., "Emmett Palaima" <[hidden email]> wrote:
Hi, as part of my research on filter design I have been studying the source code for the moogladder opcode (moogladder_process, fast_tanh, TanH, lines 30-153) and was wondering what purpose passing part of the feedback loop through a tanh function is serving. 

The signal is scaled down by thermal before being passed through the tanh (and scaled back afterwards by tune), which means that on a 0dbfs = 1 scale the tanh optimization given will always return the result return x * sign (the original value). 

I even tested this by implementing the code myself and putting a print statement inside the fast_tanh function, which was never called. 

What then is the purpose of including tanh? Is the opcode meant to function on another amplitude scale, and if so how does it account for users defining different amplitude scales?

Thanks,
Emmett


Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Purpose of Tanh Function in Moogladder Source Code

epalaima
In reply to this post by Victor Lazzarini-2
Since you wrote the code, perhaps you can clarify: what sort of amplitude range is the transfer function designed to work with? 

I was thinking it was supposed to work as a waveshaper / transfer function to simulate the clipping of analog transistors. The reason for my question stemmed from the fact that in a system where 0dbfs = 1 the transfer function does nothing. 

Thanks for your replies.  

On Wed, Sep 6, 2017 at 2:49 PM, Victor Lazzarini <[hidden email]> wrote:
Tanh() is the non-linear waveshaper used to clip the signal in the filter. If you look in the manual, you will see the reference from where the design comes from. I wrote the original code, but John implemented the optimisations so if the question is related to that, he should be able to answer them.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 19:12, Emmett Palaima <[hidden email]> wrote:

That would make sense if the transfer function was built for a different amplitude scale. The max value of 32,767 time 0.000025 would be 0.819175, which at least makes a little bit of use of the transfer function. 

The coefficient THERMAL is commented as transistor thermal voltage, which suggests that tanh is used to approximate the behavior of an analog transistor. 

On Wed, Sep 6, 2017 at 1:45 PM, Peter Burgess <[hidden email]> wrote:
I'd guess the accounting for different 0dbfs values probably is the reason for it. Have you tested different amplitudes through your example? Originally csound was based on 16bit int amplitudes

On 6 Sep 2017 6:41 p.m., "Emmett Palaima" <[hidden email]> wrote:
Hi, as part of my research on filter design I have been studying the source code for the moogladder opcode (moogladder_process, fast_tanh, TanH, lines 30-153) and was wondering what purpose passing part of the feedback loop through a tanh function is serving. 

The signal is scaled down by thermal before being passed through the tanh (and scaled back afterwards by tune), which means that on a 0dbfs = 1 scale the tanh optimization given will always return the result return x * sign (the original value). 

I even tested this by implementing the code myself and putting a print statement inside the fast_tanh function, which was never called. 

What then is the purpose of including tanh? Is the opcode meant to function on another amplitude scale, and if so how does it account for users defining different amplitude scales?

Thanks,
Emmett


Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Purpose of Tanh Function in Moogladder Source Code

Victor Lazzarini-2
The tanh() is supposed to simulate the clipping of the transistors. Can't recall the details, and I don't have the computer here,
but I'd say it works on a normalised range
-1 to 1. The code just follows the recipe in the paper, so you should read that reference.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 21:21, Emmett Palaima <[hidden email]> wrote:

Since you wrote the code, perhaps you can clarify: what sort of amplitude range is the transfer function designed to work with? 

I was thinking it was supposed to work as a waveshaper / transfer function to simulate the clipping of analog transistors. The reason for my question stemmed from the fact that in a system where 0dbfs = 1 the transfer function does nothing. 

Thanks for your replies.  

On Wed, Sep 6, 2017 at 2:49 PM, Victor Lazzarini <[hidden email]> wrote:
Tanh() is the non-linear waveshaper used to clip the signal in the filter. If you look in the manual, you will see the reference from where the design comes from. I wrote the original code, but John implemented the optimisations so if the question is related to that, he should be able to answer them.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 19:12, Emmett Palaima <[hidden email]> wrote:

That would make sense if the transfer function was built for a different amplitude scale. The max value of 32,767 time 0.000025 would be 0.819175, which at least makes a little bit of use of the transfer function. 

The coefficient THERMAL is commented as transistor thermal voltage, which suggests that tanh is used to approximate the behavior of an analog transistor. 

On Wed, Sep 6, 2017 at 1:45 PM, Peter Burgess <[hidden email]> wrote:
I'd guess the accounting for different 0dbfs values probably is the reason for it. Have you tested different amplitudes through your example? Originally csound was based on 16bit int amplitudes

On 6 Sep 2017 6:41 p.m., "Emmett Palaima" <[hidden email]> wrote:
Hi, as part of my research on filter design I have been studying the source code for the moogladder opcode (moogladder_process, fast_tanh, TanH, lines 30-153) and was wondering what purpose passing part of the feedback loop through a tanh function is serving. 

The signal is scaled down by thermal before being passed through the tanh (and scaled back afterwards by tune), which means that on a 0dbfs = 1 scale the tanh optimization given will always return the result return x * sign (the original value). 

I even tested this by implementing the code myself and putting a print statement inside the fast_tanh function, which was never called. 

What then is the purpose of including tanh? Is the opcode meant to function on another amplitude scale, and if so how does it account for users defining different amplitude scales?

Thanks,
Emmett


Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Purpose of Tanh Function in Moogladder Source Code

Victor Lazzarini-2
Non-Linear Digital Implementation of the Moog Ladder Filter


Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 21:37, Victor Lazzarini <[hidden email]> wrote:

The tanh() is supposed to simulate the clipping of the transistors. Can't recall the details, and I don't have the computer here,
but I'd say it works on a normalised range
-1 to 1. The code just follows the recipe in the paper, so you should read that reference.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 21:21, Emmett Palaima <[hidden email]> wrote:

Since you wrote the code, perhaps you can clarify: what sort of amplitude range is the transfer function designed to work with? 

I was thinking it was supposed to work as a waveshaper / transfer function to simulate the clipping of analog transistors. The reason for my question stemmed from the fact that in a system where 0dbfs = 1 the transfer function does nothing. 

Thanks for your replies.  

On Wed, Sep 6, 2017 at 2:49 PM, Victor Lazzarini <[hidden email]> wrote:
Tanh() is the non-linear waveshaper used to clip the signal in the filter. If you look in the manual, you will see the reference from where the design comes from. I wrote the original code, but John implemented the optimisations so if the question is related to that, he should be able to answer them.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 19:12, Emmett Palaima <[hidden email]> wrote:

That would make sense if the transfer function was built for a different amplitude scale. The max value of 32,767 time 0.000025 would be 0.819175, which at least makes a little bit of use of the transfer function. 

The coefficient THERMAL is commented as transistor thermal voltage, which suggests that tanh is used to approximate the behavior of an analog transistor. 

On Wed, Sep 6, 2017 at 1:45 PM, Peter Burgess <[hidden email]> wrote:
I'd guess the accounting for different 0dbfs values probably is the reason for it. Have you tested different amplitudes through your example? Originally csound was based on 16bit int amplitudes

On 6 Sep 2017 6:41 p.m., "Emmett Palaima" <[hidden email]> wrote:
Hi, as part of my research on filter design I have been studying the source code for the moogladder opcode (moogladder_process, fast_tanh, TanH, lines 30-153) and was wondering what purpose passing part of the feedback loop through a tanh function is serving. 

The signal is scaled down by thermal before being passed through the tanh (and scaled back afterwards by tune), which means that on a 0dbfs = 1 scale the tanh optimization given will always return the result return x * sign (the original value). 

I even tested this by implementing the code myself and putting a print statement inside the fast_tanh function, which was never called. 

What then is the purpose of including tanh? Is the opcode meant to function on another amplitude scale, and if so how does it account for users defining different amplitude scales?

Thanks,
Emmett


Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Purpose of Tanh Function in Moogladder Source Code

Victor Lazzarini-2
and here is the first implementation using Csound code. The range of amplitudes for tanh() does not seem to be a consideration. Thinking about it, it never appeared to 
matter; I guess if you are replacing tanh()
with table lookup or other optimised 
code etc then it is probably important to find out.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 21:45, Victor Lazzarini <[hidden email]> wrote:

Non-Linear Digital Implementation of the Moog Ladder Filter


Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 21:37, Victor Lazzarini <[hidden email]> wrote:

The tanh() is supposed to simulate the clipping of the transistors. Can't recall the details, and I don't have the computer here,
but I'd say it works on a normalised range
-1 to 1. The code just follows the recipe in the paper, so you should read that reference.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 21:21, Emmett Palaima <[hidden email]> wrote:

Since you wrote the code, perhaps you can clarify: what sort of amplitude range is the transfer function designed to work with? 

I was thinking it was supposed to work as a waveshaper / transfer function to simulate the clipping of analog transistors. The reason for my question stemmed from the fact that in a system where 0dbfs = 1 the transfer function does nothing. 

Thanks for your replies.  

On Wed, Sep 6, 2017 at 2:49 PM, Victor Lazzarini <[hidden email]> wrote:
Tanh() is the non-linear waveshaper used to clip the signal in the filter. If you look in the manual, you will see the reference from where the design comes from. I wrote the original code, but John implemented the optimisations so if the question is related to that, he should be able to answer them.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 19:12, Emmett Palaima <[hidden email]> wrote:

That would make sense if the transfer function was built for a different amplitude scale. The max value of 32,767 time 0.000025 would be 0.819175, which at least makes a little bit of use of the transfer function. 

The coefficient THERMAL is commented as transistor thermal voltage, which suggests that tanh is used to approximate the behavior of an analog transistor. 

On Wed, Sep 6, 2017 at 1:45 PM, Peter Burgess <[hidden email]> wrote:
I'd guess the accounting for different 0dbfs values probably is the reason for it. Have you tested different amplitudes through your example? Originally csound was based on 16bit int amplitudes

On 6 Sep 2017 6:41 p.m., "Emmett Palaima" <[hidden email]> wrote:
Hi, as part of my research on filter design I have been studying the source code for the moogladder opcode (moogladder_process, fast_tanh, TanH, lines 30-153) and was wondering what purpose passing part of the feedback loop through a tanh function is serving. 

The signal is scaled down by thermal before being passed through the tanh (and scaled back afterwards by tune), which means that on a 0dbfs = 1 scale the tanh optimization given will always return the result return x * sign (the original value). 

I even tested this by implementing the code myself and putting a print statement inside the fast_tanh function, which was never called. 

What then is the purpose of including tanh? Is the opcode meant to function on another amplitude scale, and if so how does it account for users defining different amplitude scales?

Thanks,
Emmett


Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Purpose of Tanh Function in Moogladder Source Code

iron_attorney
Surely the amplitude range does realistically matter unless it's normalised first. If you're using a 16bit int range, you'll almost always be harshly clipping

On 6 Sep 2017 9:57 p.m., "Victor Lazzarini" <[hidden email]> wrote:
and here is the first implementation using Csound code. The range of amplitudes for tanh() does not seem to be a consideration. Thinking about it, it never appeared to 
matter; I guess if you are replacing tanh()
with table lookup or other optimised 
code etc then it is probably important to find out.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 21:45, Victor Lazzarini <[hidden email]> wrote:

Non-Linear Digital Implementation of the Moog Ladder Filter


Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 21:37, Victor Lazzarini <[hidden email]> wrote:

The tanh() is supposed to simulate the clipping of the transistors. Can't recall the details, and I don't have the computer here,
but I'd say it works on a normalised range
-1 to 1. The code just follows the recipe in the paper, so you should read that reference.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 21:21, Emmett Palaima <[hidden email]> wrote:

Since you wrote the code, perhaps you can clarify: what sort of amplitude range is the transfer function designed to work with? 

I was thinking it was supposed to work as a waveshaper / transfer function to simulate the clipping of analog transistors. The reason for my question stemmed from the fact that in a system where 0dbfs = 1 the transfer function does nothing. 

Thanks for your replies.  

On Wed, Sep 6, 2017 at 2:49 PM, Victor Lazzarini <[hidden email]> wrote:
Tanh() is the non-linear waveshaper used to clip the signal in the filter. If you look in the manual, you will see the reference from where the design comes from. I wrote the original code, but John implemented the optimisations so if the question is related to that, he should be able to answer them.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 19:12, Emmett Palaima <[hidden email]> wrote:

That would make sense if the transfer function was built for a different amplitude scale. The max value of 32,767 time 0.000025 would be 0.819175, which at least makes a little bit of use of the transfer function. 

The coefficient THERMAL is commented as transistor thermal voltage, which suggests that tanh is used to approximate the behavior of an analog transistor. 

On Wed, Sep 6, 2017 at 1:45 PM, Peter Burgess <[hidden email]> wrote:
I'd guess the accounting for different 0dbfs values probably is the reason for it. Have you tested different amplitudes through your example? Originally csound was based on 16bit int amplitudes

On 6 Sep 2017 6:41 p.m., "Emmett Palaima" <[hidden email]> wrote:
Hi, as part of my research on filter design I have been studying the source code for the moogladder opcode (moogladder_process, fast_tanh, TanH, lines 30-153) and was wondering what purpose passing part of the feedback loop through a tanh function is serving. 

The signal is scaled down by thermal before being passed through the tanh (and scaled back afterwards by tune), which means that on a 0dbfs = 1 scale the tanh optimization given will always return the result return x * sign (the original value). 

I even tested this by implementing the code myself and putting a print statement inside the fast_tanh function, which was never called. 

What then is the purpose of including tanh? Is the opcode meant to function on another amplitude scale, and if so how does it account for users defining different amplitude scales?

Thanks,
Emmett


Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Purpose of Tanh Function in Moogladder Source Code

Victor Lazzarini-2
You can check the paper, it makes no
mention as to what signal levels are
expected at the input, only that the
filter becomes linear for very small
input values (of course).

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 22:20, Peter Burgess <[hidden email]> wrote:

Surely the amplitude range does realistically matter unless it's normalised first. If you're using a 16bit int range, you'll almost always be harshly clipping

On 6 Sep 2017 9:57 p.m., "Victor Lazzarini" <[hidden email]> wrote:
and here is the first implementation using Csound code. The range of amplitudes for tanh() does not seem to be a consideration. Thinking about it, it never appeared to 
matter; I guess if you are replacing tanh()
with table lookup or other optimised 
code etc then it is probably important to find out.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 21:45, Victor Lazzarini <[hidden email]> wrote:

Non-Linear Digital Implementation of the Moog Ladder Filter


Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 21:37, Victor Lazzarini <[hidden email]> wrote:

The tanh() is supposed to simulate the clipping of the transistors. Can't recall the details, and I don't have the computer here,
but I'd say it works on a normalised range
-1 to 1. The code just follows the recipe in the paper, so you should read that reference.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 21:21, Emmett Palaima <[hidden email]> wrote:

Since you wrote the code, perhaps you can clarify: what sort of amplitude range is the transfer function designed to work with? 

I was thinking it was supposed to work as a waveshaper / transfer function to simulate the clipping of analog transistors. The reason for my question stemmed from the fact that in a system where 0dbfs = 1 the transfer function does nothing. 

Thanks for your replies.  

On Wed, Sep 6, 2017 at 2:49 PM, Victor Lazzarini <[hidden email]> wrote:
Tanh() is the non-linear waveshaper used to clip the signal in the filter. If you look in the manual, you will see the reference from where the design comes from. I wrote the original code, but John implemented the optimisations so if the question is related to that, he should be able to answer them.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 19:12, Emmett Palaima <[hidden email]> wrote:

That would make sense if the transfer function was built for a different amplitude scale. The max value of 32,767 time 0.000025 would be 0.819175, which at least makes a little bit of use of the transfer function. 

The coefficient THERMAL is commented as transistor thermal voltage, which suggests that tanh is used to approximate the behavior of an analog transistor. 

On Wed, Sep 6, 2017 at 1:45 PM, Peter Burgess <[hidden email]> wrote:
I'd guess the accounting for different 0dbfs values probably is the reason for it. Have you tested different amplitudes through your example? Originally csound was based on 16bit int amplitudes

On 6 Sep 2017 6:41 p.m., "Emmett Palaima" <[hidden email]> wrote:
Hi, as part of my research on filter design I have been studying the source code for the moogladder opcode (moogladder_process, fast_tanh, TanH, lines 30-153) and was wondering what purpose passing part of the feedback loop through a tanh function is serving. 

The signal is scaled down by thermal before being passed through the tanh (and scaled back afterwards by tune), which means that on a 0dbfs = 1 scale the tanh optimization given will always return the result return x * sign (the original value). 

I even tested this by implementing the code myself and putting a print statement inside the fast_tanh function, which was never called. 

What then is the purpose of including tanh? Is the opcode meant to function on another amplitude scale, and if so how does it account for users defining different amplitude scales?

Thanks,
Emmett


Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Purpose of Tanh Function in Moogladder Source Code

iron_attorney
Fair enough. I guess the non linear effect is part of the deal anyway

On 6 Sep 2017 10:47 p.m., "Victor Lazzarini" <[hidden email]> wrote:
You can check the paper, it makes no
mention as to what signal levels are
expected at the input, only that the
filter becomes linear for very small
input values (of course).

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 22:20, Peter Burgess <[hidden email]> wrote:

Surely the amplitude range does realistically matter unless it's normalised first. If you're using a 16bit int range, you'll almost always be harshly clipping

On 6 Sep 2017 9:57 p.m., "Victor Lazzarini" <[hidden email]> wrote:
and here is the first implementation using Csound code. The range of amplitudes for tanh() does not seem to be a consideration. Thinking about it, it never appeared to 
matter; I guess if you are replacing tanh()
with table lookup or other optimised 
code etc then it is probably important to find out.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 21:45, Victor Lazzarini <[hidden email]> wrote:

Non-Linear Digital Implementation of the Moog Ladder Filter


Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 21:37, Victor Lazzarini <[hidden email]> wrote:

The tanh() is supposed to simulate the clipping of the transistors. Can't recall the details, and I don't have the computer here,
but I'd say it works on a normalised range
-1 to 1. The code just follows the recipe in the paper, so you should read that reference.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 21:21, Emmett Palaima <[hidden email]> wrote:

Since you wrote the code, perhaps you can clarify: what sort of amplitude range is the transfer function designed to work with? 

I was thinking it was supposed to work as a waveshaper / transfer function to simulate the clipping of analog transistors. The reason for my question stemmed from the fact that in a system where 0dbfs = 1 the transfer function does nothing. 

Thanks for your replies.  

On Wed, Sep 6, 2017 at 2:49 PM, Victor Lazzarini <[hidden email]> wrote:
Tanh() is the non-linear waveshaper used to clip the signal in the filter. If you look in the manual, you will see the reference from where the design comes from. I wrote the original code, but John implemented the optimisations so if the question is related to that, he should be able to answer them.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 19:12, Emmett Palaima <[hidden email]> wrote:

That would make sense if the transfer function was built for a different amplitude scale. The max value of 32,767 time 0.000025 would be 0.819175, which at least makes a little bit of use of the transfer function. 

The coefficient THERMAL is commented as transistor thermal voltage, which suggests that tanh is used to approximate the behavior of an analog transistor. 

On Wed, Sep 6, 2017 at 1:45 PM, Peter Burgess <[hidden email]> wrote:
I'd guess the accounting for different 0dbfs values probably is the reason for it. Have you tested different amplitudes through your example? Originally csound was based on 16bit int amplitudes

On 6 Sep 2017 6:41 p.m., "Emmett Palaima" <[hidden email]> wrote:
Hi, as part of my research on filter design I have been studying the source code for the moogladder opcode (moogladder_process, fast_tanh, TanH, lines 30-153) and was wondering what purpose passing part of the feedback loop through a tanh function is serving. 

The signal is scaled down by thermal before being passed through the tanh (and scaled back afterwards by tune), which means that on a 0dbfs = 1 scale the tanh optimization given will always return the result return x * sign (the original value). 

I even tested this by implementing the code myself and putting a print statement inside the fast_tanh function, which was never called. 

What then is the purpose of including tanh? Is the opcode meant to function on another amplitude scale, and if so how does it account for users defining different amplitude scales?

Thanks,
Emmett


Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Purpose of Tanh Function in Moogladder Source Code

epalaima
To be more precise, I am not asking what the amplitude level the filter expects, but rather, what system for describing amplitude the filter expects. As Peter has suggested this code may have been written to work with a system where 0dbfs = 32,767, since in a system where 0dbfs = 1.0 the transfer function will never do anything (since the maximum value passed into it is 0.000025 in that system, which is well below the threshold at which the tanh optimization is called). 

@Victor: That is what I was trying to ask you to clarify, but I now realize my wording was unclear. 



On Wed, Sep 6, 2017 at 6:22 PM, Peter Burgess <[hidden email]> wrote:
Fair enough. I guess the non linear effect is part of the deal anyway

On 6 Sep 2017 10:47 p.m., "Victor Lazzarini" <[hidden email]> wrote:
You can check the paper, it makes no
mention as to what signal levels are
expected at the input, only that the
filter becomes linear for very small
input values (of course).

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 22:20, Peter Burgess <[hidden email]> wrote:

Surely the amplitude range does realistically matter unless it's normalised first. If you're using a 16bit int range, you'll almost always be harshly clipping

On 6 Sep 2017 9:57 p.m., "Victor Lazzarini" <[hidden email]> wrote:
and here is the first implementation using Csound code. The range of amplitudes for tanh() does not seem to be a consideration. Thinking about it, it never appeared to 
matter; I guess if you are replacing tanh()
with table lookup or other optimised 
code etc then it is probably important to find out.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 21:45, Victor Lazzarini <[hidden email]> wrote:

Non-Linear Digital Implementation of the Moog Ladder Filter


Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 21:37, Victor Lazzarini <[hidden email]> wrote:

The tanh() is supposed to simulate the clipping of the transistors. Can't recall the details, and I don't have the computer here,
but I'd say it works on a normalised range
-1 to 1. The code just follows the recipe in the paper, so you should read that reference.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 21:21, Emmett Palaima <[hidden email]> wrote:

Since you wrote the code, perhaps you can clarify: what sort of amplitude range is the transfer function designed to work with? 

I was thinking it was supposed to work as a waveshaper / transfer function to simulate the clipping of analog transistors. The reason for my question stemmed from the fact that in a system where 0dbfs = 1 the transfer function does nothing. 

Thanks for your replies.  

On Wed, Sep 6, 2017 at 2:49 PM, Victor Lazzarini <[hidden email]> wrote:
Tanh() is the non-linear waveshaper used to clip the signal in the filter. If you look in the manual, you will see the reference from where the design comes from. I wrote the original code, but John implemented the optimisations so if the question is related to that, he should be able to answer them.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 6 Sep 2017, at 19:12, Emmett Palaima <[hidden email]> wrote:

That would make sense if the transfer function was built for a different amplitude scale. The max value of 32,767 time 0.000025 would be 0.819175, which at least makes a little bit of use of the transfer function. 

The coefficient THERMAL is commented as transistor thermal voltage, which suggests that tanh is used to approximate the behavior of an analog transistor. 

On Wed, Sep 6, 2017 at 1:45 PM, Peter Burgess <[hidden email]> wrote:
I'd guess the accounting for different 0dbfs values probably is the reason for it. Have you tested different amplitudes through your example? Originally csound was based on 16bit int amplitudes

On 6 Sep 2017 6:41 p.m., "Emmett Palaima" <[hidden email]> wrote:
Hi, as part of my research on filter design I have been studying the source code for the moogladder opcode (moogladder_process, fast_tanh, TanH, lines 30-153) and was wondering what purpose passing part of the feedback loop through a tanh function is serving. 

The signal is scaled down by thermal before being passed through the tanh (and scaled back afterwards by tune), which means that on a 0dbfs = 1 scale the tanh optimization given will always return the result return x * sign (the original value). 

I even tested this by implementing the code myself and putting a print statement inside the fast_tanh function, which was never called. 

What then is the purpose of including tanh? Is the opcode meant to function on another amplitude scale, and if so how does it account for users defining different amplitude scales?

Thanks,
Emmett


Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Purpose of Tanh Function in Moogladder Source Code

Victor Lazzarini-2
Well, I did not consider the input ranges, just implemented the filter straight out of the paper (with calls to tanh(), no optimisation).
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

> On 8 Sep 2017, at 06:43, Emmett Palaima <[hidden email]> wrote:
>
> To be more precise, I am not asking what the amplitude level the filter expects, but rather, what system for describing amplitude the filter expects. As Peter has suggested this code may have been written to work with a system where 0dbfs = 32,767, since in a system where 0dbfs = 1.0 the transfer function will never do anything (since the maximum value passed into it is 0.000025 in that system, which is well below the threshold at which the tanh optimization is called).
>
> @Victor: That is what I was trying to ask you to clarify, but I now realize my wording was unclear.
>
>
>
> On Wed, Sep 6, 2017 at 6:22 PM, Peter Burgess <[hidden email]> wrote:
> Fair enough. I guess the non linear effect is part of the deal anyway
>
> On 6 Sep 2017 10:47 p.m., "Victor Lazzarini" <[hidden email]> wrote:
> You can check the paper, it makes no
> mention as to what signal levels are
> expected at the input, only that the
> filter becomes linear for very small
> input values (of course).
>
> Victor Lazzarini
> Dean of Arts, Celtic Studies, and Philosophy
> Maynooth University
> Ireland
>
> On 6 Sep 2017, at 22:20, Peter Burgess <[hidden email]> wrote:
>
>> Surely the amplitude range does realistically matter unless it's normalised first. If you're using a 16bit int range, you'll almost always be harshly clipping
>>
>> On 6 Sep 2017 9:57 p.m., "Victor Lazzarini" <[hidden email]> wrote:
>> and here is the first implementation using Csound code. The range of amplitudes for tanh() does not seem to be a consideration. Thinking about it, it never appeared to
>> matter; I guess if you are replacing tanh()
>> with table lookup or other optimised
>> code etc then it is probably important to find out.
>>
>> Victor Lazzarini
>> Dean of Arts, Celtic Studies, and Philosophy
>> Maynooth University
>> Ireland
>>
>> On 6 Sep 2017, at 21:45, Victor Lazzarini <[hidden email]> wrote:
>>
>>> Non-Linear Digital Implementation of the Moog Ladder Filter
>>>
>>> https://pdfs.semanticscholar.org/c490/4c04a7be1d675e360409178da71a1253f6d8.pdf
>>>
>>> Victor Lazzarini
>>> Dean of Arts, Celtic Studies, and Philosophy
>>> Maynooth University
>>> Ireland
>>>
>>> On 6 Sep 2017, at 21:37, Victor Lazzarini <[hidden email]> wrote:
>>>
>>>> The tanh() is supposed to simulate the clipping of the transistors. Can't recall the details, and I don't have the computer here,
>>>> but I'd say it works on a normalised range
>>>> -1 to 1. The code just follows the recipe in the paper, so you should read that reference.
>>>>
>>>> Victor Lazzarini
>>>> Dean of Arts, Celtic Studies, and Philosophy
>>>> Maynooth University
>>>> Ireland
>>>>
>>>> On 6 Sep 2017, at 21:21, Emmett Palaima <[hidden email]> wrote:
>>>>
>>>>> Since you wrote the code, perhaps you can clarify: what sort of amplitude range is the transfer function designed to work with?
>>>>>
>>>>> I was thinking it was supposed to work as a waveshaper / transfer function to simulate the clipping of analog transistors. The reason for my question stemmed from the fact that in a system where 0dbfs = 1 the transfer function does nothing.
>>>>>
>>>>> Thanks for your replies.  
>>>>>
>>>>> On Wed, Sep 6, 2017 at 2:49 PM, Victor Lazzarini <[hidden email]> wrote:
>>>>> Tanh() is the non-linear waveshaper used to clip the signal in the filter. If you look in the manual, you will see the reference from where the design comes from. I wrote the original code, but John implemented the optimisations so if the question is related to that, he should be able to answer them.
>>>>>
>>>>> Victor Lazzarini
>>>>> Dean of Arts, Celtic Studies, and Philosophy
>>>>> Maynooth University
>>>>> Ireland
>>>>>
>>>>> On 6 Sep 2017, at 19:12, Emmett Palaima <[hidden email]> wrote:
>>>>>
>>>>>> That would make sense if the transfer function was built for a different amplitude scale. The max value of 32,767 time 0.000025 would be 0.819175, which at least makes a little bit of use of the transfer function.
>>>>>>
>>>>>> The coefficient THERMAL is commented as transistor thermal voltage, which suggests that tanh is used to approximate the behavior of an analog transistor.
>>>>>>
>>>>>> On Wed, Sep 6, 2017 at 1:45 PM, Peter Burgess <[hidden email]> wrote:
>>>>>> I'd guess the accounting for different 0dbfs values probably is the reason for it. Have you tested different amplitudes through your example? Originally csound was based on 16bit int amplitudes
>>>>>>
>>>>>> On 6 Sep 2017 6:41 p.m., "Emmett Palaima" <[hidden email]> wrote:
>>>>>> Hi, as part of my research on filter design I have been studying the source code for the moogladder opcode (moogladder_process, fast_tanh, TanH, lines 30-153) and was wondering what purpose passing part of the feedback loop through a tanh function is serving.
>>>>>>
>>>>>> The signal is scaled down by thermal before being passed through the tanh (and scaled back afterwards by tune), which means that on a 0dbfs = 1 scale the tanh optimization given will always return the result return x * sign (the original value).
>>>>>>
>>>>>> I even tested this by implementing the code myself and putting a print statement inside the fast_tanh function, which was never called.
>>>>>>
>>>>>> What then is the purpose of including tanh? Is the opcode meant to function on another amplitude scale, and if so how does it account for users defining different amplitude scales?
>>>>>>
>>>>>> Thanks,
>>>>>> Emmett
>>>>>>
>>>>>>
>>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>>>>>>
>>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>>>>>
>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>
> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Purpose of Tanh Function in Moogladder Source Code

iron_attorney
Where in the source is moogladder?

On 8 Sep 2017 9:16 a.m., "Victor Lazzarini" <[hidden email]> wrote:
Well, I did not consider the input ranges, just implemented the filter straight out of the paper (with calls to tanh(), no optimisation).
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

> On 8 Sep 2017, at 06:43, Emmett Palaima <[hidden email]> wrote:
>
> To be more precise, I am not asking what the amplitude level the filter expects, but rather, what system for describing amplitude the filter expects. As Peter has suggested this code may have been written to work with a system where 0dbfs = 32,767, since in a system where 0dbfs = 1.0 the transfer function will never do anything (since the maximum value passed into it is 0.000025 in that system, which is well below the threshold at which the tanh optimization is called).
>
> @Victor: That is what I was trying to ask you to clarify, but I now realize my wording was unclear.
>
>
>
> On Wed, Sep 6, 2017 at 6:22 PM, Peter Burgess <[hidden email]> wrote:
> Fair enough. I guess the non linear effect is part of the deal anyway
>
> On 6 Sep 2017 10:47 p.m., "Victor Lazzarini" <[hidden email]> wrote:
> You can check the paper, it makes no
> mention as to what signal levels are
> expected at the input, only that the
> filter becomes linear for very small
> input values (of course).
>
> Victor Lazzarini
> Dean of Arts, Celtic Studies, and Philosophy
> Maynooth University
> Ireland
>
> On 6 Sep 2017, at 22:20, Peter Burgess <[hidden email]> wrote:
>
>> Surely the amplitude range does realistically matter unless it's normalised first. If you're using a 16bit int range, you'll almost always be harshly clipping
>>
>> On 6 Sep 2017 9:57 p.m., "Victor Lazzarini" <[hidden email]> wrote:
>> and here is the first implementation using Csound code. The range of amplitudes for tanh() does not seem to be a consideration. Thinking about it, it never appeared to
>> matter; I guess if you are replacing tanh()
>> with table lookup or other optimised
>> code etc then it is probably important to find out.
>>
>> Victor Lazzarini
>> Dean of Arts, Celtic Studies, and Philosophy
>> Maynooth University
>> Ireland
>>
>> On 6 Sep 2017, at 21:45, Victor Lazzarini <[hidden email]> wrote:
>>
>>> Non-Linear Digital Implementation of the Moog Ladder Filter
>>>
>>> https://pdfs.semanticscholar.org/c490/4c04a7be1d675e360409178da71a1253f6d8.pdf
>>>
>>> Victor Lazzarini
>>> Dean of Arts, Celtic Studies, and Philosophy
>>> Maynooth University
>>> Ireland
>>>
>>> On 6 Sep 2017, at 21:37, Victor Lazzarini <[hidden email]> wrote:
>>>
>>>> The tanh() is supposed to simulate the clipping of the transistors. Can't recall the details, and I don't have the computer here,
>>>> but I'd say it works on a normalised range
>>>> -1 to 1. The code just follows the recipe in the paper, so you should read that reference.
>>>>
>>>> Victor Lazzarini
>>>> Dean of Arts, Celtic Studies, and Philosophy
>>>> Maynooth University
>>>> Ireland
>>>>
>>>> On 6 Sep 2017, at 21:21, Emmett Palaima <[hidden email]> wrote:
>>>>
>>>>> Since you wrote the code, perhaps you can clarify: what sort of amplitude range is the transfer function designed to work with?
>>>>>
>>>>> I was thinking it was supposed to work as a waveshaper / transfer function to simulate the clipping of analog transistors. The reason for my question stemmed from the fact that in a system where 0dbfs = 1 the transfer function does nothing.
>>>>>
>>>>> Thanks for your replies.
>>>>>
>>>>> On Wed, Sep 6, 2017 at 2:49 PM, Victor Lazzarini <[hidden email]> wrote:
>>>>> Tanh() is the non-linear waveshaper used to clip the signal in the filter. If you look in the manual, you will see the reference from where the design comes from. I wrote the original code, but John implemented the optimisations so if the question is related to that, he should be able to answer them.
>>>>>
>>>>> Victor Lazzarini
>>>>> Dean of Arts, Celtic Studies, and Philosophy
>>>>> Maynooth University
>>>>> Ireland
>>>>>
>>>>> On 6 Sep 2017, at 19:12, Emmett Palaima <[hidden email]> wrote:
>>>>>
>>>>>> That would make sense if the transfer function was built for a different amplitude scale. The max value of 32,767 time 0.000025 would be 0.819175, which at least makes a little bit of use of the transfer function.
>>>>>>
>>>>>> The coefficient THERMAL is commented as transistor thermal voltage, which suggests that tanh is used to approximate the behavior of an analog transistor.
>>>>>>
>>>>>> On Wed, Sep 6, 2017 at 1:45 PM, Peter Burgess <[hidden email]> wrote:
>>>>>> I'd guess the accounting for different 0dbfs values probably is the reason for it. Have you tested different amplitudes through your example? Originally csound was based on 16bit int amplitudes
>>>>>>
>>>>>> On 6 Sep 2017 6:41 p.m., "Emmett Palaima" <[hidden email]> wrote:
>>>>>> Hi, as part of my research on filter design I have been studying the source code for the moogladder opcode (moogladder_process, fast_tanh, TanH, lines 30-153) and was wondering what purpose passing part of the feedback loop through a tanh function is serving.
>>>>>>
>>>>>> The signal is scaled down by thermal before being passed through the tanh (and scaled back afterwards by tune), which means that on a 0dbfs = 1 scale the tanh optimization given will always return the result return x * sign (the original value).
>>>>>>
>>>>>> I even tested this by implementing the code myself and putting a print statement inside the fast_tanh function, which was never called.
>>>>>>
>>>>>> What then is the purpose of including tanh? Is the opcode meant to function on another amplitude scale, and if so how does it account for users defining different amplitude scales?
>>>>>>
>>>>>> Thanks,
>>>>>> Emmett
>>>>>>
>>>>>>
>>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>>>>>>
>>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>>>>>
>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>
> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Purpose of Tanh Function in Moogladder Source Code

Victor Lazzarini-2
Opcodes/newfils.c
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

> On 8 Sep 2017, at 11:12, Peter Burgess <[hidden email]> wrote:
>
> Where in the source is moogladder?
>
> On 8 Sep 2017 9:16 a.m., "Victor Lazzarini" <[hidden email]> wrote:
> Well, I did not consider the input ranges, just implemented the filter straight out of the paper (with calls to tanh(), no optimisation).
> ========================
> Prof. Victor Lazzarini
> Dean of Arts, Celtic Studies, and Philosophy,
> Maynooth University,
> Maynooth, Co Kildare, Ireland
> Tel: 00 353 7086936
> Fax: 00 353 1 7086952
>
> > On 8 Sep 2017, at 06:43, Emmett Palaima <[hidden email]> wrote:
> >
> > To be more precise, I am not asking what the amplitude level the filter expects, but rather, what system for describing amplitude the filter expects. As Peter has suggested this code may have been written to work with a system where 0dbfs = 32,767, since in a system where 0dbfs = 1.0 the transfer function will never do anything (since the maximum value passed into it is 0.000025 in that system, which is well below the threshold at which the tanh optimization is called).
> >
> > @Victor: That is what I was trying to ask you to clarify, but I now realize my wording was unclear.
> >
> >
> >
> > On Wed, Sep 6, 2017 at 6:22 PM, Peter Burgess <[hidden email]> wrote:
> > Fair enough. I guess the non linear effect is part of the deal anyway
> >
> > On 6 Sep 2017 10:47 p.m., "Victor Lazzarini" <[hidden email]> wrote:
> > You can check the paper, it makes no
> > mention as to what signal levels are
> > expected at the input, only that the
> > filter becomes linear for very small
> > input values (of course).
> >
> > Victor Lazzarini
> > Dean of Arts, Celtic Studies, and Philosophy
> > Maynooth University
> > Ireland
> >
> > On 6 Sep 2017, at 22:20, Peter Burgess <[hidden email]> wrote:
> >
> >> Surely the amplitude range does realistically matter unless it's normalised first. If you're using a 16bit int range, you'll almost always be harshly clipping
> >>
> >> On 6 Sep 2017 9:57 p.m., "Victor Lazzarini" <[hidden email]> wrote:
> >> and here is the first implementation using Csound code. The range of amplitudes for tanh() does not seem to be a consideration. Thinking about it, it never appeared to
> >> matter; I guess if you are replacing tanh()
> >> with table lookup or other optimised
> >> code etc then it is probably important to find out.
> >>
> >> Victor Lazzarini
> >> Dean of Arts, Celtic Studies, and Philosophy
> >> Maynooth University
> >> Ireland
> >>
> >> On 6 Sep 2017, at 21:45, Victor Lazzarini <[hidden email]> wrote:
> >>
> >>> Non-Linear Digital Implementation of the Moog Ladder Filter
> >>>
> >>> https://pdfs.semanticscholar.org/c490/4c04a7be1d675e360409178da71a1253f6d8.pdf
> >>>
> >>> Victor Lazzarini
> >>> Dean of Arts, Celtic Studies, and Philosophy
> >>> Maynooth University
> >>> Ireland
> >>>
> >>> On 6 Sep 2017, at 21:37, Victor Lazzarini <[hidden email]> wrote:
> >>>
> >>>> The tanh() is supposed to simulate the clipping of the transistors. Can't recall the details, and I don't have the computer here,
> >>>> but I'd say it works on a normalised range
> >>>> -1 to 1. The code just follows the recipe in the paper, so you should read that reference.
> >>>>
> >>>> Victor Lazzarini
> >>>> Dean of Arts, Celtic Studies, and Philosophy
> >>>> Maynooth University
> >>>> Ireland
> >>>>
> >>>> On 6 Sep 2017, at 21:21, Emmett Palaima <[hidden email]> wrote:
> >>>>
> >>>>> Since you wrote the code, perhaps you can clarify: what sort of amplitude range is the transfer function designed to work with?
> >>>>>
> >>>>> I was thinking it was supposed to work as a waveshaper / transfer function to simulate the clipping of analog transistors. The reason for my question stemmed from the fact that in a system where 0dbfs = 1 the transfer function does nothing.
> >>>>>
> >>>>> Thanks for your replies.
> >>>>>
> >>>>> On Wed, Sep 6, 2017 at 2:49 PM, Victor Lazzarini <[hidden email]> wrote:
> >>>>> Tanh() is the non-linear waveshaper used to clip the signal in the filter. If you look in the manual, you will see the reference from where the design comes from. I wrote the original code, but John implemented the optimisations so if the question is related to that, he should be able to answer them.
> >>>>>
> >>>>> Victor Lazzarini
> >>>>> Dean of Arts, Celtic Studies, and Philosophy
> >>>>> Maynooth University
> >>>>> Ireland
> >>>>>
> >>>>> On 6 Sep 2017, at 19:12, Emmett Palaima <[hidden email]> wrote:
> >>>>>
> >>>>>> That would make sense if the transfer function was built for a different amplitude scale. The max value of 32,767 time 0.000025 would be 0.819175, which at least makes a little bit of use of the transfer function.
> >>>>>>
> >>>>>> The coefficient THERMAL is commented as transistor thermal voltage, which suggests that tanh is used to approximate the behavior of an analog transistor.
> >>>>>>
> >>>>>> On Wed, Sep 6, 2017 at 1:45 PM, Peter Burgess <[hidden email]> wrote:
> >>>>>> I'd guess the accounting for different 0dbfs values probably is the reason for it. Have you tested different amplitudes through your example? Originally csound was based on 16bit int amplitudes
> >>>>>>
> >>>>>> On 6 Sep 2017 6:41 p.m., "Emmett Palaima" <[hidden email]> wrote:
> >>>>>> Hi, as part of my research on filter design I have been studying the source code for the moogladder opcode (moogladder_process, fast_tanh, TanH, lines 30-153) and was wondering what purpose passing part of the feedback loop through a tanh function is serving.
> >>>>>>
> >>>>>> The signal is scaled down by thermal before being passed through the tanh (and scaled back afterwards by tune), which means that on a 0dbfs = 1 scale the tanh optimization given will always return the result return x * sign (the original value).
> >>>>>>
> >>>>>> I even tested this by implementing the code myself and putting a print statement inside the fast_tanh function, which was never called.
> >>>>>>
> >>>>>> What then is the purpose of including tanh? Is the opcode meant to function on another amplitude scale, and if so how does it account for users defining different amplitude scales?
> >>>>>>
> >>>>>> Thanks,
> >>>>>> Emmett
> >>>>>>
> >>>>>>
> >>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>>>>>
> >>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>>>>
> >>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> > Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> > Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >
> > Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>
> Csound mailing list
> [hidden email]
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Purpose of Tanh Function in Moogladder Source Code

epalaima
Tried implementing the code on a 0dbfs = 1 scale without the THERMAL coefficient included in any of the calculations (can do this by setting THERMAL = 1). Definitely makes a difference in the sound, there is some nice harmonic distortion added to the system which was not there previously. Especially noticeable at higher resonance values, causing the resonance to sound much more "analog" (for lack of a better term). 

That brings up an interesting question with Csound opcodes. Does Csound make any adjustments to how things are processed based on the definition of 0dbfs? If not any sort of transfer function / distortion type opcode would work much differently for different 0dbfs values (which might be a good thing, since it adds the possibility for creative use). 

Thanks all for your responses. Has been very interesting to figure this stuff out. 


On Fri, Sep 8, 2017 at 6:34 AM, Victor Lazzarini <[hidden email]> wrote:
Opcodes/newfils.c
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

> On 8 Sep 2017, at 11:12, Peter Burgess <[hidden email]> wrote:
>
> Where in the source is moogladder?
>
> On 8 Sep 2017 9:16 a.m., "Victor Lazzarini" <[hidden email]> wrote:
> Well, I did not consider the input ranges, just implemented the filter straight out of the paper (with calls to tanh(), no optimisation).
> ========================
> Prof. Victor Lazzarini
> Dean of Arts, Celtic Studies, and Philosophy,
> Maynooth University,
> Maynooth, Co Kildare, Ireland
> Tel: 00 353 7086936
> Fax: 00 353 1 7086952
>
> > On 8 Sep 2017, at 06:43, Emmett Palaima <[hidden email]> wrote:
> >
> > To be more precise, I am not asking what the amplitude level the filter expects, but rather, what system for describing amplitude the filter expects. As Peter has suggested this code may have been written to work with a system where 0dbfs = 32,767, since in a system where 0dbfs = 1.0 the transfer function will never do anything (since the maximum value passed into it is 0.000025 in that system, which is well below the threshold at which the tanh optimization is called).
> >
> > @Victor: That is what I was trying to ask you to clarify, but I now realize my wording was unclear.
> >
> >
> >
> > On Wed, Sep 6, 2017 at 6:22 PM, Peter Burgess <[hidden email]> wrote:
> > Fair enough. I guess the non linear effect is part of the deal anyway
> >
> > On 6 Sep 2017 10:47 p.m., "Victor Lazzarini" <[hidden email]> wrote:
> > You can check the paper, it makes no
> > mention as to what signal levels are
> > expected at the input, only that the
> > filter becomes linear for very small
> > input values (of course).
> >
> > Victor Lazzarini
> > Dean of Arts, Celtic Studies, and Philosophy
> > Maynooth University
> > Ireland
> >
> > On 6 Sep 2017, at 22:20, Peter Burgess <[hidden email]> wrote:
> >
> >> Surely the amplitude range does realistically matter unless it's normalised first. If you're using a 16bit int range, you'll almost always be harshly clipping
> >>
> >> On 6 Sep 2017 9:57 p.m., "Victor Lazzarini" <[hidden email]> wrote:
> >> and here is the first implementation using Csound code. The range of amplitudes for tanh() does not seem to be a consideration. Thinking about it, it never appeared to
> >> matter; I guess if you are replacing tanh()
> >> with table lookup or other optimised
> >> code etc then it is probably important to find out.
> >>
> >> Victor Lazzarini
> >> Dean of Arts, Celtic Studies, and Philosophy
> >> Maynooth University
> >> Ireland
> >>
> >> On 6 Sep 2017, at 21:45, Victor Lazzarini <[hidden email]> wrote:
> >>
> >>> Non-Linear Digital Implementation of the Moog Ladder Filter
> >>>
> >>> https://pdfs.semanticscholar.org/c490/4c04a7be1d675e360409178da71a1253f6d8.pdf
> >>>
> >>> Victor Lazzarini
> >>> Dean of Arts, Celtic Studies, and Philosophy
> >>> Maynooth University
> >>> Ireland
> >>>
> >>> On 6 Sep 2017, at 21:37, Victor Lazzarini <[hidden email]> wrote:
> >>>
> >>>> The tanh() is supposed to simulate the clipping of the transistors. Can't recall the details, and I don't have the computer here,
> >>>> but I'd say it works on a normalised range
> >>>> -1 to 1. The code just follows the recipe in the paper, so you should read that reference.
> >>>>
> >>>> Victor Lazzarini
> >>>> Dean of Arts, Celtic Studies, and Philosophy
> >>>> Maynooth University
> >>>> Ireland
> >>>>
> >>>> On 6 Sep 2017, at 21:21, Emmett Palaima <[hidden email]> wrote:
> >>>>
> >>>>> Since you wrote the code, perhaps you can clarify: what sort of amplitude range is the transfer function designed to work with?
> >>>>>
> >>>>> I was thinking it was supposed to work as a waveshaper / transfer function to simulate the clipping of analog transistors. The reason for my question stemmed from the fact that in a system where 0dbfs = 1 the transfer function does nothing.
> >>>>>
> >>>>> Thanks for your replies.
> >>>>>
> >>>>> On Wed, Sep 6, 2017 at 2:49 PM, Victor Lazzarini <[hidden email]> wrote:
> >>>>> Tanh() is the non-linear waveshaper used to clip the signal in the filter. If you look in the manual, you will see the reference from where the design comes from. I wrote the original code, but John implemented the optimisations so if the question is related to that, he should be able to answer them.
> >>>>>
> >>>>> Victor Lazzarini
> >>>>> Dean of Arts, Celtic Studies, and Philosophy
> >>>>> Maynooth University
> >>>>> Ireland
> >>>>>
> >>>>> On 6 Sep 2017, at 19:12, Emmett Palaima <[hidden email]> wrote:
> >>>>>
> >>>>>> That would make sense if the transfer function was built for a different amplitude scale. The max value of 32,767 time 0.000025 would be 0.819175, which at least makes a little bit of use of the transfer function.
> >>>>>>
> >>>>>> The coefficient THERMAL is commented as transistor thermal voltage, which suggests that tanh is used to approximate the behavior of an analog transistor.
> >>>>>>
> >>>>>> On Wed, Sep 6, 2017 at 1:45 PM, Peter Burgess <[hidden email]> wrote:
> >>>>>> I'd guess the accounting for different 0dbfs values probably is the reason for it. Have you tested different amplitudes through your example? Originally csound was based on 16bit int amplitudes
> >>>>>>
> >>>>>> On 6 Sep 2017 6:41 p.m., "Emmett Palaima" <[hidden email]> wrote:
> >>>>>> Hi, as part of my research on filter design I have been studying the source code for the moogladder opcode (moogladder_process, fast_tanh, TanH, lines 30-153) and was wondering what purpose passing part of the feedback loop through a tanh function is serving.
> >>>>>>
> >>>>>> The signal is scaled down by thermal before being passed through the tanh (and scaled back afterwards by tune), which means that on a 0dbfs = 1 scale the tanh optimization given will always return the result return x * sign (the original value).
> >>>>>>
> >>>>>> I even tested this by implementing the code myself and putting a print statement inside the fast_tanh function, which was never called.
> >>>>>>
> >>>>>> What then is the purpose of including tanh? Is the opcode meant to function on another amplitude scale, and if so how does it account for users defining different amplitude scales?
> >>>>>>
> >>>>>> Thanks,
> >>>>>> Emmett
> >>>>>>
> >>>>>>
> >>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>>>>>
> >>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>>>>
> >>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> > Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> > Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >
> > Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>
> Csound mailing list
> [hidden email]
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Purpose of Tanh Function in Moogladder Source Code

Victor Lazzarini-2
Depending on the opcode, it does.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 8 Sep 2017, at 20:37, Emmett Palaima <[hidden email]> wrote:

Tried implementing the code on a 0dbfs = 1 scale without the THERMAL coefficient included in any of the calculations (can do this by setting THERMAL = 1). Definitely makes a difference in the sound, there is some nice harmonic distortion added to the system which was not there previously. Especially noticeable at higher resonance values, causing the resonance to sound much more "analog" (for lack of a better term). 

That brings up an interesting question with Csound opcodes. Does Csound make any adjustments to how things are processed based on the definition of 0dbfs? If not any sort of transfer function / distortion type opcode would work much differently for different 0dbfs values (which might be a good thing, since it adds the possibility for creative use). 

Thanks all for your responses. Has been very interesting to figure this stuff out. 


On Fri, Sep 8, 2017 at 6:34 AM, Victor Lazzarini <[hidden email]> wrote:
Opcodes/newfils.c
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

> On 8 Sep 2017, at 11:12, Peter Burgess <[hidden email]> wrote:
>
> Where in the source is moogladder?
>
> On 8 Sep 2017 9:16 a.m., "Victor Lazzarini" <[hidden email]> wrote:
> Well, I did not consider the input ranges, just implemented the filter straight out of the paper (with calls to tanh(), no optimisation).
> ========================
> Prof. Victor Lazzarini
> Dean of Arts, Celtic Studies, and Philosophy,
> Maynooth University,
> Maynooth, Co Kildare, Ireland
> Tel: 00 353 7086936
> Fax: 00 353 1 7086952
>
> > On 8 Sep 2017, at 06:43, Emmett Palaima <[hidden email]> wrote:
> >
> > To be more precise, I am not asking what the amplitude level the filter expects, but rather, what system for describing amplitude the filter expects. As Peter has suggested this code may have been written to work with a system where 0dbfs = 32,767, since in a system where 0dbfs = 1.0 the transfer function will never do anything (since the maximum value passed into it is 0.000025 in that system, which is well below the threshold at which the tanh optimization is called).
> >
> > @Victor: That is what I was trying to ask you to clarify, but I now realize my wording was unclear.
> >
> >
> >
> > On Wed, Sep 6, 2017 at 6:22 PM, Peter Burgess <[hidden email]> wrote:
> > Fair enough. I guess the non linear effect is part of the deal anyway
> >
> > On 6 Sep 2017 10:47 p.m., "Victor Lazzarini" <[hidden email]> wrote:
> > You can check the paper, it makes no
> > mention as to what signal levels are
> > expected at the input, only that the
> > filter becomes linear for very small
> > input values (of course).
> >
> > Victor Lazzarini
> > Dean of Arts, Celtic Studies, and Philosophy
> > Maynooth University
> > Ireland
> >
> > On 6 Sep 2017, at 22:20, Peter Burgess <[hidden email]> wrote:
> >
> >> Surely the amplitude range does realistically matter unless it's normalised first. If you're using a 16bit int range, you'll almost always be harshly clipping
> >>
> >> On 6 Sep 2017 9:57 p.m., "Victor Lazzarini" <[hidden email]> wrote:
> >> and here is the first implementation using Csound code. The range of amplitudes for tanh() does not seem to be a consideration. Thinking about it, it never appeared to
> >> matter; I guess if you are replacing tanh()
> >> with table lookup or other optimised
> >> code etc then it is probably important to find out.
> >>
> >> Victor Lazzarini
> >> Dean of Arts, Celtic Studies, and Philosophy
> >> Maynooth University
> >> Ireland
> >>
> >> On 6 Sep 2017, at 21:45, Victor Lazzarini <[hidden email]> wrote:
> >>
> >>> Non-Linear Digital Implementation of the Moog Ladder Filter
> >>>
> >>> https://pdfs.semanticscholar.org/c490/4c04a7be1d675e360409178da71a1253f6d8.pdf
> >>>
> >>> Victor Lazzarini
> >>> Dean of Arts, Celtic Studies, and Philosophy
> >>> Maynooth University
> >>> Ireland
> >>>
> >>> On 6 Sep 2017, at 21:37, Victor Lazzarini <[hidden email]> wrote:
> >>>
> >>>> The tanh() is supposed to simulate the clipping of the transistors. Can't recall the details, and I don't have the computer here,
> >>>> but I'd say it works on a normalised range
> >>>> -1 to 1. The code just follows the recipe in the paper, so you should read that reference.
> >>>>
> >>>> Victor Lazzarini
> >>>> Dean of Arts, Celtic Studies, and Philosophy
> >>>> Maynooth University
> >>>> Ireland
> >>>>
> >>>> On 6 Sep 2017, at 21:21, Emmett Palaima <[hidden email]> wrote:
> >>>>
> >>>>> Since you wrote the code, perhaps you can clarify: what sort of amplitude range is the transfer function designed to work with?
> >>>>>
> >>>>> I was thinking it was supposed to work as a waveshaper / transfer function to simulate the clipping of analog transistors. The reason for my question stemmed from the fact that in a system where 0dbfs = 1 the transfer function does nothing.
> >>>>>
> >>>>> Thanks for your replies.
> >>>>>
> >>>>> On Wed, Sep 6, 2017 at 2:49 PM, Victor Lazzarini <[hidden email]> wrote:
> >>>>> Tanh() is the non-linear waveshaper used to clip the signal in the filter. If you look in the manual, you will see the reference from where the design comes from. I wrote the original code, but John implemented the optimisations so if the question is related to that, he should be able to answer them.
> >>>>>
> >>>>> Victor Lazzarini
> >>>>> Dean of Arts, Celtic Studies, and Philosophy
> >>>>> Maynooth University
> >>>>> Ireland
> >>>>>
> >>>>> On 6 Sep 2017, at 19:12, Emmett Palaima <[hidden email]> wrote:
> >>>>>
> >>>>>> That would make sense if the transfer function was built for a different amplitude scale. The max value of 32,767 time 0.000025 would be 0.819175, which at least makes a little bit of use of the transfer function.
> >>>>>>
> >>>>>> The coefficient THERMAL is commented as transistor thermal voltage, which suggests that tanh is used to approximate the behavior of an analog transistor.
> >>>>>>
> >>>>>> On Wed, Sep 6, 2017 at 1:45 PM, Peter Burgess <[hidden email]> wrote:
> >>>>>> I'd guess the accounting for different 0dbfs values probably is the reason for it. Have you tested different amplitudes through your example? Originally csound was based on 16bit int amplitudes
> >>>>>>
> >>>>>> On 6 Sep 2017 6:41 p.m., "Emmett Palaima" <[hidden email]> wrote:
> >>>>>> Hi, as part of my research on filter design I have been studying the source code for the moogladder opcode (moogladder_process, fast_tanh, TanH, lines 30-153) and was wondering what purpose passing part of the feedback loop through a tanh function is serving.
> >>>>>>
> >>>>>> The signal is scaled down by thermal before being passed through the tanh (and scaled back afterwards by tune), which means that on a 0dbfs = 1 scale the tanh optimization given will always return the result return x * sign (the original value).
> >>>>>>
> >>>>>> I even tested this by implementing the code myself and putting a print statement inside the fast_tanh function, which was never called.
> >>>>>>
> >>>>>> What then is the purpose of including tanh? Is the opcode meant to function on another amplitude scale, and if so how does it account for users defining different amplitude scales?
> >>>>>>
> >>>>>> Thanks,
> >>>>>> Emmett
> >>>>>>
> >>>>>>
> >>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>>>>>
> >>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>>>>
> >>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> > Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> > Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >
> > Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>
> Csound mailing list
> [hidden email]
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Purpose of Tanh Function in Moogladder Source Code

Victor Lazzarini-2
In reply to this post by epalaima
It might be possible to set thermal to
depend the 0dbfs value. 

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 8 Sep 2017, at 20:37, Emmett Palaima <[hidden email]> wrote:

Tried implementing the code on a 0dbfs = 1 scale without the THERMAL coefficient included in any of the calculations (can do this by setting THERMAL = 1). Definitely makes a difference in the sound, there is some nice harmonic distortion added to the system which was not there previously. Especially noticeable at higher resonance values, causing the resonance to sound much more "analog" (for lack of a better term). 

That brings up an interesting question with Csound opcodes. Does Csound make any adjustments to how things are processed based on the definition of 0dbfs? If not any sort of transfer function / distortion type opcode would work much differently for different 0dbfs values (which might be a good thing, since it adds the possibility for creative use). 

Thanks all for your responses. Has been very interesting to figure this stuff out. 


On Fri, Sep 8, 2017 at 6:34 AM, Victor Lazzarini <[hidden email]> wrote:
Opcodes/newfils.c
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

> On 8 Sep 2017, at 11:12, Peter Burgess <[hidden email]> wrote:
>
> Where in the source is moogladder?
>
> On 8 Sep 2017 9:16 a.m., "Victor Lazzarini" <[hidden email]> wrote:
> Well, I did not consider the input ranges, just implemented the filter straight out of the paper (with calls to tanh(), no optimisation).
> ========================
> Prof. Victor Lazzarini
> Dean of Arts, Celtic Studies, and Philosophy,
> Maynooth University,
> Maynooth, Co Kildare, Ireland
> Tel: 00 353 7086936
> Fax: 00 353 1 7086952
>
> > On 8 Sep 2017, at 06:43, Emmett Palaima <[hidden email]> wrote:
> >
> > To be more precise, I am not asking what the amplitude level the filter expects, but rather, what system for describing amplitude the filter expects. As Peter has suggested this code may have been written to work with a system where 0dbfs = 32,767, since in a system where 0dbfs = 1.0 the transfer function will never do anything (since the maximum value passed into it is 0.000025 in that system, which is well below the threshold at which the tanh optimization is called).
> >
> > @Victor: That is what I was trying to ask you to clarify, but I now realize my wording was unclear.
> >
> >
> >
> > On Wed, Sep 6, 2017 at 6:22 PM, Peter Burgess <[hidden email]> wrote:
> > Fair enough. I guess the non linear effect is part of the deal anyway
> >
> > On 6 Sep 2017 10:47 p.m., "Victor Lazzarini" <[hidden email]> wrote:
> > You can check the paper, it makes no
> > mention as to what signal levels are
> > expected at the input, only that the
> > filter becomes linear for very small
> > input values (of course).
> >
> > Victor Lazzarini
> > Dean of Arts, Celtic Studies, and Philosophy
> > Maynooth University
> > Ireland
> >
> > On 6 Sep 2017, at 22:20, Peter Burgess <[hidden email]> wrote:
> >
> >> Surely the amplitude range does realistically matter unless it's normalised first. If you're using a 16bit int range, you'll almost always be harshly clipping
> >>
> >> On 6 Sep 2017 9:57 p.m., "Victor Lazzarini" <[hidden email]> wrote:
> >> and here is the first implementation using Csound code. The range of amplitudes for tanh() does not seem to be a consideration. Thinking about it, it never appeared to
> >> matter; I guess if you are replacing tanh()
> >> with table lookup or other optimised
> >> code etc then it is probably important to find out.
> >>
> >> Victor Lazzarini
> >> Dean of Arts, Celtic Studies, and Philosophy
> >> Maynooth University
> >> Ireland
> >>
> >> On 6 Sep 2017, at 21:45, Victor Lazzarini <[hidden email]> wrote:
> >>
> >>> Non-Linear Digital Implementation of the Moog Ladder Filter
> >>>
> >>> https://pdfs.semanticscholar.org/c490/4c04a7be1d675e360409178da71a1253f6d8.pdf
> >>>
> >>> Victor Lazzarini
> >>> Dean of Arts, Celtic Studies, and Philosophy
> >>> Maynooth University
> >>> Ireland
> >>>
> >>> On 6 Sep 2017, at 21:37, Victor Lazzarini <[hidden email]> wrote:
> >>>
> >>>> The tanh() is supposed to simulate the clipping of the transistors. Can't recall the details, and I don't have the computer here,
> >>>> but I'd say it works on a normalised range
> >>>> -1 to 1. The code just follows the recipe in the paper, so you should read that reference.
> >>>>
> >>>> Victor Lazzarini
> >>>> Dean of Arts, Celtic Studies, and Philosophy
> >>>> Maynooth University
> >>>> Ireland
> >>>>
> >>>> On 6 Sep 2017, at 21:21, Emmett Palaima <[hidden email]> wrote:
> >>>>
> >>>>> Since you wrote the code, perhaps you can clarify: what sort of amplitude range is the transfer function designed to work with?
> >>>>>
> >>>>> I was thinking it was supposed to work as a waveshaper / transfer function to simulate the clipping of analog transistors. The reason for my question stemmed from the fact that in a system where 0dbfs = 1 the transfer function does nothing.
> >>>>>
> >>>>> Thanks for your replies.
> >>>>>
> >>>>> On Wed, Sep 6, 2017 at 2:49 PM, Victor Lazzarini <[hidden email]> wrote:
> >>>>> Tanh() is the non-linear waveshaper used to clip the signal in the filter. If you look in the manual, you will see the reference from where the design comes from. I wrote the original code, but John implemented the optimisations so if the question is related to that, he should be able to answer them.
> >>>>>
> >>>>> Victor Lazzarini
> >>>>> Dean of Arts, Celtic Studies, and Philosophy
> >>>>> Maynooth University
> >>>>> Ireland
> >>>>>
> >>>>> On 6 Sep 2017, at 19:12, Emmett Palaima <[hidden email]> wrote:
> >>>>>
> >>>>>> That would make sense if the transfer function was built for a different amplitude scale. The max value of 32,767 time 0.000025 would be 0.819175, which at least makes a little bit of use of the transfer function.
> >>>>>>
> >>>>>> The coefficient THERMAL is commented as transistor thermal voltage, which suggests that tanh is used to approximate the behavior of an analog transistor.
> >>>>>>
> >>>>>> On Wed, Sep 6, 2017 at 1:45 PM, Peter Burgess <[hidden email]> wrote:
> >>>>>> I'd guess the accounting for different 0dbfs values probably is the reason for it. Have you tested different amplitudes through your example? Originally csound was based on 16bit int amplitudes
> >>>>>>
> >>>>>> On 6 Sep 2017 6:41 p.m., "Emmett Palaima" <[hidden email]> wrote:
> >>>>>> Hi, as part of my research on filter design I have been studying the source code for the moogladder opcode (moogladder_process, fast_tanh, TanH, lines 30-153) and was wondering what purpose passing part of the feedback loop through a tanh function is serving.
> >>>>>>
> >>>>>> The signal is scaled down by thermal before being passed through the tanh (and scaled back afterwards by tune), which means that on a 0dbfs = 1 scale the tanh optimization given will always return the result return x * sign (the original value).
> >>>>>>
> >>>>>> I even tested this by implementing the code myself and putting a print statement inside the fast_tanh function, which was never called.
> >>>>>>
> >>>>>> What then is the purpose of including tanh? Is the opcode meant to function on another amplitude scale, and if so how does it account for users defining different amplitude scales?
> >>>>>>
> >>>>>> Thanks,
> >>>>>> Emmett
> >>>>>>
> >>>>>>
> >>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>>>>>
> >>>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>>>>
> >>>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >>> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> > Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> > Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> >
> > Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>
> Csound mailing list
> [hidden email]
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
12