Csound Csound-dev Csound-tekno Search About

[Csnd] Using FLTK slider as instrument dispatcher

Date2013-05-15 19:35
FromMark Brophy
Subject[Csnd] Using FLTK slider as instrument dispatcher
I want to select an instrument using an FLTK slider as follows:


<CsInstruments>

sr = 44100

kr = 441

ksmps = 100

nchnls = 2


gisine ftgen 0, 0, 65536, 10, 1

gielectro ftgen 0, 0, 65536, 10, 50, 100, 20, 20, 20


FLpanel "Dispatcher", 300, 300, 450, 300

gkInstrument, ihndInstrument FLcount "Instrument", 0, 1, 1, 1, 2, 150, 40, 30, 30, -1

gkts1, ihts1 FLbutton "Play", 0, 0, 1, 80, 35, 30, 100, 0, 122, 0, 8

FLpanel_end

FLrun


instr 95

aenv expseg 0.001, 0.01, 1, p3 - 0.01, 0.001

a1 oscili aenv, 165, gisine

out 20000 * a1, 20000 * a1

endin


instr 96

aenv expseg 0.001, 0.01, 1, p3 - 0.01, 0.001

a1 oscili aenv, 165, gielectro

out 20000 * a1, 20000 * a1

endin


instr 122

if (gkInstrument == 0) then

event_i "i", 95, 0, 1

else

event_i "i", 96, 0, 1

endif

endin


</CsInstruments>


Why does the code always invoke instrument 95 even when the user sets the slider to 1? What can I do to fix this?