Csound Csound-dev Csound-tekno Search About

Link decimal instruments with global variables?

Date2017-07-27 17:40
Fromlorangeverte
SubjectLink decimal instruments with global variables?
Hello Csound forum,

In case of two different instruments linked together with an audio global
variable, do you know a way to link their instances (decimal p1) with a
coherent strategy? 

I declare for exemple two global variables:

gaOs init 0


Then built an instrument and set her controls with sprintf

instr 1

iT =  (100*p1) % 10
SChannel1 sprintf "freq%d", iT
kcps chnget SChannel1

kamp = 0.2
asig oscil kamp, kcps, 1
gaOs += asig
endin

After that built for exemple an effect instrument with the same system

instr 2

iT =  (100*p1) % 10
SChannel2 sprintf "feed%d", iT
kfeedback chnget SChannel2

kdelL=120
kdelR=340
abuf2	delayr	1
adelL 	deltapi	a(kdelL) * 0.001		
	delayw	gaOs + (adelL * a(kfeedback))
abuf3	delayr	1
adelR 	deltapi  a(kdelR) * 0.001	
	delayw	gaOs + (adelR * a(kfeedback)) 
outch 1, adelL, 2, adelR
gaOs = 0

endin

I would like to active one instance of instrument 1, so i1.01, which will
correspond to a "reciprocal" instance of instrument 2, so i2.01... In this
system, i1.02 will be corresponding to i2.02. 
Unfortunately, when I active i1.02, I don't arrive to active i2.02,  and I
don't know exactly why...  Just controls of i2.01 are available but my goal
is to can set per instance of i1 the controls of relative i2 instances...

Could you help me, please?

Regards,

Lorangeverte







--
View this message in context: http://csound.1045644.n5.nabble.com/Link-decimal-instruments-with-global-variables-tp5757337.html
Sent from the Csound - General mailing list archive at Nabble.com.

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

Date2017-07-27 18:14
FromJohn ff
SubjectRe: Link decimal instruments with global variables?
Use a global array indexed by the fractional part times 100 perhaps.

Sent from TypeApp
On 27 Jul 2017, at 17:41, lorangeverte <sosa.jeanbasile@GMAIL.COM> wrote:
Hello Csound forum,

In case of two different instruments linked together with an audio global
variable, do you know a way to link their instances (decimal p1) with a
coherent strategy?

I declare for exemple two global variables:

gaOs init 0


Then built an instrument and set her controls with sprintf

instr 1

iT = (100*p1) % 10
SChannel1 sprintf "freq%d", iT
kcps chnget SChannel1

kamp = 0.2
asig oscil kamp, kcps, 1
gaOs += asig
endin

After that built for exemple an effect instrument with the same system

instr 2

iT = (100*p1) % 10
SChannel2 sprintf "feed%d", iT
kfeedback chnget SChannel2

kdelL=120
kdelR=340
abuf2 delayr 1
adelL deltapi a(kdelL) * 0.001
delayw gaOs + (adelL * a(kfeedback))
abuf3 delayr 1
adelR deltapi a(kdelR) * 0.001
delayw gaOs + (adelR * a(kfeedback))
outch 1, adelL, 2, adelR
gaOs = 0

endin

I would like to active one instance of instrument 1, so i1.01, which will
correspond to a "reciprocal" instance of instrument 2, so i2.01... In this
system, i1.02 will be corresponding to i2.02.
Unfortunately, when I active i1.02, I don't arrive to active i2.02, and I
don't know exactly why... Just controls of i2.01 are available but my goal
is to can set per instance of i1 the controls of relative i2 instances...

Could you help me, please?

Regards,

Lorangeverte







--
View this message in context: http://csound.1045644.n5.nabble.com/Link-decimal-instruments-with-global-variables-tp5757337.html
Sent from the Csound - General mailing list archive at Nabble.com.

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

Date2017-07-27 23:09
Fromjoachim heintz
SubjectRe: Link decimal instruments with global variables?
hi lorangverte -

not sure i understand your code, but i think the problem might be that 
you send the audio from all instances via the same global variable.  but 
you need two (three, four, ...) separate variables for the two (three, 
four, ...) instances.

this can be done with the same technique you already use for control 
channels.  i paste a simple example below; maybe it helps to find your 
solution.

