Post by Christian Schoenebeck"
on note
disallow_group($ALL_GROUPS) { turn all groups off }
allow_group(0) { turn first group on }
ignore_event($EVENT_ID) { inhibit triggering note from being
played } play_note($EVENT_NOTE, $EVENT_VELOCITY, 0, -1) { replay
note } end note
"
It's just a fragment, but yes, it seems like play_note can still
trigger the note and follow the 'note_on/note_off' of the note handler
itself.
Ok, since you say it is just a fragment of the overall code, I can just guess
that this technique might he used as an alternative for calling change_*()
functions for the triggered note.
I do see use cases which were not possible with our implementation of
play_note(), so I just implemented the following behavior changes of the
play_note() function:
* If -1 was passed for the "duration" argument and the parent note is already
gone (i.e. because of a previous call to ignore_event()) then play_note()
silently returns 0 as result value.
* Additionally I added a new special value -2 for argument "duration", which
essentially enables what you demonstrated.
Here the updated docs:
http://doc.linuxsampler.org/Instrument_Scripts/NKSP_Language/Reference/play_note_function/
Now I don't know Kontakt's precise behavior on this one, so I am not
absolutely sure whether these changes are optimal. But let me describe the use
cases for the two special values -1 and -2 and hence the reason why I think we
need both:
* Use case for duration = -1 :
------------------------------
on note
play_note($EVENT_NOTE+12, $EVENT_VELOCITY, -1, -1)
end on
This triggers an additional note (transposed upwards by one octave) each time
you trigger a key on the keyboard. In this case the new note has a different
note number, however you still want the new (transposed) note to be released
when a note-off event arrives on $EVENT_NOTE, not on $EVENT_NOTE+12. So the
new note's life time is sticked to its causing parent note.
In a more complex script of this use case, you might additionally have some
logic code afterwards which might drop the original (parent) note on certain
conditions, then also the already scheduled new (transposed) note should be
dropped automatically as well, which our current behavior does. So this is a
very handy feature in this case.
* Use case for duration = -2 :
------------------------------
on controller
declare $someNoteNr := 60
declare $someNoteVelocity := 127
...
if ($CC_NUM = 1)
play_note($someNoteNr, $someNoteVelocity, -1, -2)
end if
end on
This triggers a new note (i.e. with note number 60) when the modulation wheel
is used (MIDI CC#1), and sticks the life time of the new note to MIDI note/key
number 60. So those new voice(s) shall play until a MIDI note-off arrives on
MIDI note number 60.
As said, I don't know what Kontakt does exactly. It could be that Kontakt's
duration=-1 case is what we now have as duration=-2, and that they don't have
our duration=-1 behavior at all. Or their behavior could also be mix of our
two -1 and -2 cases, such a mix behavior is not desirable IMO though. Maybe
somebody can check what Kontakt really does here.
CU
Christian