[Csnd] What Do FL and EXP Mean in Csound Source Code?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Csnd] What Do FL and EXP Mean in Csound Source Code?

epalaima
Hi I am looking at the source code for the follow2 opcode in Csound: https://github.com/csound/csound/blob/2ef3d7cd3f0a910122a61bf45d7fd7b1f22724fa/Opcodes/follow.c, and am finding the following lines used to set the attack parameter somewhat confusing: 

if (p->lastatt!=*p->attack) {
p->lastatt = *p->attack;
if (p->lastatt<=FL(0.0))
ga = p->ga = EXP(- FL(69.0775527898)*csound->onedsr);
// EXP(-FL(10000.0)*csound->onedsr);
else
ga = p->ga = EXP(- FL(6.90775527898)/(CS_ESR* p->lastatt));
//EXP(-FL(1.0)/(CS_ESR* p->lastatt));
}
What do EXP and FL mean in this context? I am thinking EXP(x) is e^x, is this correct? What is FL doing (maybe casting as float?)? 

Lastly, I assume CS_ESR and *csound->onedsr are accessing the sample rate, but what is the purpose of using these two different methods to get it?

Thanks!
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
|  
Report Content as Inappropriate

Re: [Csnd] What Do FL and EXP Mean in Csound Source Code?

nsingh1
I could be wrong but I think you're right - looks like EXP is #defined as exp (which is e^x), and FL is #defined as x##f which essentially concatenates the 'f' token with the number, making it a float rather than implicitly a double (the equivalent of 3.3f for example, rather than 3.3).

On Tue, Mar 14, 2017 at 10:36 PM, Emmett Palaima <[hidden email]> wrote:
Hi I am looking at the source code for the follow2 opcode in Csound: https://github.com/csound/csound/blob/2ef3d7cd3f0a910122a61bf45d7fd7b1f22724fa/Opcodes/follow.c, and am finding the following lines used to set the attack parameter somewhat confusing: 

if (p->lastatt!=*p->attack) {
p->lastatt = *p->attack;
if (p->lastatt<=FL(0.0))
ga = p->ga = EXP(- FL(69.0775527898)*csound->onedsr);
// EXP(-FL(10000.0)*csound->onedsr);
else
ga = p->ga = EXP(- FL(6.90775527898)/(CS_ESR* p->lastatt));
//EXP(-FL(1.0)/(CS_ESR* p->lastatt));
}
What do EXP and FL mean in this context? I am thinking EXP(x) is e^x, is this correct? What is FL doing (maybe casting as float?)? 

Lastly, I assume CS_ESR and *csound->onedsr are accessing the sample rate, but what is the purpose of using these two different methods to get it?

Thanks!
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
|  
Report Content as Inappropriate

Re: [Csnd] What Do FL and EXP Mean in Csound Source Code?

jpff
EXP is a macro that deals with float/double option. FL is similar for constants.

Sent from TypeApp
On 15 Mar 2017, at 05:52, Nikhil Singh <[hidden email]> wrote:
I could be wrong but I think you're right - looks like EXP is #defined as exp (which is e^x), and FL is #defined as x##f which essentially concatenates the 'f' token with the number, making it a float rather than implicitly a double (the equivalent of 3.3f for example, rather than 3.3).

On Tue, Mar 14, 2017 at 10:36 PM, Emmett Palaima <[hidden email]> wrote:
Hi I am looking at the source code for the follow2 opcode in Csound:  https://github.com/csound/csound/blob/2ef3d7cd3f0a910122a61bf45d7fd7b1f22724fa/Opcodes/follow.c, and am finding the following lines used to set the attack parameter somewhat confusing: 

if (p->lastatt!=*p->attack) {
p->lastatt = *p->attack;
if (p->lastatt<=FL(0.0))
ga = p->ga = EXP(- FL(69.0775527898)*csound->onedsr);
// EXP(-FL(10000.0)*csound->onedsr);
else
ga = p->ga = EXP(- FL(6.90775527898)/(CS_ESR* p->lastatt));
//EXP(-FL(1.0)/(CS_ESR* p->lastatt));
}
What do EXP and FL mean in this context? I am thinking EXP(x) is e^x, is this correct? What is FL doing (maybe casting as float?)? 

Lastly, I assume CS_ESR and *csound->onedsr are accessing the sample rate, but what is the purpose of using these two different methods to get it?

