Csound Csound-dev Csound-tekno Search About

[Csnd] Classic vs alternative syntax

Date2019-02-21 16:23
FromMauro Giubileo
Subject[Csnd] Classic vs alternative syntax

Hi, I was thinking about the classic Csound syntax vs the alternative one and I was wondering if something like this:

 aOut someOpcode ...

runs faster than:

 aOut = someOpcode(...)

In other terms, does the Csound parser generate exactly the same syntax tree for both the versions?


Best Regards,

---
Mauro


Date2019-02-21 17:21
Fromjohn
SubjectRe: [Csnd] Classic vs alternative syntax
Simpleexperimemt shows they are not identical.` Instr 2 has a temporary 
variable created.  Similar examplewith kvars are identical.  There is code 
to optimise but it does not always work aparently
   Ialso saw some errors in the compilation referring to multicore.  No 
idea why

I guess it is time to look again.



instr 1
   aout oscil 1000, 440
   out aout
   endin

instr 2
   aout = oscil(1000, 440)
   out aout
   endin



On Thu, 21 Feb 2019, Mauro Giubileo wrote:

> 
> Hi, I was thinking about the classic Csound syntax vs the alternative one and
> I was wondering if something like this:
> 
>  aOut someOpcode ...
> 
> runs faster than:
> 
>  aOut = someOpcode(...)
> 
> In other terms, does the Csound parser generate exactly the same syntax tree
> for both the versions?
> 
> 
> Best Regards,
> 
> ---
> Mauro
> 
> Csound mailing list Csound@listserv.heanet.ie
> 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
Csound@listserv.heanet.ie
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

Date2019-02-21 17:57
FromMauro Giubileo
SubjectRe: [Csnd] Classic vs alternative syntax

Ok, so if I understood right, the version in the first instrument should be faster (at least for now), right?

And I was thinking, in the second instrument, how does Csound know if the oscil opcode has to return an a-type variable or a k-type? It checks the left-value type of the expression?

  aout = oscil:a(1000, 440) ; is ':a' not necessary in this case?


Regards,

---
Mauro

 

Il 2019-02-21 18:21 john ha scritto:

Simpleexperimemt shows they are not identical.` Instr 2 has a temporary variable created.  Similar examplewith kvars are identical.  There is code to optimise but it does not always work aparently
  Ialso saw some errors in the compilation referring to multicore.  No idea why

I guess it is time to look again.


<CsInstruments>
instr 1
  aout oscil 1000, 440
  out aout
  endin

instr 2
  aout = oscil(1000, 440)
  out aout
  endin
</CsInstruments>


On Thu, 21 Feb 2019, Mauro Giubileo wrote:


Hi, I was thinking about the classic Csound syntax vs the alternative one and
I was wondering if something like this:

 aOut someOpcode ...

runs faster than:

 aOut = someOpcode(...)

In other terms, does the Csound parser generate exactly the same syntax tree
for both the versions?


Best Regards,

---
Mauro

Csound mailing list Csound@listserv.heanet.ie
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
Csound@listserv.heanet.ie
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

Date2019-02-21 19:52
FromRory Walsh
SubjectRe: [Csnd] Classic vs alternative syntax
I think it defaults to a-rate if you leave out the return type? 

On Thu, 21 Feb 2019 at 17:57, Mauro Giubileo <mgiubileo@computeraltafed.it> wrote:

Ok, so if I understood right, the version in the first instrument should be faster (at least for now), right?

And I was thinking, in the second instrument, how does Csound know if the oscil opcode has to return an a-type variable or a k-type? It checks the left-value type of the expression?

  aout = oscil:a(1000, 440) ; is ':a' not necessary in this case?


Regards,

---
Mauro

 

Il 2019-02-21 18:21 john ha scritto:

