NoteOnEvent affecting non-captured note-off events

I have a question regarding capturing note-on events with GPScript and how it relates to note-off events.

My goal is to capture some of the notes coming in from my left hand to reset the bpm used by a midi player to reflect that of the BPM of the song as it is being played. I then plan to trigger the MIDI player by pressing a non-playing note in the right hand, running it at the current BPM. But before implementing this, I first to try to implement simple things and make sure that they work before moving on to more complex things, to divide and conquer. I also try to avoid adding good code to bad.

My issue is with the code below:

Var
   ClavMidiIn : MidiInBlock

On NoteOnEvent(m : NoteMessage) Matching [E1..G1] from ClavMidiIn
    SendNow(ClavMidiIn, m)
End

This works as expected with Note-On events, but for some reason, it blocks Note-Off events for notes within the matching range. I have verified this by using a Midi Monitor:

Note on A1 (45) Velocity 75 Channel 1
Note off A1 (45) Velocity 96 Channel 1
Note on G1 (43) Velocity 71 Channel 1
Note on F1 (41) Velocity 85 Channel 1
Note on B1 (47) Velocity 79 Channel 1
Note off B1 (47) Velocity 108 Channel 1

Note that the note-on notifications within the matching range do not have a corresponding note-off notification.

Does this mean that I must also capture Note-Off events explicitly with a similarly constrained NoteOffEvent callback? Either that or get rid of NoteOnEvent and NoteOffEvent callbacks and instead use a constrained NoteEvent callback and then check if IsNoteOn(m) Then within the callback before, say, calling Tap()?

As always, many thanks in advance!

Pete

The “On NoteEvent” callback will not be called if “On NoteOn” or “On NoteOff” is defined.

1 Like

@Frank1119 Thank you for your reply.

So, does this mean that the system uses the On NoteEvent(...) callback internally to handle MIDI notes that have entered a MidiInBlock, and that my own on NoteOnEvent(...) callback is preventing this from working?

If so, then it looks like I will need to use an On NoteEvent(...) callback to handle things rather than On NoteOnEvent(...).

Again and as always, thanks!

Pete

1 Like

Well, it is simply that if you use On NoteOnEvent, you need to use the corresponding On NoteOffEvent. Only use On NoteEvent if you do the same for Note On and Note Off.

1 Like

@David-san: Thanks. I will try to remember this and continue to strive forward!

1 Like