[Csnd] if...then behaviour in UDO with setksmps 1

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

[Csnd] if...then behaviour in UDO with setksmps 1

hcenteno
Hello,

I have an UDO that has setksmps to 1 but it seems that this makes all the k-rate if...then conditionals to be completely ignored. The code inside them gets executed regardless of the condition being true or false.  I had to replace them with if...kgoto conditionals, which works as expected. Removing setksmps makes the if...then work again. Is this an expected behaviour? I'm using Csound 6.09.1 on Windows 10.

Thanks,

Hector


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] if...then behaviour in UDO with setksmps 1

Steven Yi
This doesn't seem right to me. Could you post an example?

On Tue, Aug 15, 2017 at 2:22 PM, Hector Centeno <[hidden email]> wrote:

> Hello,
>
> I have an UDO that has setksmps to 1 but it seems that this makes all the
> k-rate if...then conditionals to be completely ignored. The code inside them
> gets executed regardless of the condition being true or false.  I had to
> replace them with if...kgoto conditionals, which works as expected. Removing
> setksmps makes the if...then work again. Is this an expected behaviour? I'm
> using Csound 6.09.1 on Windows 10.
>
> Thanks,
>
> Hector
>
>
> 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] if...then behaviour in UDO with setksmps 1

hcenteno
Thanks Steven,

It seems that setksmps doesn't really have any impact so I removed it from the test. Here's a simple test CSD with an UDO that uses both "then" and "kgoto". p4 in instrument 10 is passed to the UDO to compare and print a string if equal to 1. The output is:

instr 10:  p4 = 0.000
if...then true, kval==0
B  0.000 ..  1.000 T  1.000 TT  1.000 M:  1.00000  0.00000
instr 10:  p4 = 1.000
if...then true, kval==1
if...kgoto true, kval==1
B  1.000 ..  2.000 T  2.000 TT  2.000 M:  1.00000  0.00000
.
Actually I'm on Csound 6.09.2 (the latest beta for Windows) although Csound reports as being 6.09.1 but I guess that's just the version number needing to be updated in the source.

<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>

sr = 48000
ksmps = 32
nchnls = 2
0dbfs  = 1

opcode BPlay, a,k
kval xin 
if (kval == 1) then
printks "if...then true, kval==%d\n", 2, kval
endif

if (kval == 1) kgoto label1
kgoto label2
label1:
printks "if...kgoto true, kval==%d\n", 2, kval

label2:
aout1 oscil 1, 440

xout aout1     

endop

instr 10
print p4
aw BPlay p4
out aw

endin

</CsInstruments>
<CsScore>
i 10 0 1 0
i 10 1 1 1
</CsScore>
</CsoundSynthesizer>

On Tue, Aug 15, 2017 at 3:00 PM Steven Yi <[hidden email]> wrote:
This doesn't seem right to me. Could you post an example?

On Tue, Aug 15, 2017 at 2:22 PM, Hector Centeno <[hidden email]> wrote:
> Hello,
>
> I have an UDO that has setksmps to 1 but it seems that this makes all the
> k-rate if...then conditionals to be completely ignored. The code inside them
> gets executed regardless of the condition being true or false.  I had to
> replace them with if...kgoto conditionals, which works as expected. Removing
> setksmps makes the if...then work again. Is this an expected behaviour? I'm
> using Csound 6.09.1 on Windows 10.
>
> Thanks,
>
> Hector
>
>
> 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] if...then behaviour in UDO with setksmps 1

hcenteno
oops, sorry for the full amplitude oscil. Please change it before running the test!!

On Tue, Aug 15, 2017 at 4:19 PM Hector Centeno <[hidden email]> wrote:
Thanks Steven,

It seems that setksmps doesn't really have any impact so I removed it from the test. Here's a simple test CSD with an UDO that uses both "then" and "kgoto". p4 in instrument 10 is passed to the UDO to compare and print a string if equal to 1. The output is:

instr 10:  p4 = 0.000
if...then true, kval==0
B  0.000 ..  1.000 T  1.000 TT  1.000 M:  1.00000  0.00000
instr 10:  p4 = 1.000
if...then true, kval==1
if...kgoto true, kval==1
B  1.000 ..  2.000 T  2.000 TT  2.000 M:  1.00000  0.00000
.
Actually I'm on Csound 6.09.2 (the latest beta for Windows) although Csound reports as being 6.09.1 but I guess that's just the version number needing to be updated in the source.

