Csound Csound-dev Csound-tekno Search About

[Csnd] "Udo for chnset" problem

Date2019-10-28 13:01
FromJean Basile Sosa
Subject[Csnd] "Udo for chnset" problem
Hello all,

I am trying to write a generic and basic instrument which will read channels
control declared in other instruments and pass them into p-fields line score
as well. 

In this way I would like to change control paramaters of a given instrument
without to have to init it again when parameters change during the
performance.

The udo attached to instr 2 does not work while instr 3 shows the excepted
result.  
Of course in my case a declaration of all chnset one by one is not a good
strategy because each instrument  has a different and variable number of
control parameters.

When instr 2 is playing I receive the famous following Init error : "channel
already exists with incompatible type"

I have tried to replace sprintf with sprintfk and to convert old syntaxe to
the new functional but without result.

Could you tell me what is wrong in my code and help me to achieve my goal ? 

Best,

Jean Basile

opcode ctrl,  0, iSiSi
imax, S_pchamp, index, S_name, index xin
loop: 
S_p sprintf "%s%d", S_pchamp, index+3
S_ctrl sprintf "%s%d", S_name, index
chnset S_p, S_ctrl
puts S_p,1
puts S_ctrl, 1
loop_lt index, 1, imax+1, loop
endop

instr 1

chnset p4, "ctrl_1"
kamp chnget "ctrl_1"
chnset p5, "ctrl_2"
kcps chnget "ctrl_2"

asig oscil kamp , kcps, 1
     outs asig,asig
endin 

instr 2 ; 

index = 1

ctrl 2, "p", index, "ctrl_", index ; init error

endin

instr 3 ; excepted result

chnset p4, "ctrl_1" 
chnset p5, "ctrl_2" 

endin




f1 0 16384 10 1                                        

i1 0 6 0.1 100
i2 2 1  0.1 120
i3 4 1  0.1 120



 




--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

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

Date2019-10-28 13:23
Fromjoachim heintz
SubjectRe: [Csnd] "Udo for chnset" problem
hello jean basile -

i think there is one basic mistake.  csound's p4 is not a string.  so 
you cannot work with sprintf here, to produce the output p4.

perhaps you can describe as a simple example what you want to do.  i am 
pretty sure it is not too complicated, but the means to get there are 
different from what you tried.

best -
	joachim



On 28/10/19 14:01, Jean Basile Sosa wrote:
> Hello all,
>
> I am trying to write a generic and basic instrument which will read channels
> control declared in other instruments and pass them into p-fields line score
> as well.
>
> In this way I would like to change control paramaters of a given instrument
> without to have to init it again when parameters change during the
> performance.
>
> The udo attached to instr 2 does not work while instr 3 shows the excepted
> result.
> Of course in my case a declaration of all chnset one by one is not a good
> strategy because each instrument  has a different and variable number of
> control parameters.
>
> When instr 2 is playing I receive the famous following Init error : "channel
> already exists with incompatible type"
>
> I have tried to replace sprintf with sprintfk and to convert old syntaxe to
> the new functional but without result.
>
> Could you tell me what is wrong in my code and help me to achieve my goal ?
>
> Best,
>
> Jean Basile
>
> opcode ctrl,  0, iSiSi
> imax, S_pchamp, index, S_name, index xin
> loop:
> S_p sprintf "%s%d", S_pchamp, index+3
> S_ctrl sprintf "%s%d", S_name, index
> chnset S_p, S_ctrl
> puts S_p,1
> puts S_ctrl, 1
> loop_lt index, 1, imax+1, loop
> endop
>
> instr 1
>
> chnset p4, "ctrl_1"
> kamp chnget "ctrl_1"
> chnset p5, "ctrl_2"
> kcps chnget "ctrl_2"
>
> asig oscil kamp , kcps, 1
>      outs asig,asig
> endin
>
> instr 2 ;
>
> index = 1
>
> ctrl 2, "p", index, "ctrl_", index ; init error
>
> endin
>
> instr 3 ; excepted result
>
> chnset p4, "ctrl_1"
> chnset p5, "ctrl_2"
>
> endin
>
> 
> 
>
> f1 0 16384 10 1
>
> i1 0 6 0.1 100
> i2 2 1  0.1 120
> i3 4 1  0.1 120
>
> 
>
> 
>
>
>
>
> --
> Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html
>
> 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

