[Csnd] question/confusion on dynamically creating control channels

Hi all, I am trying to figure out how I can have a score event (or API message) to the csound instance in my csound6~ Max object trigger the creation and update of a control channel, where that control channel itself is chosen from the event. As in, a message to csound~ could create a (for example) envelope process for some amount of time, but outputting to a specific named control channel. Ideally, the named channel springs into existence on this message, but if I had to send a separate msg to create it, that would be ok too. I’m trying to avoid the user having to precreate the named channel in the orc header, but I’m not clear whether that is possible. If anyone has suggestions, that would be great. Also, if this is going to improve somehow or another in csound7, that would be good to know too in case it means it’s not worth trying to get working in csound6.

Some things that confused me:

  • the manual entries for chnset mention declaring channels with chn_k, but the csd examples in chnset do not include this
  • the API has functions for setting, reading, and listing named channels, but doesn’t seem to have a function for declaring one, is there a different way?
  • I’m also wondering if the channel name used in chnset can be a string variable, and if, can it come from a pfield?

thanks!
iain

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

Mar 13 2022, Iain Duncan has written:

Hi all, I am trying to figure out how I can have a score event (or API
message) to the csound instance in my csound6~ Max object trigger the
*creation* and update of a control channel, where that control channel
itself is chosen from the event.

...
Hi Iain,
I'm always working from within Csound, but I used dynamic channel
creation a lot.

String variables received through instrument's p-fileds are fine. To be
on the safe side, I think this still applies, use strget(psomething)
inside the instrument. You can even used received strings or typed in
names in concatenation strcat and related to create further specified
names.

You can find examples of that in the JBSO object system:
http://juliencoder.de/sound/jbso-1.1.zip
or in a slightly easier structure in samplebank:
http://juliencoder.de/sound/m_samplebank-1.0.zip

From Steven Yi I adopted the concept of systematic names, something
like:
Sname = strcat("MySynth.Envelope.", SmyDynamicID)
Easier to avoid name clashes and wiht some trickery perhaps even keep
score of your created channels, which is part of the idea behind JBSO,
to create kind of objects, as in object oriented programming, and manage
them.

HTH.

Best wishes,

Jeanette

thanks, I’ll take a look at those examples!

Hi Jeanette, that was helpful and I got what I needed going. This is going to be a killer addition to Max, I’ve cooked up a much improved output channel facility.

I thought you might like to know though that the links you posted were not working for me for some reason. The browser (Chrome on Mac) tries to open them and just closes instantly. Not sure what is up.

iain

csoundGetChannelPtr will create a channel if it does not exist (this is documented in the API). Once you have the pointer you can set the value directly (this is not threadsafe, see also csoundGetChannelLock) or use csoundSetControlChannel

Hi Iain,
I'm very glad that your challenge is mastered.
Mar 15 2022, Iain Duncan has written:
...

I thought you might like to know though that the links you posted were not
working for me for some reason. The browser (Chrome on Mac) tries to open
them and just closes instantly. Not sure what is up.

...
I've heard something like that before about links I post to my website.
The links are fine, but the website is http not https, i.e. "insecure".
Just out of curiosity, could you try to open the index:
http://juliencoder.de

Best wishes,

Jeanette