Link decimal instruments with global variables?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Link decimal instruments with global variables?

lorangeverte
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



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd] Link decimal instruments with global variables?

jpff
Use a global array indexed by the fractional part times 100 perhaps.

Sent from TypeApp
On 27 Jul 2017, at 17:41, lorangeverte <[hidden email]> 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
[hidden email]
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 [hidden email] 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd] Link decimal instruments with global variables?

joachim-3
In reply to this post by lorangeverte
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


<CsoundSynthesizer>
<CsOptions>
-odac -m128
</CsOptions>
<CsInstruments>
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

</CsInstruments>
<CsScore>
i 1 0 10
i 1 1 3
i 1 2 4
</CsScore>
</CsoundSynthesizer>




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
> [hidden email]
> 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
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd] Link decimal instruments with global variables?

lorangeverte
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd] Link decimal instruments with global variables?

joachim-3
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
> [hidden email]
> 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
[hidden email]
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
Loading...