Hey there,
how do I create a script for choking oneshots from my sampler?
(The usual approaches that I saw on the forum where noteOff commands which won't work once the oneshot got played)
Also I am using one sampler engine so I would work with keytriggers that cancel each other or sth. if Note 70 is played then cut 66
// Use const var for constants for improved performance.
const var closeHiHatKey = 48;
const var openHiHatKey = 58;
// An Array is also a constant, even if it will be populated later on
const var evtList = [];
// make sure it has enough storage to avoid allocation during the noteOn callback
evtList.reserve(64);
function onNoteOn()
{
if(Message.getNoteNumber() == closeHiHatKey)
{
// Always use the for ... in loop if you don't need the index
for(eventId in evtList)
{
// Send the note off command for the given event id
Synth.noteOffByEventId(eventId);
}
// Clear all notes
evtList.clear();
}
else if (Message.getNoteNumber() == openHiHatKey)
{
// This is necessary because you will kill the note artificially and HISE
// can only kill artifical notes for stability reasons
Message.makeArtificial();
// Add this ID to the list (it'll add the artificial event ID)
evtList.push(Message.getEventId());
}
}
function onNoteOff()
{
if(Message.getNoteNumber() == openHiHatKey)
{
// We need to ignore the note-off message
// for the open hi-hat so it will keep ringing...
Message.ignoreEvent(true);
}
}
function onController()
{
}
function onTimer()
{
}
function onControl(number, value)
{
}