<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>

sr = 48000
ksmps = 32
nchnls = 2
0dbfs  = 1

opcode BPlay, a,k
kval xin 
if (kval == 1) then
printks "if...then true, kval==%d\n", 2, kval
endif

if (kval == 1) kgoto label1
kgoto label2
label1:
printks "if...kgoto true, kval==%d\n", 2, kval

label2:
aout1 oscil 1, 440

xout aout1     

endop

instr 10
print p4
aw BPlay p4
out aw

endin

</CsInstruments>
<CsScore>
i 10 0 1 0
i 10 1 1 1
</CsScore>
</CsoundSynthesizer>

On Tue, Aug 15, 2017 at 3:00 PM Steven Yi <[hidden email]> wrote:
This doesn't seem right to me. Could you post an example?

On Tue, Aug 15, 2017 at 2:22 PM, Hector Centeno <[hidden email]> wrote:
> Hello,
>
> I have an UDO that has setksmps to 1 but it seems that this makes all the
> k-rate if...then conditionals to be completely ignored. The code inside them
> gets executed regardless of the condition being true or false.  I had to
> replace them with if...kgoto conditionals, which works as expected. Removing
> setksmps makes the if...then work again. Is this an expected behaviour? I'm
> using Csound 6.09.1 on Windows 10.
>
> Thanks,
>
> Hector
>
>
> 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] if...then behaviour in UDO with setksmps 1

Steven Yi
I had the volume down before testing, luckily. ;)

I see from running with --verbose:

op (xin) allocated at 0000000003D0EA10
op (==.0) allocated at 0000000003D0F240
op (cingoto) allocated at 0000000003D0F288
op (printks) allocated at 0000000003D0F2C8
opadr = 000000006C5831C0
op ($label) allocated at 0000000003D151A0
op (==.0) allocated at 0000000003D151E0
op (ckgoto) allocated at 0000000003D15228
opadr = 000000006C557AF0
op (kgoto) allocated at 0000000003D15268
opadr = 000000006C557AB0
op ($label) allocated at 0000000003D152A0
op (printks) allocated at 0000000003D152E0
opadr = 000000006C5831C0
op ($label) allocated at 0000000003D1B1B8
op (oscil.a) allocated at 0000000003D1B1F8
opadr = 000000006C570A30
op (xout) allocated at 0000000003D1F540

that cingoto is used for the if-then, but probably should be cngoto.
Going to take a look now...

On Tue, Aug 15, 2017 at 4:23 PM, Hector Centeno <[hidden email]> wrote:

> oops, sorry for the full amplitude oscil. Please change it before running
> the test!!
>
> On Tue, Aug 15, 2017 at 4:19 PM Hector Centeno <[hidden email]> wrote:
>>
>> Thanks Steven,
>>
>> It seems that setksmps doesn't really have any impact so I removed it from
>> the test. Here's a simple test CSD with an UDO that uses both "then" and
>> "kgoto". p4 in instrument 10 is passed to the UDO to compare and print a
>> string if equal to 1. The output is:
>>
>> instr 10:  p4 = 0.000
>> if...then true, kval==0
>> B  0.000 ..  1.000 T  1.000 TT  1.000 M:  1.00000  0.00000
>> instr 10:  p4 = 1.000
>> if...then true, kval==1
>> if...kgoto true, kval==1
>> B  1.000 ..  2.000 T  2.000 TT  2.000 M:  1.00000  0.00000
>> .
>> Actually I'm on Csound 6.09.2 (the latest beta for Windows) although
>> Csound reports as being 6.09.1 but I guess that's just the version number
>> needing to be updated in the source.
>>
>> <CsoundSynthesizer>
>> <CsOptions>
>> -odac
>> </CsOptions>
>> <CsInstruments>
>>
>> sr = 48000
>> ksmps = 32
>> nchnls = 2
>> 0dbfs  = 1
>>
>> opcode BPlay, a,k
>> kval xin
>> if (kval == 1) then
>> printks "if...then true, kval==%d\n", 2, kval
>> endif
>>
>> if (kval == 1) kgoto label1
>> kgoto label2
>> label1:
>> printks "if...kgoto true, kval==%d\n", 2, kval
>>
>> label2:
>> aout1 oscil 1, 440
>>
>> xout aout1
>>
>> endop
>>
>> instr 10
>> print p4
>> aw BPlay p4
>> out aw
>>
>> endin
>>
>> </CsInstruments>
>> <CsScore>
>> i 10 0 1 0
>> i 10 1 1 1
>> </CsScore>
>> </CsoundSynthesizer>
>>
>> On Tue, Aug 15, 2017 at 3:00 PM Steven Yi <[hidden email]> wrote:
>>>
>>> This doesn't seem right to me. Could you post an example?
>>>
>>> On Tue, Aug 15, 2017 at 2:22 PM, Hector Centeno <[hidden email]>
>>> wrote:
>>> > Hello,
>>> >
>>> > I have an UDO that has setksmps to 1 but it seems that this makes all
>>> > the
>>> > k-rate if...then conditionals to be completely ignored. The code inside
>>> > them
>>> > gets executed regardless of the condition being true or false.  I had
>>> > to
>>> > replace them with if...kgoto conditionals, which works as expected.
>>> > Removing
>>> > setksmps makes the if...then work again. Is this an expected behaviour?
>>> > I'm
>>> > using Csound 6.09.1 on Windows 10.
>>> >
>>> > Thanks,
>>> >
>>> > Hector
>>> >
>>> >
>>> > 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] if...then behaviour in UDO with setksmps 1

