The most direct method is to write a small C++ program that:
: Reading the MIDI file to extract note on/off events, velocities, and other relevant data. midi to bytebeat