[Csnd] Is it possible to set initial value to channel?

Hi, there)

Is it possible to init a named channel with an initial value?

I’ve tried to use chnset with i-rate value,
but when later I try to write a-rate signal to it, the compiler
complains that thisname is already used at a different rate.

Is there some workaround?

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

hi anton -

this is a workaround:

chn_a("bla",3)

instr Init
   chnset(a(1),"bla")
   turnoff
endin
schedule("Init",0,1)

instr Test
   aBla = chnget:a("bla")
   printk2(k(aBla))
endin
schedule("Test",0,1)

perhaps on the long run init could be extended to do this job.

best -
  joachim

Hi Joachim
Thank you for this trick. I will try it out.

вт, 7 февр. 2023 г. в 14:07, joachim heintz <jh@joachimheintz.de>:

hi anton -

this is a workaround:

chn_a(“bla”,3)

instr Init
chnset(a(1),“bla”)
turnoff
endin
schedule(“Init”,0,1)

instr Test
aBla = chnget:a(“bla”)
printk2(k(aBla))
endin
schedule(“Test”,0,1)

perhaps on the long run init could be extended to do this job.

best -
joachim

Hi, there)

Is it possible to init a named channel with an initial value?

I’ve tried to use chnset with i-rate value,
but when later I try to write a-rate signal to it, the compiler
complains that thisname is already used at a different rate.

Is there some workaround?
Csound mailing list Csound@listserv.heanet.ie
mailto:[Csound@listserv.heanet.ie](mailto:Csound@listserv.heanet.ie)
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
<https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send bugs reports to
https://github.com/csound/csound/issues
<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

Actually I can not use this trick because I don’t know in advance the name of the channel.
I use them to pass signals between instruments and to keep the channels unique between several instances
of the same instrument. I use an ever increasing counter to generate fresh names for channels.

So the names for channels are not fixed.

вт, 7 февр. 2023 г. в 19:57, Anton Kholomiov <anton.kholomiov@gmail.com>:

Hi Joachim
Thank you for this trick. I will try it out.

вт, 7 февр. 2023 г. в 14:07, joachim heintz <jh@joachimheintz.de>:

hi anton -

this is a workaround:

chn_a(“bla”,3)

instr Init
chnset(a(1),“bla”)
turnoff
endin
schedule(“Init”,0,1)

instr Test
aBla = chnget:a(“bla”)
printk2(k(aBla))
endin
schedule(“Test”,0,1)

perhaps on the long run init could be extended to do this job.

best -
joachim

Hi, there)

Is it possible to init a named channel with an initial value?

I’ve tried to use chnset with i-rate value,
but when later I try to write a-rate signal to it, the compiler
complains that thisname is already used at a different rate.

Is there some workaround?
Csound mailing list Csound@listserv.heanet.ie
mailto:[Csound@listserv.heanet.ie](mailto:Csound@listserv.heanet.ie)
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
<https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send bugs reports to
https://github.com/csound/csound/issues
<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

but how do you want to set an initial value to a channel whichs name you don't know?
if you create the names dynamically, it should be possible to do it in a similar way, with sprintf.

Steven Yi’s ‘xchan’ UDO might be of use. You may have to make an arate version, but it should be fine.

https://github.com/kunstmusik/csound-live-code/blob/main/livecode.orc#L801-L810

Thanks, I see it’s nice ide with i-rate update on 0 value, maybe I can use it.
And also explicit query of chnget to work at rate.
I was not aware of that feature. I mean this chnget:rate that Steven uses in the code

сб, 11 февр. 2023 г. в 14:09, thorin kerr <thorin.kerr@gmail.com>:

Steven Yi’s ‘xchan’ UDO might be of use. You may have to make an arate version, but it should be fine.

https://github.com/kunstmusik/csound-live-code/blob/main/livecode.orc#L801-L810

Actually I can not use this trick because I don’t know in advance the name of the channel.
I use them to pass signals between instruments and to keep the channels unique between several instances
of the same instrument. I use an ever increasing counter to generate fresh names for channels.

So the names for channels are not fixed.

вт, 7 февр. 2023 г. в 19:57, Anton Kholomiov <anton.kholomiov@gmail.com>:

Hi Joachim
Thank you for this trick. I will try it out.

вт, 7 февр. 2023 г. в 14:07, joachim heintz <jh@joachimheintz.de>:

hi anton -

this is a workaround:

chn_a(“bla”,3)

instr Init
chnset(a(1),“bla”)
turnoff
endin
schedule(“Init”,0,1)

instr Test
aBla = chnget:a(“bla”)
printk2(k(aBla))
endin
schedule(“Test”,0,1)

perhaps on the long run init could be extended to do this job.

best -
joachim

Hi, there)

Is it possible to init a named channel with an initial value?

I’ve tried to use chnset with i-rate value,
but when later I try to write a-rate signal to it, the compiler
complains that thisname is already used at a different rate.

Is there some workaround?
Csound mailing list Csound@listserv.heanet.ie
mailto:[Csound@listserv.heanet.ie](mailto:Csound@listserv.heanet.ie)
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
<https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send bugs reports to
https://github.com/csound/csound/issues
<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