Steven Yi
I've found a fix. I didn't follow the background for the change, but
it has to do with instrument 0 parsing of if-then. It looks like the
change was done by adding an ->inZero flag that gets toggled, but it
only toggled when compiling instrument definitions and not UDO
definitions.  It's a pretty serious bug, but it was introduced only
after the last full release (6.09.1), so anyone using releases should
be okay.

I found it a little hard to understand the issue from the Git commit
messages and I'm going to guess we may need to revisit the code as it
is stored in the csound struct and may cause problems in the case of
failed compilations and live-coding. For now though, if you do a build
with latest from develop you should get the fix.

On Tue, Aug 15, 2017 at 4:27 PM, Steven Yi <[hidden email]> wrote:

> I had the volume down before testing, luckily. ;)
>
> I see from running with --verbose:
>
> op (xin) allocated at 0000000003D0EA10
> op (==.0) allocated at 0000000003D0F240
> op (cingoto) allocated at 0000000003D0F288
> op (printks) allocated at 0000000003D0F2C8
> opadr = 000000006C5831C0
> op ($label) allocated at 0000000003D151A0
> op (==.0) allocated at 0000000003D151E0
> op (ckgoto) allocated at 0000000003D15228
> opadr = 000000006C557AF0
> op (kgoto) allocated at 0000000003D15268
> opadr = 000000006C557AB0
> op ($label) allocated at 0000000003D152A0
> op (printks) allocated at 0000000003D152E0
> opadr = 000000006C5831C0
> op ($label) allocated at 0000000003D1B1B8
> op (oscil.a) allocated at 0000000003D1B1F8
> opadr = 000000006C570A30
> op (xout) allocated at 0000000003D1F540
>
> that cingoto is used for the if-then, but probably should be cngoto.
> Going to take a look now...
>
> On Tue, Aug 15, 2017 at 4:23 PM, Hector Centeno <[hidden email]> wrote:
>> oops, sorry for the full amplitude oscil. Please change it before running
>> the test!!
>>
>> On Tue, Aug 15, 2017 at 4:19 PM Hector Centeno <[hidden email]> wrote:
>>>
>>> Thanks Steven,
>>>
>>> It seems that setksmps doesn't really have any impact so I removed it from
>>> the test. Here's a simple test CSD with an UDO that uses both "then" and
>>> "kgoto". p4 in instrument 10 is passed to the UDO to compare and print a
>>> string if equal to 1. The output is:
>>>
>>> instr 10:  p4 = 0.000
>>> if...then true, kval==0
>>> B  0.000 ..  1.000 T  1.000 TT  1.000 M:  1.00000  0.00000
>>> instr 10:  p4 = 1.000
>>> if...then true, kval==1
>>> if...kgoto true, kval==1
>>> B  1.000 ..  2.000 T  2.000 TT  2.000 M:  1.00000  0.00000
>>> .
>>> Actually I'm on Csound 6.09.2 (the latest beta for Windows) although
>>> Csound reports as being 6.09.1 but I guess that's just the version number
>>> needing to be updated in the source.
>>>
>>> <CsoundSynthesizer>
>>> <CsOptions>
>>> -odac
>>> </CsOptions>
>>> <CsInstruments>
>>>
>>> sr = 48000
>>> ksmps = 32
>>> nchnls = 2
>>> 0dbfs  = 1
>>>
>>> opcode BPlay, a,k
>>> kval xin
>>> if (kval == 1) then
>>> printks "if...then true, kval==%d\n", 2, kval
>>> endif
>>>
>>> if (kval == 1) kgoto label1
>>> kgoto label2
>>> label1:
>>> printks "if...kgoto true, kval==%d\n", 2, kval
>>>
>>> label2:
>>> aout1 oscil 1, 440
>>>
>>> xout aout1
>>>
>>> endop
>>>
>>> instr 10
>>> print p4
>>> aw BPlay p4
>>> out aw
>>>
>>> endin
>>>
>>> </CsInstruments>
>>> <CsScore>
>>> i 10 0 1 0
>>> i 10 1 1 1
>>> </CsScore>
>>> </CsoundSynthesizer>
>>>
>>> On Tue, Aug 15, 2017 at 3:00 PM Steven Yi <[hidden email]> wrote:
>>>>
>>>> This doesn't seem right to me. Could you post an example?
>>>>
>>>> On Tue, Aug 15, 2017 at 2:22 PM, Hector Centeno <[hidden email]>
>>>> wrote:
>>>> > Hello,
>>>> >
>>>> > I have an UDO that has setksmps to 1 but it seems that this makes all
>>>> > the
>>>> > k-rate if...then conditionals to be completely ignored. The code inside
>>>> > them
>>>> > gets executed regardless of the condition being true or false.  I had
>>>> > to
>>>> > replace them with if...kgoto conditionals, which works as expected.
>>>> > Removing
>>>> > setksmps makes the if...then work again. Is this an expected behaviour?
>>>> > I'm
>>>> > using Csound 6.09.1 on Windows 10.
>>>> >
>>>> > Thanks,
>>>> >
>>>> > Hector
>>>> >
>>>> >
>>>> > 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] if...then behaviour in UDO with setksmps 1