Date2019-10-28 14:49
FromVictor Lazzarini
SubjectRe: [Csnd] "Udo for chnset" problem
In your UDO, chnset sets the value of a string channel (Svar is used); in instr 3, you
are setting the value of a numeric (ivar, kvar)
channel (at init-time).

So it's a different type of bus channel. If you want what you have in instr 3, don't use an Svar as the first arg to chnset.

Prof. Victor Lazzarini
Maynooth University
Ireland

> On 28 Oct 2019, at 12:50, Jean Basile Sosa  wrote:
> 
> Hello all,
> 
> I am trying to write a generic and basic instrument which will read channels
> control declared in other instruments and pass them into p-fields line score
> as well. 
> 
> In this way I would like to change control paramaters of a given instrument
> without to have to init it again when parameters change during the
> performance.
> 
> The udo attached to instr 2 does not work while instr 3 shows the excepted
> result.  
> Of course in my case a declaration of all chnset one by one is not a good
> strategy because each instrument  has a different and variable number of
> control parameters.
> 
> When instr 2 is playing I receive the famous following Init error : "channel
> already exists with incompatible type"
> 
> I have tried to replace sprintf with sprintfk and to convert old syntaxe to
> the new functional but without result.
> 
> Could you tell me what is wrong in my code and help me to achieve my goal ? 
> 
> Best,
> 
> Jean Basile
> 
> opcode ctrl,  0, iSiSi
> imax, S_pchamp, index, S_name, index xin
> loop: 
> S_p sprintf "%s%d", S_pchamp, index+3
> S_ctrl sprintf "%s%d", S_name, index
> chnset S_p, S_ctrl
> puts S_p,1
> puts S_ctrl, 1
> loop_lt index, 1, imax+1, loop
> endop
> 
> instr 1
> 
> chnset p4, "ctrl_1"
> kamp chnget "ctrl_1"
> chnset p5, "ctrl_2"
> kcps chnget "ctrl_2"
> 
> asig oscil kamp , kcps, 1
>     outs asig,asig
> endin 
> 
> instr 2 ; 
> 
> index = 1
> 
> ctrl 2, "p", index, "ctrl_", index ; init error
> 
> endin
> 
> instr 3 ; excepted result
> 
> chnset p4, "ctrl_1" 
> chnset p5, "ctrl_2" 
> 
> endin
> 
> 
> 
> 
> f1 0 16384 10 1                                        
> 
> i1 0 6 0.1 100
> i2 2 1  0.1 120
> i3 4 1  0.1 120
> 
> 
> 
>  
> 
> 
> 
> 
> --
> Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html
> 
> 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

Date2019-10-28 18:06
FromJean Basile Sosa
SubjectRe: [Csnd] "Udo for chnset" problem
Thank you Joachim and Victor.
 
Indeed it was a real mistake to set a p-field of a string variable... Thank
you for your explanations!

Yes Joachim what I want to write is certainly very simple but I missing
something to finish the Udo.

In fact, this Udo should to allow a generic instrument to receive and set
control parameters of other.

By the use of this instrument I want to write automation of parameters
directly in the score; for example, one instance of an instrument is playing
during 20 seconds, and after 3 seconds of the performance, frequency,
amplitude, filter coefficient (never mind) change without new initialization
of the instrument. 

There is surely many ways to do that, and of course it works if I declare
all parameters in orchestra and pass datas using numerous chnset (I think
that I have used in past event_i to achieve this goal).

I am not very comfortable with the Udo syntax yet, either to express those
kind of things (the same im my mother tongue, then, in English...)... 

Maybe have you some advices for me, opcodes suggestions or a part of the
manual to read more attentively ?

Thanks again,

Jean Basile



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

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

Date2019-10-29 03:11
Fromjoachim heintz
SubjectRe: [Csnd] "Udo for chnset" problem
it sounds to me that you need a good architecture of your instruments. 
perhaps you call in the score at different time one instrument which 
changes control parameters of another one.  like

