how to make a simple note hold toggle?
-
Re: Retrigger On Release
I've been trying to figure out how to make a simple note hold toggle, but a bit at a loss as to where to filter note off midi messages. I did find this in the API doc for Engine:
void ignoreEvent ( bool shouldBeIgnored = true )
but not sure where or how to make use of it. Was thinking maybe in the noteOff callback but since that function defaults to blank I wasn't sure.In general I think it would be extremely useful if the built in scripts were editable so that they could be used as a reference / starting point.
-
@macromachines All of the built in scripts are available on github (they're in a C++ script but can easily be translated to HISE script).
What do you want to do exactly when you say a simple note hold toggle?
-
@d-healey the C++ scripts sound somewhat useful. My point was if they were provided in the same format as the editable scripts, they could function as examples / templates.
by Note Hold Toggle, I mean a switch that would disable note off events coming through.. essentially like a sustain pedal connected to a toggle button. Absynth has a feature like this and I use it all the time for sound designing.
-
I found this thread that might be helpful, but I cant figure out how to paste the snippet code :
https://forum.hise.audio/topic/243/mouse-modifier-to-click-keyboard-and-sustain-a-note -
Ok found this thread :
https://forum.hise.audio/topic/231/zero-effort-sustain-controllerlooks like Message.ignoreEvent(true); inside the onNoteOff function is what I was looking for.
-
Though is there maybe a way to bind a toggle button to the internal MIDI sustain handling?
-
Yes the ignoreEvent function is what you need. By bind to the internal MIDI sustain handling I assume you mean you want the sustain pedal to turn this feature on or off? If so just use the
Synth.isSustainPedalDown()
function in the on note off callback. You can also disable the default sustain pedal behavior in the on controller callback using ignoreEvent. -
@d-healey said in how to make a simple note hold toggle?:
Synth.isSustainPedalDown()
Cool, thats useful. So my initial thought that Synth was a general API class was correct.. I tried to see if there was some info on it in the API doc and I thought maybe it was specific to the synthesized waveform generators when I saw that there was also a Sampler class in the API.
Actually I was asking how I might bind an interface button to turn on and off the sustain pedal.
-
Actually I was asking how I might bind an interface button to turn on and off the sustain pedal.
inline function toggleSustain(component, value) { Synth.sendController(64, value ? 127 : 0); } SustainToggleButton.setControlCallback(toggleSustain);
-
@christoph-hart Thank you :D . I am curious, is the component input meant to be used in functions or is it only used by the callback definition to pass the component object internally?
-
Of course you can use it in the function itself, just be cautious that you don't create cyclic references by doing something stupid :)
This parameter gets incredibly handy when you use one callback function for multiple controls:
const var buttons = []; for(i = 0; i < 128; i++) { buttons.push(Content.getComponent("button" + i); } inline function printMyIndex(component, value) { local index = buttons.indexOf(component); Console.print("You clicked button " + index); }; for(b in buttons) b.setControlCallback(printMyIndex);
I've been using this paradigm in literally every project I am working on since it heavily reduces boilerplate code. Although it comes with a slight performance overhead because it needs to look up the index in the array, so if it's a time critical function, better code it manually...