Reinitialize instruments in real time
In the following code, we have a control variable used to star reproducing a sample (if gkControl is 1) and stop reproducing if gkControl is 2 here is where we want to reinitialize the state of the opcode diskin or others like pluck, line, linen, etc. How can we do that?
<CsoundSynthesizer>
<CsOptions>
-o dac -+rtaudio=alsa
</CsOptions>
<CsInstruments>
sr = 44100
kr = 4410
ksmps = 10
nchnls = 2
gkcontrol init 0
instr 1
gkcontrol chnget "sample"
if gkcontrol == 1 then
a1,a2 diskin "rep1.wav", 1, 0, 1, 0, 100
outs a1, a2
endif
if gkcontrol == 2 then
;Reiniciar
endif
endin
instr 2
gkcontrol = p4
printk2 gkcontrol
endin
</CsInstruments>
<CsScore>
;reproduccion todos los instrumentos
i1 0 100
i2 0 50 1
i2 50 50 2
</CsScore>
</CsoundSynthesizer>