Playback of midi has been an ongoing and fun project that I'm working on. It involves a lot of reading bytes, which need to be decoded as they could mean anything.
Midi by itself is more or less a file that works like a music score or as orchestra conductor. By itself it will not generate any music, an additional file is required: sound fonts.
Sound fonts have various audio parts within and additional direction on how it should sound. The two files I have combined into my own approach of midi playback
Examples have been rendered to a .wav format, real time playback is also possible.
By far it is from perfect, but as it is my own implementation a lot more can be done instead.
Such as constant pitch bending, changing instruments, or change them for each measure.
Besides this there are plenty of other things than can be achieved, such as transposing or playing in reverse.
Or more technical things like directly influencing audio by using certain audio filters
audio
element.audio
element.audio
element.
The playback is not limited to one single instrument, it can play various instruments at the same time; creating a virtual orchestra.
The final sound quality varies per midi music file. It also varies per soundfont instruments it uses.
audio
element.audio
element.audio
element.