instr Control_Filter_A
  iCenterFreq = p4
  chnset iCenterFreq, "Filter_A_CenterFreq"
endin

instr Filter_A
  kCenterFreq chnget "Filter_A_CenterFreq"
  ...
endin

(and in the score you can call the Control_Filter_A instrument several 
times.)

i have the impression that you don't need UDOs for your approach, but a 
clear plan about which instrument is doing which thing.

hope this helps, best -

	joachim



On 28/10/19 19:06, Jean Basile Sosa wrote:
> Thank you Joachim and Victor.
>
> Indeed it was a real mistake to set a p-field of a string variable... Thank
> you for your explanations!
>
> Yes Joachim what I want to write is certainly very simple but I missing
> something to finish the Udo.
>
> In fact, this Udo should to allow a generic instrument to receive and set
> control parameters of other.
>
> By the use of this instrument I want to write automation of parameters
> directly in the score; for example, one instance of an instrument is playing
> during 20 seconds, and after 3 seconds of the performance, frequency,
> amplitude, filter coefficient (never mind) change without new initialization
> of the instrument.
>
> There is surely many ways to do that, and of course it works if I declare
> all parameters in orchestra and pass datas using numerous chnset (I think
> that I have used in past event_i to achieve this goal).
>
> I am not very comfortable with the Udo syntax yet, either to express those
> kind of things (the same im my mother tongue, then, in English...)...
>
> Maybe have you some advices for me, opcodes suggestions or a part of the
> manual to read more attentively ?
>
> Thanks again,
>
> Jean Basile
>
>
>
> --
> Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html
>
> 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

Date2019-10-31 12:56
FromJean Basile Sosa
SubjectRe: [Csnd] "Udo for chnset" problem
Hello Joachim,

I continued to explore a way to achieve a result before to answer you.

First thanks for your help and  advises. 
A csounder friend of me gave me a quickly help to write the udo that I
described. 
We both agree that it will be preferable that I’ll work with array.

I don’t know if it is very interesting or pertinent here but I would like to
give you an exemple as you asked me.
My syntaxe is very complicated because I use several langage : csound and
csound~, antescofo, java script in max, max patching… My goal is just to
translate in “true” csound score syntax my old antescofo files.

There is just one and simple instrument in the csd attached but in the
second audio exemple several instruments all instanced are played. 
In this second exemple, trust me the score is more complicated… 
In fact, csound via csound~ is sequenced in real time in Max environment,
than datas can be organised in time with antescofo… The conversion depends
to java script (in max as well).

Have a good day and thanks again Joachim,

Best

Jean Basile

example_00.csd
  

the audio link : 
http://file:///Users/jeanbasilesosa/Documents/example/exemple.html
  



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

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

Date2019-10-31 20:12
Fromjoachim heintz
SubjectRe: [Csnd] "Udo for chnset" problem
hi -

good to know you found a solution.  this looks really complicated!

thanks for letting us see it --- can certainly be instructive for people 
working in similar workflows.

best -
	joachim



On 31/10/19 13:56, Jean Basile Sosa wrote:
> Hello Joachim,
>
> I continued to explore a way to achieve a result before to answer you.
>
> First thanks for your help and  advises.
> A csounder friend of me gave me a quickly help to write the udo that I
> described.
> We both agree that it will be preferable that I’ll work with array.
>
> I don’t know if it is very interesting or pertinent here but I would like to
> give you an exemple as you asked me.
> My syntaxe is very complicated because I use several langage : csound and
> csound~, antescofo, java script in max, max patching… My goal is just to
> translate in “true” csound score syntax my old antescofo files.
>
> There is just one and simple instrument in the csd attached but in the
> second audio exemple several instruments all instanced are played.
> In this second exemple, trust me the score is more complicated…
> In fact, csound via csound~ is sequenced in real time in Max environment,
> than datas can be organised in time with antescofo… The conversion depends
> to java script (in max as well).
>
> Have a good day and thanks again Joachim,
>
> Best
>
> Jean Basile
>
> example_00.csd
> 
>
> the audio link :
> http://file:///Users/jeanbasilesosa/Documents/example/exemple.html
> 
>
>
>
> --
> Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html
>
> 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