PDA

View Full Version : MIDI Implementation


Phil Steinmeyer
11-14-2005, 10:02 PM
I'm considering the possibility of implementing MIDI for the web version (Active X) of my game. This version has very tight space constraints (< 1MB total, compressed), so it's either MIDI or nothing (or maybe a simple ambient loop) for music.

Anyways, I've stripped out SDL and FMOD for the web version to keep everything small - I'm using straight DIBs for graphics, and DirectSound 7 (I think - it's from the PopCap library) for sound.

PopCap's stuff doesn't support MIDI in any way, so I'm on my own here.

So, IIUC, I need to use DirectMusic for MIDI, right? Any magic info on versions? What versions of DX is DirectMusic available for? Any 'gotchas' I should know about? Any alternative APIs I should consider (like something in WinMM, maybe?)

Thanks,
Phil

gosub
11-14-2005, 11:04 PM
DirectMusic would be one way, but I think DirectShow might be simpler. In any case, there's a few examples in the original DirectX 9.0 SDK that play files (including midi) using both DirectMusic and DirectShow.

Did DirectMusic even exist in DirectX 7.0? As I recall, there's a simple AudioVideoPlayback API that goes back to Windows 95. Unfortunately, I forget where. It was a COM interface, and I used it through Visual Basic.

-Jeremy

soniCron
11-15-2005, 02:46 AM
Did DirectMusic even exist in DirectX 7.0? Yes. It's been around since DirectX 6.0.

ManuelMarino
11-18-2005, 06:58 PM
Are you sure using midi? Is a jump in darkness, you never know the outcome, so many engines exist.

jetro
11-19-2005, 12:17 PM
Were you using modules (xm, it, mod etc) or mp3/ogg to play with FMOD?

If you used modules or are willing to use them, you might get away easily enough with MINIFMOD, which is available from the FMOD site. It is really small, adds just a few kilobytes to your exe, and can play XM files.

And... just a bit of fuel for thought... there's something about music games haven't really yet utilized. One could use "softsynth" to produce music - those are really small and still often sound quite good. Either have one producing sound realtime, or use one to generate samples for a module. Those kind of tricks are used to make 4 KB and 64 KB intros (such as this one (http://jet.ro/files/angeles.zip) for example). Here is also a small example exe playing out music (http://jet.ro/files/parallaxfat_music.exe) by combining a softsynth and a small speech synth to generate samples for XM played out with the MINIFMOD (and finally compressed with UPX).

soniCron
11-19-2005, 01:25 PM
And... just a bit of fuel for thought... there's something about music games haven't really yet utilized. One could use "softsynth" to produce music - those are really small and still often sound quite good. I've had a stub (http://sourceforge.net/projects/imusing/) at SourceForge for a long time now for just this. When I've got myself more free time, I'll be able to start working on the framework. I've already got a commercial quality soft-synth fully coded and ready to go once the audiopath is nailed down. Unfortunately, I suspect it'll be around the beginning of 2007 before I can really devote enough time to put into this project.

Phil Steinmeyer
11-19-2005, 02:01 PM
My original files were XM, which I compressed to OXM for playback through FMOD. The limiter here is not so much the size of the FMOD DLLs as it is the size of the compressed XMs ~ 1.8MB for all 30 minutes of music. Even if I just used a song or two, it would be too big, considering my overall budget is 1MB for everything, including graphics and EXE

jetro
11-21-2005, 01:41 AM
My original files were XM, which I compressed to OXM for playback through FMOD. The limiter here is not so much the size of the FMOD DLLs as it is the size of the compressed XMs ~ 1.8MB for all 30 minutes of music. Even if I just used a song or two, it would be too big, considering my overall budget is 1MB for everything, including graphics and EXE

If you're willing to go "as low" as MIDI, you could probably use different set (and less) of XMs instead, with simpler and maybe lower quality samples. Personally I would consider that to be better approach than MIDI, knowing that capable composers can do wonders in surprisingly small space with modules.. Problem is, optimization like that may be outside your time/budget.