To get instrument 98 working you need to rearrange some of those chnset
stuff so it falls through to the default values at i-time.
; I also though this one would work too... guess not.
instr 98
kTrig chnget "but1"
if(changed(kTrig)==1) then
; I guess stating kTrig==0 first doesn't work correctly?
if(kTrig==1) then
chnset "visible(0)", "sliders1"
chnset "visible(1)", "sliders2"
else
chnset "visible(1)", "sliders1"
chnset "visible(0)", "sliders2"
endif
endif
endin
My understanding is that string channels are a little odd in Csound. Technically strings are i-rate, so Csound will assume i-rate channels are being used when strings are passed to chnset
.
instr 97
is an interesting one.
; I thought this one would work, not sure offhand why it didn't.
instr 97
kTrig chnget "but1"
if(changed(kTrig)==1) then
Smessage sprintfk "visible(%d)", kTrig==0 ? 1 : 0
chnset Smessage, "sliders2"
Smessage sprintfk "visible(%d)", kTrig==1 ? 1 : 0
chnset Smessage, "sliders1"
endif
endin
It works but only after the first button press. In this case you are modifying a string at k-time and then passing that string to chnset. As far as I understand it, Smessage
will not contain any valid string data until we are in k-time. So these channels are initially empty.
And finally, there is another way to do this.
instr 96
kTrig chnget "but1"
SStr[] init 4
SStr[0] = "sliders1"
SStr[1] = "sliders2"
SStr[2] = "visible(1)"
SStr[3] = "visible(0)"
if(changed(kTrig)==1) then
chnset SStr[2+kTrig], SStr[0]
chnset SStr[2+(kTrig == 1 ? 0 : 1)], SStr[1]
endif
endin