jpff
In reply to this post by Steven Yi
Arhhh.  Ido is being treated as instr0

Recent change.  Needs small fix to compiler to unset instr0

Sorry busy just now cooking

Sent from Blue
On 15 Aug 2017, at 21:28, Steven Yi <[hidden email]> wrote:
I had the volume down before testing, luckily. ;)

I see from running with --verbose:

op (xin) allocated at 0000000003D0EA10
op (==.0) allocated at 0000000003D0F240
op (cingoto) allocated at 0000000003D0F288
op (printks) allocated at 0000000003D0F2C8
opadr = 000000006C5831C0
op ($label) allocated at 0000000003D151A0
op (==.0) allocated at 0000000003D151E0
op (ckgoto) allocated at 0000000003D15228
opadr = 000000006C557AF0
op (kgoto) allocated at 0000000003D15268
opadr = 000000006C557AB0
op ($label) allocated at 0000000003D152A0
op (printks) allocated at 0000000003D152E0
opadr = 000000006C5831C0
op ($label) allocated at 0000000003D1B1B8
op (oscil.a) allocated at 0000000003D1B1F8
opadr = 000000006C570A30
op (xout) allocated at 0000000003D1F540

that cingoto is used for the if-then, but probably should be cngoto.
Going to take a look now...

On Tue, Aug 15, 2017 at 4:23 PM, Hector Centeno <[hidden email]> wrote:
oops, sorry for the full amplitude oscil. Please change it before running
the test!!

On Tue, Aug 15, 2017 at 4:19 PM Hector Centeno <[hidden email]> wrote:

Thanks Steven,

It seems that setksmps doesn't really have any impact so I removed it from
the test. Here's a simple test CSD with an UDO that uses both "then" and
"kgoto". p4 in instrument 10 is passed to the UDO to compare and print a
string if equal to 1. The output is:

