Script/SendNow() ignores MIDI In Block Split

Hi folks -

Newbie question for you. I have a MIDI In Block defined with a keyboard split (say, C1-C2), along with a Rackspace script that I only expect to run when notes are played within that split. The code looks something like:

On NoteEvent (m : NoteMessage) From MyInputBlock

   If IsNoteOn(m) Then
  
      // Do something...

      SendNow(MyInputBlock, m)
  
   Elsif IsNoteOff(m) Then
  
      // Do something else...

      SendNow(MyInputBlock, m)
 
   End

End

The script works fine, but it generates output for all notes, not just the ones defined in the split range. I can get around it by doing something like this:

On NoteEvent (m : NoteMessage) From MyInputBlock

   If IsNoteOn(m) And BetweenNotes(GetMinNoteFromMidiInBlock(MyInputBlock), m, GetMaxNoteFromMidiInBlock(MyInputBlock)) Then
  
      // Do something...

      SendNow(MyInputBlock, m)
  
   Elsif IsNoteOff(m) And BetweenNotes(GetMinNoteFromMidiInBlock(MyInputBlock), m, GetMaxNoteFromMidiInBlock(MyInputBlock)) Then
  
      // Do something else...

      SendNow(MyInputBlock, m)
 
   End

End

Is this the recommended approach? It seems a bit cumbersome since I would expect the MIDI In Block to filter out notes that aren’t in the split range, either on the input side or the output side but somewhere, so that the script wouldn’t have to perform this check. Or am I missing a simple checkbox or setting somewhere?

Thanks as always!

The whole point of GPScript (as it pertains to its use with the MIDI In Block) is to let you do whatever you want regardless of the MIDI In Block explicit settings.

For a trivial example, suppose you have have defined a split so that it only responds to keys that you press between C1 and C2.

Now suppose that, whenever you press a note in that range, you would like to add a second note that is a third above whatever note you were playing. So if you press C1, you also get F1. If you press G1, you also get C2. But what happens if you press A1. You would surely like D2 to be heard but if GPScript obeyed the MIDI In Block splits, that second note wouldn’t play.

There are some system functions available through which you can query the current MIDI In Block split values so you can decide what you want to do in your GP Script.

Alternatively, if you don’t intend to change that split, you could use a constrained NoteEvent callback that will only react to notes in the range

On NoteEvent(m : NoteMessage) Matching [C1..C2] from MyInputBLock
...
End

That’s actually very efficient because the callback won’t even be invoked for notes outside the range.
Constrained callbacks are documented in the language manual which you can find on our support page.

1 Like

Ah!! Well of course it makes sense if you put it like that! :laughing:

Thank you for the concise, informative reply in less time than it takes to make a pot of coffee (!). This truly is an amazing community!