best -
	joachim




-odac -m128


sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
seed 0

;set a global counter
giInstance init 1

instr 1

;audio channel to communicate with the appropriate instance of instr 2
S_chn sprintf "audio_%d", giInstance

;print who am i
prints "instance %d of instr 1 called\n", giInstance

;send some audio
aSig poscil .2, random:i(400,800)
chnset aSig, S_chn

;call instr 2
schedule 2, 0, p3, giInstance

;now increase the counter (for the next instance)
giInstance += 1

endin

instr 2

;get instance number
iInstance = p4

;create channel name
S_chn sprintf "audio_%d", iInstance

;print who am i
prints "  instance %d of instr 2 called\n", iInstance

;receive audio and put out
aRec chnget S_chn
aOut linen aRec, p3/10, p3, p3/2
aL, aR pan2 aOut, random:i(0,1)
out aL, aR

endin



i 1 0 10
i 1 1 3
i 1 2 4






On 27/07/17 18:40, lorangeverte wrote:
> Hello Csound forum,
>
> In case of two different instruments linked together with an audio global
> variable, do you know a way to link their instances (decimal p1) with a
> coherent strategy?
>
> I declare for exemple two global variables:
>
> gaOs init 0
>
>
> Then built an instrument and set her controls with sprintf
>
> instr 1
>
> iT =  (100*p1) % 10
> SChannel1 sprintf "freq%d", iT
> kcps chnget SChannel1
>
> kamp = 0.2
> asig oscil kamp, kcps, 1
> gaOs += asig
> endin
>
> After that built for exemple an effect instrument with the same system
>
> instr 2
>
> iT =  (100*p1) % 10
> SChannel2 sprintf "feed%d", iT
> kfeedback chnget SChannel2
>
> kdelL=120
> kdelR=340
> abuf2	delayr	1
> adelL 	deltapi	a(kdelL) * 0.001		
> 	delayw	gaOs + (adelL * a(kfeedback))
> abuf3	delayr	1
> adelR 	deltapi  a(kdelR) * 0.001	
> 	delayw	gaOs + (adelR * a(kfeedback))
> outch 1, adelL, 2, adelR
> gaOs = 0
>
> endin
>
> I would like to active one instance of instrument 1, so i1.01, which will
> correspond to a "reciprocal" instance of instrument 2, so i2.01... In this
> system, i1.02 will be corresponding to i2.02.
> Unfortunately, when I active i1.02, I don't arrive to active i2.02,  and I
> don't know exactly why...  Just controls of i2.01 are available but my goal
> is to can set per instance of i1 the controls of relative i2 instances...
>
> Could you help me, please?
>
> Regards,
>
> Lorangeverte
>
>
>
>
>
>
>
> --
> View this message in context: http://csound.1045644.n5.nabble.com/Link-decimal-instruments-with-global-variables-tp5757337.html
> Sent from the Csound - General mailing list archive at Nabble.com.
>
> 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

Date2017-07-28 12:45
Fromlorangeverte
SubjectRe: Link decimal instruments with global variables?
Hi Joachim,

many thanks for your tips and code, my problem is solved, everything now
works perfectly! 
(Maybe the bizarre behavior of my exemple code come from reason that I'm a
csound~ user... I don't know... Bref, many thanks again Joachim!).

Best regards,

Lorangeverte




--
View this message in context: http://csound.1045644.n5.nabble.com/Link-decimal-instruments-with-global-variables-tp5757337p5757350.html
Sent from the Csound - General mailing list archive at Nabble.com.

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

Date2017-07-28 20:16
Fromjoachim heintz
SubjectRe: Link decimal instruments with global variables?
thanks - good to know you could use it.
bye -
	j


On 28/07/17 13:45, lorangeverte wrote:
> Hi Joachim,
>
> many thanks for your tips and code, my problem is solved, everything now
> works perfectly!
> (Maybe the bizarre behavior of my exemple code come from reason that I'm a
> csound~ user... I don't know... Bref, many thanks again Joachim!).
>
> Best regards,
>
> Lorangeverte
>
>
>
>
> --
> View this message in context: http://csound.1045644.n5.nabble.com/Link-decimal-instruments-with-global-variables-tp5757337p5757350.html
> Sent from the Csound - General mailing list archive at Nabble.com.
>
> 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