instr 10: p4 = 0.000
if...then true, kval==0
B 0.000 .. 1.000 T 1.000 TT 1.000 M: 1.00000 0.00000
instr 10: p4 = 1.000
if...then true, kval==1
if...kgoto true, kval==1
B 1.000 .. 2.000 T 2.000 TT 2.000 M: 1.00000 0.00000
.
Actually I'm on Csound 6.09.2 (the latest beta for Windows) although
Csound reports as being 6.09.1 but I guess that's just the version number
needing to be updated in the source.

<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>

sr = 48000
ksmps = 32
nchnls = 2
0dbfs = 1

opcode BPlay, a,k
kval xin
if (kval == 1) then
printks "if...then true, kval==%d\n", 2, kval
endif

if (kval == 1) kgoto label1
kgoto label2
label1:
printks "if...kgoto true, kval==%d\n", 2, kval

label2:
aout1 oscil 1, 440

xout aout1

endop

instr 10
print p4
aw BPlay p4
out aw

endin

</CsInstruments>
<CsScore>
i 10 0 1 0
i 10 1 1 1
</CsScore>
</CsoundSynthesizer>

On Tue, Aug 15, 2017 at 3:00 PM Steven Yi <[hidden email]> wrote:

This doesn't seem right to me. Could you post an example?

On Tue, Aug 15, 2017 at 2:22 PM, Hector Centeno <[hidden email]>
wrote:
Hello,

I have an UDO that has setksmps to 1 but it seems that this makes all
the
k-rate if...then conditionals to be completely ignored. The code inside
them
gets executed regardless of the condition being true or false. I had
to
replace them with if...kgoto conditionals, which works as expected.
Removing
setksmps makes the if...then work again. Is this an expected behaviour?
I'm
using Csound 6.09.1 on Windows 10.

Thanks,

Hector


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] if...then behaviour in UDO with setksmps 1

jpff
In reply to this post by Steven Yi
I suspect you unfixed the instr0 bug?

Sent from Blue
On 15 Aug 2017, at 21:49, Steven Yi <[hidden email]> wrote:
I've found a fix. I didn't follow the background for the change, but
it has to do with instrument 0 parsing of if-then. It looks like the
change was done by adding an ->inZero flag that gets toggled, but it
only toggled when compiling instrument definitions and not UDO
definitions. It's a pretty serious bug, but it was introduced only
after the last full release (6.09.1), so anyone using releases should
be okay.

I found it a little hard to understand the issue from the Git commit
messages and I'm going to guess we may need to revisit the code as it
is stored in the csound struct and may cause problems in the case of
failed compilations and live-coding. For now though, if you do a build
with latest from develop you should get the fix.

On Tue, Aug 15, 2017 at 4:27 PM, Steven Yi <[hidden email]> wrote:
I had the volume down before testing, luckily. ;)

I see from running with --verbose:

op (xin) allocated at 0000000003D0EA10
op (==.0) allocated at 0000000003D0F240
op (cingoto) allocated at 0000000003D0F288
op (printks) allocated at 0000000003D0F2C8
opadr = 000000006C5831C0
op ($label) allocated at 0000000003D151A0
op (==.0) allocated at 0000000003D151E0
op (ckgoto) allocated at 0000000003D15228
opadr = 000000006C557AF0
op (kgoto) allocated at 0000000003D15268
opadr = 000000006C557AB0
op ($label) allocated at 0000000003D152A0
op (printks) allocated at 0000000003D152E0
opadr = 000000006C5831C0
op ($label) allocated at 0000000003D1B1B8
op (oscil.a) allocated at 0000000003D1B1F8
opadr = 000000006C570A30
op (xout) allocated at 0000000003D1F540

that cingoto is used for the if-then, but probably should be cngoto.
Going to take a look now...

On Tue, Aug 15, 2017 at 4:23 PM, Hector Centeno <[hidden email]> wrote:
oops, sorry for the full amplitude oscil. Please change it before running
the test!!

On Tue, Aug 15, 2017 at 4:19 PM Hector Centeno <[hidden email]> wrote:

Thanks Steven,

It seems that setksmps doesn't really have any impact so I removed it from
the test. Here's a simple test CSD with an UDO that uses both "then" and
"kgoto". p4 in instrument 10 is passed to the UDO to compare and print a
string if equal to 1. The output is:

