How to disable midi note event handling, or disable entire script

I have a GP script that defines On NoteEvent handlers matching several different note ranges and plays chords, updates state etc depending on which note was pressed.

I’d like to create a control to toggle all those handlers on and off with one button/note press/variation etc.

I can add an extra global boolean variable and check it in each of my NoteEvent handlers and then either do the special stuff if the global flag is enabled, or else just send the midi note back out, but is there a cleaner, easier way I’m missing?

Thanks in advance.

I would use different Midi In blocks parallel and bypass/unbypass that via a widget and a simple script.
The script also sets the Note On Filter.

Here is the script

   MINScript : MidiInBlock
   MINNoScript : MidiInBlock
   NOTEON : Widget

//Called when a NoteOn message is received at some MidiIn block
On NoteOnEvent(m : NoteMessage) from MINScript

// Called when a widget value has changed
On WidgetValueChanged(newValue : double) from NOTEON
  SetPluginBypassed(MINScript, newValue == 0.0)
  SetPluginBypassed(MINNoScript, newValue == 1.0)
  if newValue == 1.0 then
   SetParameter(MINScript, 288, 0.0)
   SetParameter(MINScript, 288, 1.0)

And here the example gig
NoteOnBlocker.gig (6.8 KB)

Another alternative is to use a Midi Filter and control Note Message via a widget.
When the filter blocks notes the script you wrote will send be able to send this messages to the connected plugin, but the parallel Midi In block is activated and the original note messages go through

NoteOnBlockerNoScript.gig (9.3 KB)

You see there are more than 1 solution for your use case.

1 Like

Thanks for the help, pianopaul. And you’re right – lots of ways to do it.

Once I added a second, parallel midi in block without gpscript enabled, I just added two widgets to control the bypass setting of the two midi in blocks, put the two widgets (one inverted) in the same widget group, and added a midi param to control the widget group.

But it’s good to see how to control the bypass flags programmatically from gpscript in case I need that level of complexity later on. Thanks again.

1 Like