Csound Csound-dev Csound-tekno Search About

[Csnd] Detecting string change

Date2020-11-22 13:59
FromRichard
Subject[Csnd] Detecting string change
I am using the following code:

instr 11
Sgm chnget "GM"
kgm changed Sgm
printk2 kgm
if (kgm==1) then
     prints "%s", Sgm
endif
endin

When the string changes the output shows that kgm becomes 1, but 
immediately becomes 0 again.
Printing of the string in the if block is not executed.

Why?

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

Date2020-11-22 14:16
FromDave Seidel
SubjectRe: [Csnd] Detecting string change
I think because you're using prints, which is I-rate, but it's a k-rate if statement. Try using prints. 

On Sun, Nov 22, 2020, 8:59 AM Richard <zappfinger@gmail.com> wrote:
I am using the following code:

instr 11
Sgm chnget "GM"
kgm changed Sgm
printk2 kgm
if (kgm==1) then
     prints "%s", Sgm
endif
endin

When the string changes the output shows that kgm becomes 1, but
immediately becomes 0 again.
Printing of the string in the if block is not executed.

Why?

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

Date2020-11-22 15:02
FromRichard
SubjectRe: [Csnd] Detecting string change

Yes of course. I am using printks now and that works.
Well in this case it actually lags one behind. The string that is printed is actually the previous selection.
Have to find out why...

BTW, it would be nice if printks could also accept -1 for the itime, indicating that it only prints one time...

On 22/11/2020 15:16, Dave Seidel wrote:
I think because you're using prints, which is I-rate, but it's a k-rate if statement. Try using prints. 

On Sun, Nov 22, 2020, 8:59 AM Richard <zappfinger@gmail.com> wrote:
I am using the following code:

instr 11
Sgm chnget "GM"
kgm changed Sgm
printk2 kgm
if (kgm==1) then
     prints "%s", Sgm
endif
endin

When the string changes the output shows that kgm becomes 1, but
immediately becomes 0 again.
Printing of the string in the if block is not executed.

Why?

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

Date2020-11-22 16:25
FromRichard
SubjectRe: [Csnd] Detecting string change

It only works correctly if I put a delay after the chnget other wise the previous value is printed. It looks like the change after the chnget comes too soon.
Following code works:

instr 11
Spath chnget "GM"
printks "now.....%s",1,Spath    ;when this line is commented out, the change shows the previous value!
kgm changed Spath
printk2 kgm
if (kgm==1) then
    printks "in if...%s",1, Spath
endif
endin

On 22/11/2020 15:16, Dave Seidel wrote:
I think because you're using prints, which is I-rate, but it's a k-rate if statement. Try using prints. 

On Sun, Nov 22, 2020, 8:59 AM Richard <zappfinger@gmail.com> wrote:
I am using the following code:

instr 11
Sgm chnget "GM"
kgm changed Sgm
printk2 kgm
if (kgm==1) then
     prints "%s", Sgm
endif
endin

When the string changes the output shows that kgm becomes 1, but
immediately becomes 0 again.
Printing of the string in the if block is not executed.

Why?

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