Playing a MIDI file (revisited)



When I was a total JUCE noob, back in 2005, I created a topic to get some information about MIDI file playing :

At the end of that topic, I shared a quite bad source code example in a zip file containing something that didn’t really work as expected but might give some insight to other people who want to play a MIDI file in an app as well.

The funny thing about this topic is that, over the last 13 years (wow I got some new white hair just by typing this number) I had I don’t know how many requests to make that sample code available again !

So, I created a new project and tried to come up quickly with something not too bad to replace that sample code and to stop finally that loooooong chain of requests :slight_smile:

PluginEditor.cpp (2.6 KB)
PluginEditor.h (1.8 KB)
PluginProcessor.cpp (9.6 KB)
PluginProcessor.h (4.0 KB)

That sample code is for a plug-in project. It allows the user to load a MIDI file from the hard drive, to select a track among the available ones, and then playing the MIDI file track content for any virtual instrument put after in the DAW at the original tempo, when playing is enabled in the transport bar. That code can probably be improved a lot, but at least it does what it is supposed to do, and provides some additional “note off events” when necessary.

Have fun !


Just wanted to say thank you !