MIDI in AS3 (Adobe Flash)

MIDI in AS3 (Adobe Flash)

William.Thompsonj's picture

For some time I've been looking at making a MIDI synthesizer in AS3 (Adobe Flash). Since AS3 doesn't natively support playing MIDI files (or reading them for that matter) this is a bit of a challenge. Through research I've learned of some methods that allow a binary file to be embedded and loaded as a byte array. From that point it's whatever handy work you can muster to interpret a byte array.

Has anyone worked with the MIDI file format or know of a good starting point for me to roll a MIDI interpreter? I understand the file structure a bit and I've read a little about generating different tones and sounds with saw waves, sine waves, square waves, triangle waves, et al, but I'm looking to accomplish this in AS3. I saw the tutorial here on OGA (opengameart.org/forumtopic/kickin-it-old-school-setting-up-nes-style-chiptunes) and read that too by the way.

There's a project that can play a MIDI file from Flash Player called SiON (wonderfl.net/c/4IH3). I've looked at that but haven't tried to implement it. I don't know if the sound quality it produces is good enough or it'll just annoy players. Particularly, it makes violins sound like synthetic pipe-organs and murders a few grand piano sounds without regard. It hits the right key and pitch but sometimes that's about all it can do.

Due to technical constraints, I'm forced to make an AS3 based game of less than 10MB total finished SWF size, only a single SWF, and it can't make remote calls for resources. So far the graphics I've chosen and had fabricated (by Sharm and the other awesome artists here on OGA) are well under that 10MB cap once compiled. I'm still struggling with the sound portion (pretty important component of any finished game). Since using 2-3 good MP3 files eats most of my size restriction I have to go with an ultri slim file type like MIDI.

Please OGA community, in your vast and collective wisdoms and interweb crawling mastery, how do you think I should proceed with making a MIDI music player for my Flash game?