Simpleexperimemt shows they are not identical.` Instr 2 has a temporary variable created.  Similar examplewith kvars are identical.  There is code to optimise but it does not always work aparently
  Ialso saw some errors in the compilation referring to multicore.  No idea why

I guess it is time to look again.


<CsInstruments>
instr 1
  aout oscil 1000, 440
  out aout
  endin

instr 2
  aout = oscil(1000, 440)
  out aout
  endin
</CsInstruments>


On Thu, 21 Feb 2019, Mauro Giubileo wrote:


Hi, I was thinking about the classic Csound syntax vs the alternative one and
I was wondering if something like this:

 aOut someOpcode ...

runs faster than:

 aOut = someOpcode(...)

In other terms, does the Csound parser generate exactly the same syntax tree
for both the versions?


Best Regards,

---
Mauro

Csound mailing list Csound@listserv.heanet.ie
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
Csound@listserv.heanet.ie
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 Csound@listserv.heanet.ie 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 Csound@listserv.heanet.ie 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

Date2019-02-21 20:10
Fromjohn
SubjectRe: [Csnd] Classic vs alternative syntax
I fixed the multicore issue and revised the assigment optimisation.  As 
far as I can tell the classical and functional cases are the same now.

A ever I epect peope to find more nasties in the compilation..... ives me 
something to do!



On Thu, 21 Feb 2019, john wrote:

> Simpleexperimemt shows they are not identical.` Instr 2 has a temporary 
> variable created.  Similar examplewith kvars are identical.  There is code to 
> optimise but it does not always work aparently
>  Ialso saw some errors in the compilation referring to multicore.  No idea 
> why
>
> I guess it is time to look again.
>
>
> 
> instr 1
>  aout oscil 1000, 440
>  out aout
>  endin
>
> instr 2
>  aout = oscil(1000, 440)
>  out aout
>  endin
> 
>
>
> On Thu, 21 Feb 2019, Mauro Giubileo wrote:
>
>> 
>> Hi, I was thinking about the classic Csound syntax vs the alternative one 
>> and
>> I was wondering if something like this:
>> 
>>  aOut someOpcode ...
>> 
>> runs faster than:
>> 
>>  aOut = someOpcode(...)
>> 
>> In other terms, does the Csound parser generate exactly the same syntax 
>> tree
>> for both the versions?
>> 
>> 
>> Best Regards,
>> 
>> ---
>> Mauro
>>

Csound mailing list
Csound@listserv.heanet.ie
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

Date2019-02-21 20:33
FromRory Walsh
SubjectRe: [Csnd] Classic vs alternative syntax
Nice work John ;) 

On Thu, 21 Feb 2019 at 20:10, john <jpff@codemist.co.uk> wrote:
I fixed the multicore issue and revised the assigment optimisation.  As
far as I can tell the classical and functional cases are the same now.

A ever I epect peope to find more nasties in the compilation..... ives me
something to do!



On Thu, 21 Feb 2019, john wrote:

> Simpleexperimemt shows they are not identical.` Instr 2 has a temporary
> variable created.  Similar examplewith kvars are identical.  There is code to
> optimise but it does not always work aparently
>  Ialso saw some errors in the compilation referring to multicore.  No idea
> why
>
> I guess it is time to look again.
>
>
> <CsInstruments>
> instr 1
>  aout oscil 1000, 440
>  out aout
>  endin
>
> instr 2
>  aout = oscil(1000, 440)
>  out aout
>  endin
> </CsInstruments>
>
>
> On Thu, 21 Feb 2019, Mauro Giubileo wrote:
>
>>
>> Hi, I was thinking about the classic Csound syntax vs the alternative one
>> and
>> I was wondering if something like this:
>>
>>  aOut someOpcode ...
>>
>> runs faster than:
>>
>>  aOut = someOpcode(...)
>>
>> In other terms, does the Csound parser generate exactly the same syntax
>> tree
>> for both the versions?
>>
>>
>> Best Regards,
>>
>> ---
>> Mauro
>>

Csound mailing list
Csound@listserv.heanet.ie
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 Csound@listserv.heanet.ie 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

Date2019-02-21 21:20
FromMauro Giubileo
SubjectRe: [Csnd] Classic vs alternative syntax

So, we can assume that for all the opcodes that can return a/k/i-type variables, the a-type is always the default one when you don't specify it and use the function syntax?

---
Mauro


Il 2019-02-21 20:52 Rory Walsh ha scritto:

I think it defaults to a-rate if you leave out the return type? 

On Thu, 21 Feb 2019 at 17:57, Mauro Giubileo <mgiubileo@computeraltafed.it> wrote:

Ok, so if I understood right, the version in the first instrument should be faster (at least for now), right?

And I was thinking, in the second instrument, how does Csound know if the oscil opcode has to return an a-type variable or a k-type? It checks the left-value type of the expression?

  aout = oscil:a(1000, 440) ; is ':a' not necessary in this case?


Regards,

---
Mauro

 

Il 2019-02-21 18:21 john ha scritto:

Simpleexperimemt shows they are not identical.` Instr 2 has a temporary variable created.  Similar examplewith kvars are identical.  There is code to optimise but it does not always work aparently
  Ialso saw some errors in the compilation referring to multicore.  No idea why

I guess it is time to look again.


<CsInstruments>
instr 1
  aout oscil 1000, 440
  out aout
  endin

instr 2
  aout = oscil(1000, 440)
  out aout
  endin
</CsInstruments>


On Thu, 21 Feb 2019, Mauro Giubileo wrote:


Hi, I was thinking about the classic Csound syntax vs the alternative one and
I was wondering if something like this:

 aOut someOpcode ...

runs faster than:

 aOut = someOpcode(...)

In other terms, does the Csound parser generate exactly the same syntax tree
for both the versions?


Best Regards,

---
Mauro

Csound mailing list Csound@listserv.heanet.ie
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
Csound@listserv.heanet.ie
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 Csound@listserv.heanet.ie 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 Csound@listserv.heanet.ie 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

