Although not perfect (because it was intended at the time for a very specific usage … clocking via fingers ) there is a MidiSequence object in GP Script along with a collection of functions for stepping through it. It can load standard MIDI files.
I use it to step through by pressing notes on a keyboard but the OnBeat callback could probably be used as well.