Thanks!
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
|  
Report Content as Inappropriate

Re: [Csnd] What Do FL and EXP Mean in Csound Source Code?

jpff
In reply to this post by epalaima
Onedsr =. 1/sr

Sent from TypeApp
On 15 Mar 2017, at 02:37, Emmett Palaima <[hidden email]> wrote:
Hi I am looking at the source code for the follow2 opcode in Csound: https://github.com/csound/csound/blob/2ef3d7cd3f0a910122a61bf45d7fd7b1f22724fa/Opcodes/follow.c, and am finding the following lines used to set the attack parameter somewhat confusing: 

if (p->lastatt!=*p->attack) {
p->lastatt = *p->attack;
if (p->lastatt<=FL(0.0))
ga = p->ga = EXP(- FL(69.0775527898)*csound->onedsr);
// EXP(-FL(10000.0)*csound->onedsr);
else
ga = p->ga = EXP(- FL(6.90775527898)/(CS_ESR* p->lastatt));
//EXP(-FL(1.0)/(CS_ESR* p->lastatt));
}
What do EXP and FL mean in this context? I am thinking EXP(x) is e^x, is this correct? What is FL doing (maybe casting as float?)? 

Lastly, I assume CS_ESR and *csound->onedsr are accessing the sample rate, but what is the purpose of using these two different methods to get it?

Thanks!
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
|  
Report Content as Inappropriate

Re: [Csnd] What Do FL and EXP Mean in Csound Source Code?

Partev Barr Sarkissian
In reply to this post by epalaima


That makes sense. "FL tends to point to Floats in most of what I've seen.
This example is single precision?
 
Isn't e^x :: Euler to the "x" power exponent?
And x^(n) would be the base of "x" to the power exponent "n"-some number?



-PBS

===============================================

--- [hidden email] wrote:

From: John ff <[hidden email]>
To: [hidden email]
Subject: Re: [Csnd] What Do FL and EXP Mean in Csound Source Code?
Date: Wed, 15 Mar 2017 12:05:03 +0000

EXP is a macro that deals with float/double option. FL is similar for constants.

Sent from TypeApp
On 15 Mar 2017, at 05:52, Nikhil Singh <[hidden email]> wrote:
I could be wrong but I think you're right - looks like EXP is #defined as exp (which is e^x), and FL is #defined as x##f which essentially concatenates the 'f' token with the number, making it a float rather than implicitly a double (the equivalent of 3.3f for example, rather than 3.3).

On Tue, Mar 14, 2017 at 10:36 PM, Emmett Palaima <[hidden email]> wrote:
Hi I am looking at the source code for the follow2 opcode in Csound:  https://github.com/csound/csound/blob/2ef3d7cd3f0a910122a61bf45d7fd7b1f22724fa/Opcodes/follow.c, and am finding the following lines used to set the attack parameter somewhat confusing: 

if (p->lastatt!=*p->attack) {
p->lastatt = *p->attack;
if (p->lastatt<=FL(0.0))
ga = p->ga = EXP(- FL(69.0775527898)*csound->onedsr);
// EXP(-FL(10000.0)*csound->onedsr);
else
ga = p->ga = EXP(- FL(6.90775527898)/(CS_ESR* p->lastatt));
//EXP(-FL(1.0)/(CS_ESR* p->lastatt));
}
What do EXP and FL mean in this context? I am thinking EXP(x) is e^x, is this correct? What is FL doing (maybe casting as float?)? 

Lastly, I assume CS_ESR and *csound->onedsr are accessing the sample rate, but what is the purpose of using these two different methods to get it?

Thanks!
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
 

Netscape.  Just the Net You Need.
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
|  
Report Content as Inappropriate

Re: [Csnd] What Do FL and EXP Mean in Csound Source Code?

jpff


On Sat, 18 Mar 2017, Partev Barr Sarkissian wrote:

>
>
> That makes sense. "FL tends to point to Floats in most of what I've seen.
> This example is single precision?
>  
> Isn't e^x :: Euler to the "x" power exponent?
> And x^(n) would be the base of "x" to the power exponent "n"-some number?
>
>

True but not useful.  Te exp function (ad expf) re much  more efficient.

FL(1.0) expands to  1.0 is USE_DOUBLE or 1.0f if not.  Removes a number of
compiler warnings and potential type conversions

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
Loading...