Csound Csound-dev Csound-tekno Search About

[Csnd] question/confusion on dynamically creating control channels

Date2022-03-13 19:04
FromIain Duncan
Subject[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

Date2022-03-13 19:19
From"Jeanette C."
SubjectRe: [Csnd] question/confusion on dynamically creating control channels
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

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

You might think that I won't make it on my own,
But now I'm Stronger <3
(Britney Spears)

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

Date2022-03-13 21:03
FromIain Duncan
SubjectRe: [Csnd] question/confusion on dynamically creating control channels
thanks, I'll take a look at those examples!

On Sun, Mar 13, 2022 at 12:19 PM Jeanette C. <julien@mail.upb.de> wrote:
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

--
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

You might think that I won't make it on my own,
But now I'm Stronger <3
(Britney Spears)

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

Date2022-03-15 00:47
FromIain Duncan
SubjectRe: [Csnd] question/confusion on dynamically creating control channels
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

On Sun, Mar 13, 2022 at 2:03 PM Iain Duncan <iainduncanlists@gmail.com> wrote:
thanks, I'll take a look at those examples!

On Sun, Mar 13, 2022 at 12:19 PM Jeanette C. <julien@mail.upb.de> wrote:
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

--
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

You might think that I won't make it on my own,
But now I'm Stronger <3
(Britney Spears)

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

Date2022-03-15 01:35
FromEduardo Moguillansky
SubjectRe: [Csnd] question/confusion on dynamically creating control channels
On 13.03.22 20:04, Iain Duncan wrote:
> 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.

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

-- 
eduardo



> 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 

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

Date2022-03-15 06:59
From"Jeanette C."
SubjectRe: [Csnd] question/confusion on dynamically creating control channels
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

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

... About some useless information,
Supposed to fire my imagination <3
(Britney Spears)

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