Dark Bit Factory & Gravity

PROGRAMMING => General coding questions => Topic started by: va!n on November 22, 2007

Title: Way to play MP3 with DirectX9 ?
Post by: va!n on November 22, 2007
hello guys...
atm i am working on a project where i use DirectX9 for the GfxEngine... However i want to play MP3 files with this app too... Afaik it should work using the winmm.lib functions but is there another and better way to play MP3 tunes with DirectX9 or DirectMedia? What would be the best for best performance and compatiblity for future Windows versions?

Stuff i need:  PlayMp3, StopMP3, StartMp3AtPosition ^^

thanks for feedback...   ah yes... possible (optional) i could add the feature to play not just only MP3 files... just MP3 and movies (using installed codecs) too and draw the video on a texture in realtime...  DX9, DirectMedia, WinMM ? :P

Title: Re: Way to play MP3 with DirectX9 ?
Post by: Jim on November 22, 2007
Can't play mp3 directly using DirectX.
You can use mci - here's how I play the mp3 in my demos
Code: [Select]
mciSendString("open \"Rezistah - Cauldron.mp3\" alias mympg", NULL,0,NULL);
mciSendString("play mympg repeat", NULL,0,NULL);
If you go to MSDN help for mciSendString and then 'play', there is a 'from' command which might help you.  And a 'stop'.

Jim

Title: Re: Way to play MP3 with DirectX9 ?
Post by: va!n on November 24, 2007
@jim:
thanks for your feedback... i still thought to use the mci commands from the winmm lib/dll... However is there possible any other and better way (more performance and better sync?) to play MP3 and i.e. movie files (using system installed codecs) using DirectShow/DirectMedia?
Title: Re: Way to play MP3 with DirectX9 ?
Post by: Jim on November 25, 2007
DirectShow sample for playing video
http://dbfinteractive.com/index.php?topic=1542.0 (http://dbfinteractive.com/index.php?topic=1542.0)
with a bit of cut and paste (mostly cut) it will play mp3 as well.  Just need to insert the source filter and pGB->Run().
But, it's probably not going to be any better performance than mci, mci is just a different way of accessing the same codecs.

If you want access to the decoded samples (for an equalizer ;)) with DirectShow you'll need to insert a Sample Grabber filter after the mp3 decode stage and before the DirectSoundRenderer.  That's pretty hard core, though.

Jim
Title: Re: Way to play MP3 with DirectX9 ?
Post by: Rbz on November 25, 2007
Hmm, if you're already using a Mp3 (big) file, why not using bass.dll or fmod.dll  ???
You will have all features that you want.
Title: Re: Way to play MP3 with DirectX9 ?
Post by: taj on November 25, 2007
Hmm, if you're already using a Mp3 (big) file, why not using bass.dll or fmod.dll  ???
You will have all features that you want.

Agreed.
Title: Re: Way to play MP3 with DirectX9 ?
Post by: va!n on November 26, 2007
@rbraz:
normaly i would i agree with you... problem is that the actuall project is very tiny in size, where i cant and dont want to use bass, fmod or something like this due fact of the sizecoding... this is still the same project where we need a very fast and tiny FFT routine, we didnt really get worked until now :P anyway many thanks :)