In a MIDI instrument I’m working on, I’ve been trying to implement a “kill button” of sorts that terminates any notes that are currently being played. I’ve figured that this effect would be useful to have when I’m initializing a patch or switching through presets. While using
turnoff2 to attempt to do this, I’ve found that events are only turned off if they are currently being sustained as the “button” is pressed. If I set notes to have a long release, and I press the terminate button during the release state of a note,
turnoff2 have no effect, and the note keeps “releasing”. Why is this the case, and is there a way to turn off events that are in their release state?
Here is some code for reference. I’m using Cabbage to create my instrument, so the Cabbage widgets are what any of the
chngets are reading from.
turnoff2 in a separate, always-running instr to try to turn off any events in a MIDI-receiving instr:
gkinit chnget "Init" if (changed2(gkinit) == 1) then event "i", 1003, 0, .1 ;call instr that initializes all widgets turnoff2 10, 8, 0.02 ;attempt to turn off all instances of MIDI-receiving instr endif
turnoff within the MIDI-receiving instr itself:
gkinit chnget "Init" if (changed2(gkinit) == 1) then event "i", 1003, 0, .1 ;call instr that initializes all widgets turnoff ;turn off current instrument (MIDI instr) endif
Both of these methods only terminate notes that are being sustained (by my fingers on the controller), and any notes in their release state are ignored.