Introduction - If you have any usage issues, please Google them yourself
This source teach you how to process a MIDI file.
The code provided is a complete game, so you can use it as a framework for your own game. And Including a PDF document in the source. Please check it carefully.