I am trying to make a simple keyboard that plays SoundFont sounds on unity.
Since Csound is new to me, I created the following as a test.
instr PlayOrStop kStart chnget "start" if changed(kStart) == 1 then event "i", "SoundFont", 0, -1, gkNote, gkVel endif kStop chnget "stop" if changed(kStop) == 1 then event "i", "SoundFont", 0, 0, gkNote, 0 endif endin instr SoundFont mididefault 60, p3 midinoteonkey p4, p5 inum init p4 ivel init p5 ivel init ivel/127 kamp linsegr 1, 1, 1, 0.5, 0 ;envelope kamp = kamp/3000 kfreq init 1 a1,a2 sfplay3 ivel, inum, kamp*ivel, kfreq, 0 outs a1, a2 endin
When you press PlaySound, the sound is played, StopSound will stop the sound.
The problem is that when I press StopSound, the sound immediately disappears and the release time that I should have set in SoundFont does not work. (Of course, this is because the vericity is zero.)
For example, what event should I issue to make the sound release over 0.5 seconds?
Thanks in advance.