Inside3D!
     

MP3 or Ogg Support
Goto page 1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Engine Programming
View previous topic :: View next topic  
Author Message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Tue Nov 17, 2009 2:14 pm    Post subject: MP3 or Ogg Support Reply with quote

I did a cursory examination of pulling DarkPlaces ogg support out and sticking it in another engine. Until I noticed a whole chain of other required changes including memory management.

Then I explored the fmod route. I thought Nehahra and those modifications using fmod.dll would support playing MP3. It doesn't. At least not in the engine source, I know the fmod dll supports but the engine code doesn't.

At least not how the nehahra.c and fmod are written in, say, JoeQuake. It only supports the "song" class of files like midi and xm (Nehahra uses xm).

Some mp3s decompress from, say, 13 MB into 88MB uncompressed and unless the whole file is loaded into memory, I guess that is going to require streaming. Sad

And it appears DarkPlaces does streaming, which at first glance requires memory management modifications to pull off and appears a bit complicated to boot.

There is, of course, the midi option that is available via the Hexen route like the Q2K4 engine uses. Or using fmod.

But for "real" cd track like playing capability without archaically expecting someone to burn a CD of the music, using midi isn't really an option.

Coincidentally, I stumbled upon this at Quake Royale author's site.

It supposedly looks like a rather easy way to add MP3 support.

http://www.telefragged.com/thefatal/q_tutorials/mp3_quake.txt

But even if it is, the supporting links are dead.

Of course another route to consider is the awkward FuhQuake/ezQuake method using WinAmp (yuck!).