instr 10: p4 = 0.000
if...then true, kval==0
B 0.000 .. 1.000 T 1.000 TT 1.000 M: 1.00000 0.00000
instr 10: p4 = 1.000
if...then true, kval==1
if...kgoto true, kval==1
B 1.000 .. 2.000 T 2.000 TT 2.000 M: 1.00000 0.00000
.
Actually I'm on Csound 6.09.2 (the latest beta for Windows) although
Csound reports as being 6.09.1 but I guess that's just the version number
needing to be updated in the source.

<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>

sr = 48000
ksmps = 32
nchnls = 2
0dbfs = 1

opcode BPlay, a,k
kval xin
if (kval == 1) then
printks "if...then true, kval==%d\n", 2, kval
endif

if (kval == 1) kgoto label1
kgoto label2
label1:
printks "if...kgoto true, kval==%d\n", 2, kval

label2:
aout1 oscil 1, 440

xout aout1

endop

instr 10
print p4
aw BPlay p4
out aw

endin

</CsInstruments>
<CsScore>
i 10 0 1 0
i 10 1 1 1
</CsScore>
</CsoundSynthesizer>

On Tue, Aug 15, 2017 at 3:00 PM Steven Yi <[hidden email]> wrote:

This doesn't seem right to me. Could you post an example?

On Tue, Aug 15, 2017 at 2:22 PM, Hector Centeno <[hidden email]>
wrote:
Hello,

I have an UDO that has setksmps to 1 but it seems that this makes all
the
k-rate if...then conditionals to be completely ignored. The code inside
them
gets executed regardless of the condition being true or false. I had
to
replace them with if...kgoto conditionals, which works as expected.
Removing
setksmps makes the if...then work again. Is this an expected behaviour?
I'm
using Csound 6.09.1 on Windows 10.

Thanks,

Hector


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] if...then behaviour in UDO with setksmps 1

