It's quite tricky to get event-based information from MIDI data. It becomes easier when you check encoding process code. I will upload my code later when it is good to do so.