Music is back!
I've revisited some old DirectShow code and had a great time trying to figure out how the thing works all over again. It's pretty much in there now, but as a supplement to rather than a replacement for the original CD player. Basically if there is no CD in the drive it attempts to fall back on MP3s or whatever (I'll come to that in a bit...) before giving up.
Aside from the fact that the music files must be in a directory called "music" under your gamedir (some day I'm going to cvar-ize all of these fixed directories I've created) I've removed all limitations on the names. So you can have 10 files called whatever you want and I'll play them in order for you. Nice.
What about formats? That's where the really nice thing (one of them anyway) about DirectShow comes in. It'll play almost anything; if you can play it in Windows Media Player then this baby will play it for you too. Theoretically it can even stream audio over the internet, but I haven't added code for that (don't think I will, somehow...)
Experiences with DirectShow were mixed. I know my initial implementation from years ago was a mess, and the first shot I'd taken at it this time was getting real ugly real fast too, so I ended up wrapping all of the DirectShow stuff in a class and using that to manage my COM pointers and stuff. It was much much cleaner overall, but there are still some weird things in the API itself that had me doing some head-scratching for a bit. Never mind.
At this stage a massive shout out needs to go to http://www.flipcode.com - they have some excellent resources, containing exactly the kind of info you need to implement DirectShow in this kind of app, which really helped with getting back up to speed.
And no thanks at all to http://msdn.microsoft.com.
Thursday, December 25, 2008
Music Wherever We Go
Posted by
mhquake
at
9:58 PM
Subscribe to:
Post Comments (Atom)
2 comments:
Nice feature!
It would be great if you followed the sound/cdtracks/track01.ext "standard". Darkplaces implemented that, one not-yet-released engine will use it and from what I know the next Fitzquake release will use it too. That way people could use their soundtrack cross-engine.
Darkplaces can do Ogg Vorbis and Wav. Fitzquake will have MP3 and I don't know. The unreleased engine can do Ogg Vorbis and MP3 (using fmod).
But by using DirectShow I guess that's not "your" (your engine's) duty. :)
If possible "future-safe" three digit would be ace in my opinion so people could actually use the cdtrack emulation to easily change music ingame (with triggers. Well, only if the engine also makes the cd commands work with the fake tracks).
I eventually intend making the directory user-configurable, but for now an option of using "sound/cdtracks" as well as "music" is trivial to implement, and seems the right thing to do.
I can do MP3, WAV, WMA, FLAC, OGG, you name it. If you have a DirectShow codec installed for it, I can do it. You can even mix different types in the same directory and I'll do them all.
I'm not bothered about an individual track naming convention either, I'll do them all whatever they're called!
The "CD" commands will work with the fake tracks.
Post a Comment