Csound Csound-dev Csound-tekno Search About

if...then behaviour in UDO with setksmps 1

Date2017-08-15 19:22
FromHector Centeno
Subjectif...then behaviour in UDO with setksmps 1
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 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

Date2017-08-15 20:00
FromSteven Yi
SubjectRe: if...then behaviour in UDO with setksmps 1
This doesn't seem right to me. Could you post an example?

On Tue, Aug 15, 2017 at 2:22 PM, Hector Centeno  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 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

Date2017-08-15 21:20
FromHector Centeno
SubjectRe: if...then behaviour in UDO with setksmps 1
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 <stevenyi@gmail.com> wrote:
This doesn't seem right to me. Could you post an example?

On Tue, Aug 15, 2017 at 2:22 PM, Hector Centeno <hcengar@gmail.com> 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 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

Date2017-08-15 21:23
FromHector Centeno
SubjectRe: if...then behaviour in UDO with setksmps 1
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 <hcengar@gmail.com> 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 <stevenyi@gmail.com> wrote:
This doesn't seem right to me. Could you post an example?

On Tue, Aug 15, 2017 at 2:22 PM, Hector Centeno <hcengar@gmail.com> 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 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

Date2017-08-15 21:27
FromSteven Yi
SubjectRe: if...then behaviour in UDO with setksmps 1
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  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  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.
>>
>> 
>> 
>> -odac
>> 
>> 
>>
>> 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
>>
>> 
>> 
>> i 10 0 1 0
>> i 10 1 1 1
>> 
>> 
>>
>> On Tue, Aug 15, 2017 at 3:00 PM Steven Yi  wrote:
>>>
>>> This doesn't seem right to me. Could you post an example?
>>>
>>> On Tue, Aug 15, 2017 at 2:22 PM, Hector Centeno 
>>> 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 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

Date2017-08-15 21:48
FromSteven Yi
SubjectRe: if...then behaviour in UDO with setksmps 1
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  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  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  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.
>>>
>>> 
>>> 
>>> -odac
>>> 
>>> 
>>>
>>> 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
>>>
>>> 
>>> 
>>> i 10 0 1 0
>>> i 10 1 1 1
>>> 
>>> 
>>>
>>> On Tue, Aug 15, 2017 at 3:00 PM Steven Yi  wrote:
>>>>
>>>> This doesn't seem right to me. Could you post an example?
>>>>
>>>> On Tue, Aug 15, 2017 at 2:22 PM, Hector Centeno 
>>>> 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 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

Date2017-08-15 21:50
FromJohn ff
SubjectRe: if...then behaviour in UDO with setksmps 1
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 <stevenyi@GMAIL.COM> 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 <hcengar@gmail.com> 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 <hcengar@gmail.com> 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 <stevenyi@gmail.com> wrote:

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

On Tue, Aug 15, 2017 at 2:22 PM, Hector Centeno <hcengar@gmail.com>
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 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

Date2017-08-15 22:00
FromJohn ff
SubjectRe: if...then behaviour in UDO with setksmps 1
I suspect you unfixed the instr0 bug?

Sent from Blue
On 15 Aug 2017, at 21:49, Steven Yi <stevenyi@GMAIL.COM> 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 <stevenyi@gmail.com> 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 <hcengar@gmail.com> 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 <hcengar@gmail.com> 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 <stevenyi@gmail.com> wrote:

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

On Tue, Aug 15, 2017 at 2:22 PM, Hector Centeno <hcengar@gmail.com>
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 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

Date2017-08-15 22:03
FromSteven Yi
SubjectRe: if...then behaviour in UDO with setksmps 1
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  wrote:
> I suspect you unfixed the instr0 bug?
>
> Sent from Blue
> On 15 Aug 2017, at 21:49, Steven Yi  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  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 
>>> 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 
>>>> 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.
>>>>>
>>>>>  
>>>>>  
>>>>>  -odac
>>>>>  
>>>>>  
>>>>>
>>>>>  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
>>>>>
>>>>>  
>>>>>  
>>>>>  i 10 0 1 0
>>>>>  i 10 1 1 1
>>>>>  
>>>>>  
>>>>>
>>>>>  On Tue, Aug 15, 2017 at 3:00 PM Steven Yi  wrote:
>>>>>>
>>>>>>
>>>>>>  This doesn't seem right to me. Could you post an example?
>>>>>>
>>>>>>  On Tue, Aug 15, 2017 at 2:22 PM, Hector Centeno 
>>>>>>  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 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
>
> 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