I have examined the FTEQW source and it looks like it has OGG support (I'm assuming AVAIL_OGG is true in the project defines). But I know FTEQW has altered memory management as well.

No real answers or questions here, but more or less am raising this for possible future discussion.
Back to top
View user's profile Send private message
reckless



Joined: 24 Jan 2008
Posts: 390
Location: inside tha debugger

PostPosted: Tue Nov 17, 2009 2:33 pm    Post subject: Reply with quote

look in mh's last opengl source it has code for mp3 playing directly from directx. (or in mine ->realm)

and aye the way fmod has been used mostly is only for xm support
(legacy dos format music files) my guess is they tried to keep compatibility with winquake alltho to my knowladge a software version of nehahra's engine newer made it.
Back to top
View user's profile Send private message
mh



Joined: 12 Jan 2008
Posts: 909

PostPosted: Tue Nov 17, 2009 2:41 pm    Post subject: Reply with quote

That Xaudio library (http://www.xaudio.com/index.html) is quite proprietary - there would be probable issues with linking it with Quake, and definite issues with distributing it.

Also, from the looks of the text file, the implementation wraps Xaudio in DirectSound, meaning that it will have implications for the normal Quake sound system.

If you're not worried about being cross-platform you can always use DirectShow (http://en.wikipedia.org/wiki/DirectShow). It's quite easy (if a little messy) to write a basic player with it, and it will handle any file type that you can play in Windows Media Player. It'll handle decompression, streaming, memory allocation and everything for you, and will play in it's own thread so you won't need to worry about keeping buffers in sync. As an added bonus you won't need any external libraries for it.

There's also something called GStreamer (http://en.wikipedia.org/wiki/GStreamer) which I haven't checked out, but seems quite capable (and is cross-platform).
_________________
DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines
Back to top
View user's profile Send private message Visit poster's website
mh



Joined: 12 Jan 2008
Posts: 909

PostPosted: Tue Nov 17, 2009 2:44 pm    Post subject: Reply with quote

reckless wrote:
look in mh's last opengl source it has code for mp3 playing directly from directx. (or in mine ->realm)

So does my current D3D source. Very Happy
_________________
DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines
Back to top
View user's profile Send private message Visit poster's website
reckless



Joined: 24 Jan 2008
Posts: 390
Location: inside tha debugger

PostPosted: Tue Nov 17, 2009 3:27 pm    Post subject: Reply with quote

Quote:
So does my current D3D source.


aye but isnt it c++ ? ow i see Embarassed the directsound code is c++.
Back to top
View user's profile Send private message
reckless



Joined: 24 Jan 2008
Posts: 390
Location: inside tha debugger

PostPosted: Tue Nov 17, 2009 3:30 pm    Post subject: Reply with quote

hmm i have some code for openal support from quake2xp but it seems a bit hacky also its a mess to read Laughing

gsteamer is indeed very capable mplayer uses it
Back to top
View user's profile Send private message
mh



Joined: 12 Jan 2008
Posts: 909

PostPosted: Tue Nov 17, 2009 3:41 pm    Post subject: Reply with quote

reckless wrote:
Quote:
So does my current D3D source.


aye but isnt it c++ ? ow i see Embarassed the directsound code is c++.

It should be straightforward enough to break out into C though, most DirectX COM stuff is (even D3D).
_________________
DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines
Back to top
View user's profile Send private message Visit poster's website
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Tue Nov 17, 2009 4:14 pm    Post subject: Reply with quote

Multiplatform to me is somewhat important because I love my OS X machine.

But at the same time, I'll settle for Windows only because the Fruitz of Dojo port has MP3 support built into it already using Apple proprietary Quicktime library stuff which is damn-near part of OS X.

Ah hell ... MH is going to have modified memory management in that though???

mh wrote:
reckless wrote:
Quote:
So does my current D3D source.


aye but isnt it c++ ? ow i see Embarassed the directsound code is c++.

It should be straightforward enough to break out into C though, most DirectX COM stuff is (even D3D).


In a couple of weeks, I'll take a look and if I can isolate it out I'll write up a tutorial on this Wink

Thanks for the infos, guys.

reckless wrote:
look in mh's last opengl source it has code for mp3 playing directly from directx. (or in mine ->realm)


Reckless do you have a link to the most current Realm source code?
Back to top
View user's profile Send private message
reckless



Joined: 24 Jan 2008
Posts: 390
Location: inside tha debugger

PostPosted: Tue Nov 17, 2009 5:09 pm    Post subject: Reply with quote

not the most recent cause i broke some code when playing with implementing some more recent hunk allocation code mh pointed me at. but i got the working one still on my ftp.

Realm_2009_2_17.zip

ftp://90.184.233.166:21 login as Anonymous theres no pass
Back to top
View user's profile Send private message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Tue Nov 17, 2009 10:08 pm    Post subject: Reply with quote

reckless wrote:
not the most recent cause i broke some code when playing with implementing some more recent hunk allocation code mh pointed me at. but i got the working one still on my ftp.

Realm_2009_2_17.zip

ftp://90.184.233.166:21 login as Anonymous theres no pass


Thanks!
Back to top
View user's profile Send private message
reckless



Joined: 24 Jan 2008
Posts: 390
Location: inside tha debugger

PostPosted: Tue Nov 17, 2009 10:47 pm    Post subject: Reply with quote

most welcome Wink
Back to top
View user's profile Send private message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Wed Nov 18, 2009 7:40 am    Post subject: Reply with quote

I got it working with stock GLQuake Very Happy

I will probably finesse around with it -- not so much the existing code but some cvar and map track stuff -- and the write up a tutorial in the next week or so.

It's a little inelegant but it wasn't so hard and most importantly it works!

Thanks Reckless/MH for the code.

Parting question probably for MH or whoever can answer a question about the API: Any way to control the MP3 playback volume to increase or decrease the sound volume? I merely ask because lack of volume control annoyed me about the Quake cd music and I'd like to have at least the ability to make a slider bar.

[I don't care if the music has to be stopped and restarted to do this.]
Back to top
View user's profile Send private message
reckless



Joined: 24 Jan 2008
Posts: 390
Location: inside tha debugger

PostPosted: Wed Nov 18, 2009 8:56 am    Post subject: Reply with quote

as fart as i remember its controllable with the same cvars that normal quake uses Smile ie. music volume etc.
Back to top
View user's profile Send private message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Wed Nov 18, 2009 9:00 am    Post subject: Reply with quote

reckless wrote:
the same cvars that normal quake uses Smile ie. music volume etc.


Yes, but Quake doesn't have cvars to control the music volume Very Happy Very Happy

You can either turn the CD music off or turn the CD music on.

You can only control the "game" volume, like all the sounds that you hear Quake play when the CD isn't in.

Anyway, I really like this code and look forward to writing up a quick tutorial on it. Thanks yet again Wink
Back to top
View user's profile Send private message
mh



Joined: 12 Jan 2008
Posts: 909

PostPosted: Wed Nov 18, 2009 9:30 am    Post subject: Reply with quote

bgmvolume is there isn't it? It never worked on the CD cos a lot of CDs were just 0 or 1 for volume.

My current code for volume goes something like this:
Code:
   void AdjustVolume (void)
   {
      // ensure that we can change volume
      if (!this->ds_Audio) return;

      long db;

      // whoever in ms designed this must have really prided themselves on being so technically correct.  bastards.
      // decibels are great if you're an audio engineer, but if you're just writing a simple sliding volume control...
      if (bgmvolume.value <= 0)
         db = -10000;
      else if (bgmvolume.value >= 1)
         db = 0;
      else
         db = log10 (bgmvolume.value) * 2000;

      // set the volume
      this->ds_Audio->put_Volume (db);
   }


The version used in the Realm codebase was a much cruder earlier take on it that precalculated the log10 in discrete steps.

A version of the above should work just fine; you just need to check for a change in the value of bgmvolume and change the this->ds_Audio pointer to pAudio.
_________________
DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Engine Programming All times are GMT
Goto page 1, 2, 3, 4, 5  Next
Page 1 of 5

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group