void flex_keyOn(int noteProgram, int data1, int data2) { long voiceNr = DSP->keyOn(data1,data2); //play the note with existing settings //alternative is to set gain to zero DSP->setVoiceParamValue("/WaveSynth_FX/gate", voiceNr,0); //switch it off immediately loadPreset(noteProgram, voiceNr); //update voice params with parameters stored in a set indicated by noteProgram (channel dependent) //DSP->setVoiceParamValue("/WaveSynth_FX/gain", voiceNr,data2); //repair gain, how to translate velocity (data2) to gain? DSP->setVoiceParamValue("/WaveSynth_FX/gate", voiceNr,1); //switch it on with the new settings } //flex_keyOn;