Steven Yi
I modified to set ->inZero to 0 when UDO definition starts and back to
1 when endop is found, matching the behavior of instr/endin.  However,
I found that this all relates to bug #826
(https://github.com/csound/csound/issues/826) and I have reopened that
and made a proposal there.  (Perhaps we can pick up the conversation
there as it's a bit technical at this point?)

On Tue, Aug 15, 2017 at 5:00 PM, John ff <[hidden email]> wrote:

> I suspect you unfixed the instr0 bug?
>
> Sent from Blue
> On 15 Aug 2017, at 21:49, Steven Yi <[hidden email]> wrote:
>>
>> I've found a fix. I didn't follow the background for the change, but
>> it has to do with instrument 0 parsing of if-then. It looks like the
>> change was done by adding an ->inZero flag that gets toggled, but it
>> only toggled when compiling instrument definitions and not UDO
>> definitions.  It's a pretty serious bug, but it was introduced only
>> after the last full release (6.09.1), so anyone using releases should
>> be okay.
>>
>> I found it a little hard to understand the issue from the Git commit
>> messages and I'm going to guess we may need to revisit the code as it
>> is stored in the csound struct and may cause problems in the case of
>> failed compilations and live-coding. For now though, if you do a build
>> with latest from develop you should get the fix.
>>
>> On Tue, Aug 15, 2017 at 4:27 PM, Steven Yi <[hidden email]> wrote:
>>>
>>>  I had the volume down before testing, luckily. ;)
>>>
>>>  I see from running with --verbose:
>>>
>>>  op (xin) allocated at 0000000003D0EA10
>>>  op (==.0) allocated at 0000000003D0F240
>>>  op (cingoto) allocated at 0000000003D0F288
>>>  op (printks) allocated at 0000000003D0F2C8
>>>  opadr = 000000006C5831C0
>>>  op ($label) allocated at 0000000003D151A0
>>>  op (==.0) allocated at 0000000003D151E0
>>>  op (ckgoto) allocated at 0000000003D15228
>>>  opadr = 000000006C557AF0
>>>  op (kgoto) allocated at 0000000003D15268
>>>  opadr = 000000006C557AB0
>>>  op ($label) allocated at 0000000003D152A0
>>>  op (printks) allocated at 0000000003D152E0
>>>  opadr = 000000006C5831C0
>>>  op ($label) allocated at 0000000003D1B1B8
>>>  op (oscil.a) allocated at 0000000003D1B1F8
>>>  opadr = 000000006C570A30
>>>  op (xout) allocated at 0000000003D1F540
>>>
>>>  that cingoto is used for the if-then, but probably should be cngoto.
>>>  Going to take a look now...
>>>
>>>  On Tue, Aug 15, 2017 at 4:23 PM, Hector Centeno <[hidden email]>
>>> wrote:
>>>>
>>>>  oops, sorry for the full amplitude oscil. Please change it before
>>>> running
>>>>  the test!!
>>>>
>>>>  On Tue, Aug 15, 2017 at 4:19 PM Hector Centeno <[hidden email]>
>>>> wrote:
>>>>>
>>>>>
>>>>>  Thanks Steven,
>>>>>
>>>>>  It seems that setksmps doesn't really have any impact so I removed it
>>>>> from
>>>>>  the test. Here's a simple test CSD with an UDO that uses both "then"
>>>>> and
>>>>>  "kgoto". p4 in instrument 10 is passed to the UDO to compare and print
>>>>> a
>>>>>  string if equal to 1. The output is:
>>>>>
>>>>>  instr 10:  p4 = 0.000
>>>>>  if...then true, kval==0
>>>>>  B  0.000 ..  1.000 T  1.000 TT  1.000 M:  1.00000  0.00000
>>>>>  instr 10:  p4 = 1.000
>>>>>  if...then true, kval==1
>>>>>  if...kgoto true, kval==1
>>>>>  B  1.000 ..  2.000 T  2.000 TT  2.000 M:  1.00000  0.00000
>>>>>  .
>>>>>  Actually I'm on Csound 6.09.2 (the latest beta for Windows) although
>>>>>  Csound reports as being 6.09.1 but I guess that's just the version
>>>>> number
>>>>>  needing to be updated in the source.
>>>>>
>>>>>  <CsoundSynthesizer>
>>>>>  <CsOptions>
>>>>>  -odac
>>>>>  </CsOptions>
>>>>>  <CsInstruments>
>>>>>
>>>>>  sr = 48000
>>>>>  ksmps = 32
>>>>>  nchnls = 2
>>>>>  0dbfs  = 1
>>>>>
>>>>>  opcode BPlay, a,k
>>>>>  kval xin
>>>>>  if (kval == 1) then
>>>>>  printks "if...then true, kval==%d\n", 2, kval
>>>>>  endif
>>>>>
>>>>>  if (kval == 1) kgoto label1
>>>>>  kgoto label2
>>>>>  label1:
>>>>>  printks "if...kgoto true, kval==%d\n", 2, kval
>>>>>
>>>>>  label2:
>>>>>  aout1 oscil 1, 440
>>>>>
>>>>>  xout aout1
>>>>>
>>>>>  endop
>>>>>
>>>>>  instr 10
>>>>>  print p4
>>>>>  aw BPlay p4
>>>>>  out aw
>>>>>
>>>>>  endin
>>>>>
>>>>>  </CsInstruments>
>>>>>  <CsScore>
>>>>>  i 10 0 1 0
>>>>>  i 10 1 1 1
>>>>>  </CsScore>
>>>>>  </CsoundSynthesizer>
>>>>>
>>>>>  On Tue, Aug 15, 2017 at 3:00 PM Steven Yi <[hidden email]> wrote:
>>>>>>
>>>>>>
>>>>>>  This doesn't seem right to me. Could you post an example?
>>>>>>
>>>>>>  On Tue, Aug 15, 2017 at 2:22 PM, Hector Centeno <[hidden email]>
>>>>>>  wrote:
>>>>>>>
>>>>>>>  Hello,
>>>>>>>
>>>>>>>  I have an UDO that has setksmps to 1 but it seems that this makes
>>>>>>> all
>>>>>>>  the
>>>>>>>  k-rate if...then conditionals to be completely ignored. The code
>>>>>>> inside
>>>>>>>  them
>>>>>>>  gets executed regardless of the condition being true or false.  I
>>>>>>> had
>>>>>>>  to
>>>>>>>  replace them with if...kgoto conditionals, which works as expected.
>>>>>>>  Removing
>>>>>>>  setksmps makes the if...then work again. Is this an expected
>>>>>>> behaviour?
>>>>>>>  I'm
>>>>>>>  using Csound 6.09.1 on Windows 10.
>>>>>>>
>>>>>>>  Thanks,
>>>>>>>
>>>>>>>  Hector
>>>>>>>
>>>>>>>
>>>>>>>  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