Date2019-02-21 21:23
FromMauro Giubileo
SubjectRe: [Csnd] Classic vs alternative syntax

Very nice, thanks!

---
Mauro

 


Il 2019-02-21 21:10 john ha scritto:

I fixed the multicore issue and revised the assigment optimisation.  As far as I can tell the classical and functional cases are the same now.

A ever I epect peope to find more nasties in the compilation..... ives me something to do!



On Thu, 21 Feb 2019, john wrote:

Simpleexperimemt shows they are not identical.` Instr 2 has a temporary variable created.  Similar examplewith kvars are identical.  There is code to optimise but it does not always work aparently
 Ialso saw some errors in the compilation referring to multicore.  No idea why

I guess it is time to look again.


<CsInstruments>
instr 1
 aout oscil 1000, 440
 out aout
 endin

instr 2
 aout = oscil(1000, 440)
 out aout
 endin
</CsInstruments>


On Thu, 21 Feb 2019, Mauro Giubileo wrote:


Hi, I was thinking about the classic Csound syntax vs the alternative one and
I was wondering if something like this:

 aOut someOpcode ...

runs faster than:

 aOut = someOpcode(...)

In other terms, does the Csound parser generate exactly the same syntax tree
for both the versions?


Best Regards,

---
Mauro

Csound mailing list
Csound@listserv.heanet.ie
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

Date2019-02-22 07:26
FromTarmo Johannes
SubjectRe: [Csnd] Classic vs alternative syntax

Hi,

 

I am afraid this is not the case - it depends which type is declared to be the default one and it can be different in different opcodes. Thus I think it is good practice to always include the desired type in functionlike syntax - otherwise you may get sometimes undwanted behaviour that is hard to detect.

 

Fotr myself I use old syntax when there is one opcode in a line (since the type is set by variable) like

 

ivalue random 10, 20

 

and functionlike when I want to have several opcodes in one line:

 

kvalue port chnget:k("value"), 0.02, chnget:i("value")

 

greetings,

tarmo

 

 

 

 

 

 

On neljapäev, 21. veebruar 2019 23:20.34 EET you wrote:

So, we can assume that for all the opcodes that can return a/k/i-type variables, the a-type is always the default one when you don't specify it and use the function syntax? --- Mauro




Date2019-02-22 10:26
FromRory Walsh
SubjectRe: [Csnd] Classic vs alternative syntax
Thanks for clarifying that Tarmo. I wasn't quite sure. 

On Fri 22 Feb 2019, 07:26 Tarmo Johannes <trmjhnns@gmail.com wrote:

Hi,

 

I am afraid this is not the case - it depends which type is declared to be the default one and it can be different in different opcodes. Thus I think it is good practice to always include the desired type in functionlike syntax - otherwise you may get sometimes undwanted behaviour that is hard to detect.

 

Fotr myself I use old syntax when there is one opcode in a line (since the type is set by variable) like

 

ivalue random 10, 20

 

and functionlike when I want to have several opcodes in one line:

 

kvalue port chnget:k("value"), 0.02, chnget:i("value")

 

greetings,

tarmo

 

 

 

 

 

 

On neljapäev, 21. veebruar 2019 23:20.34 EET you wrote:

So, we can assume that for all the opcodes that can return a/k/i-type variables, the a-type is always the default one when you don't specify it and use the function syntax? --- Mauro



Csound mailing list Csound@listserv.heanet.ie 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 Csound@listserv.heanet.ie 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

Date2019-02-22 16:28
FromMauro Giubileo
SubjectRe: [Csnd] Classic vs alternative syntax

Thanks, good to know. Now I remember I had some troubles in the past because sometimes I omitted the ":type" in some expressions with function syntax, so I too think that the when you use function syntax is better to always specify the returned type. The problem is that I tend to forget this... :-D

An advantage of the classic syntax is that there are no ambiguities on this matter, but you lose the ability to directly use an opcode inside an expression.

---
Mauro

 


Il 2019-02-22 08:26 Tarmo Johannes ha scritto:

Hi,

 

I am afraid this is not the case - it depends which type is declared to be the default one and it can be different in different opcodes. Thus I think it is good practice to always include the desired type in functionlike syntax - otherwise you may get sometimes undwanted behaviour that is hard to detect.

 

Fotr myself I use old syntax when there is one opcode in a line (since the type is set by variable) like

 

ivalue random 10, 20

 

and functionlike when I want to have several opcodes in one line:

 

kvalue port chnget:k("value"), 0.02, chnget:i("value")

 

greetings,

tarmo

 

 

 

 

 

 

On neljapäev, 21. veebruar 2019 23:20.34 EET you wrote:

So, we can assume that for all the opcodes that can return a/k/i-type variables, the a-type is always the default one when you don't specify it and use the function syntax? --- Mauro



Csound mailing list Csound@listserv.heanet.ie 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