ignore_event()
Drops the given event and thus prevents the supplied event to be further processed by the sampler. You can use this function i.e. to filter out MIDI note on and MIDI note off events, before they are causing new notes to be triggered, or to drop certain MIDI control change events before they can cause any sound to be changed.
The argument this function takes is optional. If you omit passing an
argument to this function, then the event ID will be used that
caused this current event handler to be executed
(which is $EVENT_ID
).
Dropping events with this function only succeeds if the event just
"recently" occurred. That effectively means you should drop the event in
the respective event handler before any wait()
calls, and before
entering any loops that may execute your script for a very long time.
Because in both cases the sampler may suspend your script for a certain
amount of time and once your script got resumed, the respective event may
already have entered the sampler's regular event processing chain and
thus can no longer be dropped.
There is also an ignore_controller()
function,
intended for explicitly dropping control change events. With NKSP you
you can also use ignore_event()
though to
drop control change events. So ignore_controller()
merely exists due to compatibility reasons with KSP.
Function Prototype
ignore_event([event-id])
Arguments
Argument Name | Data Type | Description |
---|---|---|
event-id |
Event ID Number or Event ID Array | Event ID(s) of the MIDI event(s) to be dropped. [optional, default: ID of the event handler's event] |
Return Value
None.
Examples
The following example implements a simple split point behavior for your sound. It only plays notes starting at C5, all note-on events below C5 will be dropped.
- on init
- { MIDI note number for "C5" }
- declare const $splitPoint := 60
- end on
- on note
- if ($EVENT_NOTE < $splitPoint)
- { $EVENT_ID is a built-in variable which always reflects the ID of the event which caused the execution of this specific event handler instance, i.e. here it reflects the respective MIDI note-on event }
- ignore_event($EVENT_ID)
- end if
- end on
Since you are almost always passing $EVENT_ID
to ignore_event()
,
you can also omit that optional argument with NKSP. So the following
would behave identical with the example above.
- on init
- { MIDI note number for "C5" }
- declare const $splitPoint := 60
- end on
- on note
- if ($EVENT_NOTE < $splitPoint)
- ignore_event()
- end if
- end on
Same applies to the optional argument: Dynamic, optional arguments are only supported by NKSP. If you want to retain compatibility to KSP, then you should always pass a parameter to this function.