I didn’t expect it would take this much time. I spent the past week learning to read and parse MIDI files, and eventually playing them with my synthesizer.


1/2/3 = play song
spacebar = stop playback

The MIDI player I’ve written is primitive and hacky. There are some quirks/bugs which I didn’t bother to fix:

  • It plays sounds based on game time rather than actual audio time, so the timing is not 100% accurate.
  • The synthesizer doesn’t stop cleanly in Chrome
  • If the page loses focus while the music is playing, the music stops playing. But upon resuming focus, all of the notes that weren’t played during the interval will be played at once.

My original goal was to have a functional MIDI player which I can manually map channels to play basic sine/triangle/noise voices, to simulate 8-bit music. I discovered that MIDI file specs are deeper than I originally thought, which means I would lose a lot of subtle sound behaviour if I do not handle the MIDI events accordingly, such as Tempo, Control and Program changes.

On top of that, although parsed MIDI files are a lot smaller than WAV data, it’s ultimately less efficient. I could write additional logic to convert the MIDI events into WAV data, but I didn’t want to spend more time reinventing the wheel, especially since I know there’s other libraries which can already do what I want to achieve, and a lot better at that too.

While I was researching MIDI-related stuff (and emulator-related articles especially the NES APU), I came across ZillaLib, a 2D and 3D C++ game framework which literally does everything I have wanted to write with Wyngine.

It took me a while of contemplating. I had to accept the fact that I would never be able to write a library as feature-complete and efficient as ZillaLib within a reasonable time-frame before I can start writing games, so I’ve decided to stop working on Wyngine and just proceed to making games instead, using ZillaLib.

Wyngine was a good exercise though. The experience itself up until now (from image and ASCII font loading, to parsing MIDI files and writing playback logic) was an interesting and informative journey.