Author Topic: Way to play MP3 with DirectX9 ?  (Read 3978 times)

0 Members and 1 Guest are viewing this topic.

Offline va!n

  • Pentium
  • *****
  • Posts: 1432
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Way to play MP3 with DirectX9 ?
« 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

- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Way to play MP3 with DirectX9 ?
« Reply #1 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

Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1432
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: Way to play MP3 with DirectX9 ?
« Reply #2 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?
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Way to play MP3 with DirectX9 ?
« Reply #3 on: November 25, 2007 »
DirectShow sample for playing video
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
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: Way to play MP3 with DirectX9 ?
« Reply #4 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.
Challenge Trophies Won:

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: Way to play MP3 with DirectX9 ?
« Reply #5 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.
Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1432
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: Way to play MP3 with DirectX9 ?
« Reply #6 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 :)
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won: