Audio development, MP3
by Nelson Rush · in Torque Game Engine · 08/11/2001 (8:22 pm) · 9 replies
I have some MP3 playing code I'd like to work into the engine but I'm having some trouble understanding what I need to call to play an audio buffer.
I'm thinking what I need is in AudioThread but I'm not really sure. Do I create() a new audio thread every time I want to play an audio buffer? And then copy over the buffer with setBufferPlayHandle() and play with process()? Or am I looking at the wrong class for this?
Also, why was Miles even necessary, doesn't OpenAL stream audio through the operating system's audio driver? Was it because Miles supported different sound cards? And what is going to be done about that?
Any help on this would be appreciated, thanks.
p.s. Or should I just make calls directly to OpenAL?
p.p.s. Or, do I use the Sim2DAudioEvent class in gameConnectionEvents.cc? Sim2DAudioEvent::process() just calls alxPlay() with the profile set by the constructor, now how do I fill in that profile? I'll try to keep looking, I'm a bit daunted by the amount of code I have to sift through. A comment at the top of each source file explaining what it is for would have been nice. Ah, neat, alxPlay() creates a source on the fly.
I'm thinking what I need is in AudioThread but I'm not really sure. Do I create() a new audio thread every time I want to play an audio buffer? And then copy over the buffer with setBufferPlayHandle() and play with process()? Or am I looking at the wrong class for this?
Also, why was Miles even necessary, doesn't OpenAL stream audio through the operating system's audio driver? Was it because Miles supported different sound cards? And what is going to be done about that?
Any help on this would be appreciated, thanks.
p.s. Or should I just make calls directly to OpenAL?
p.p.s. Or, do I use the Sim2DAudioEvent class in gameConnectionEvents.cc? Sim2DAudioEvent::process() just calls alxPlay() with the profile set by the constructor, now how do I fill in that profile? I'll try to keep looking, I'm a bit daunted by the amount of code I have to sift through. A comment at the top of each source file explaining what it is for would have been nice. Ah, neat, alxPlay() creates a source on the fly.
About the author
#2
Did Dynamix have to pay Fraunhofer royatlies for Tribes 2? That'd be interesting to find out.
Also, having support for it in the v12 engine can't be all that bad. If you ship your product and decide to use it or not that's up to your team/company. So, yah, also having Ogg support would be nice. Choices are nice.
Also, it is probably impossible to not break one of Fraunhofer's several patents on MP3 and MP3-like technology. Ogg Vorbis has probably infringed on something.
http://mp3licensing.com/patents/index.html
And, you have to sell more than 5,000 copies of your game to be charged royalties for its use.
http://mp3licensing.com/help/developer.html
Even then its only $2,500 per game title, not per copy sold.
http://mp3licensing.com/royalty/games.html
Pretty reasonable, and they did work their ass off on this compression format, they deserve it. Especially if you, as a company, are profiting off of it. IMHO.
08/12/2001 (11:33 am)
I know about Ogg Vorbis, it is hardly as common or popular as MP3 though. If end users want to play their own MP3s while the game is playing they won't want to convert their entire archives to Ogg.Did Dynamix have to pay Fraunhofer royatlies for Tribes 2? That'd be interesting to find out.
Also, having support for it in the v12 engine can't be all that bad. If you ship your product and decide to use it or not that's up to your team/company. So, yah, also having Ogg support would be nice. Choices are nice.
Also, it is probably impossible to not break one of Fraunhofer's several patents on MP3 and MP3-like technology. Ogg Vorbis has probably infringed on something.
http://mp3licensing.com/patents/index.html
And, you have to sell more than 5,000 copies of your game to be charged royalties for its use.
http://mp3licensing.com/help/developer.html
Even then its only $2,500 per game title, not per copy sold.
http://mp3licensing.com/royalty/games.html
Pretty reasonable, and they did work their ass off on this compression format, they deserve it. Especially if you, as a company, are profiting off of it. IMHO.
#3
08/12/2001 (3:16 pm)
If portability isn't an concern for you, you can probably get away with using DirectX to do your MP3 playing for you. No licensing needed.
#4
And yes, Ogg Vorbis isn't as popular as MP3, *yet*, perhaps by supporting it you would help increase it's popularity, eh?
And I'm not "Captain Ogg Vorbis Fan" or anything, but the less proprietary closed sorce formats used the less it cuts into all of our paychecks. And if you're supporting in-game music there's no reason NOT to use Ogg instead of MP3 unless you just want to spend money.
If an end-user wants to play their own music they can stick in a CD, since the distribution method of any V12 product prohibits the use of any Game-CD-in-drive oriented copy protection there's no reason NOT to utilize this feature to our advantage.
08/12/2001 (3:39 pm)
Yes, Dynamix had to pay a license fee for Tribes 2, thus the removal of MP3 support from V12.And yes, Ogg Vorbis isn't as popular as MP3, *yet*, perhaps by supporting it you would help increase it's popularity, eh?
And I'm not "Captain Ogg Vorbis Fan" or anything, but the less proprietary closed sorce formats used the less it cuts into all of our paychecks. And if you're supporting in-game music there's no reason NOT to use Ogg instead of MP3 unless you just want to spend money.
If an end-user wants to play their own music they can stick in a CD, since the distribution method of any V12 product prohibits the use of any Game-CD-in-drive oriented copy protection there's no reason NOT to utilize this feature to our advantage.
#5
Curt: I already listed reasons someone might want to include MP3 playing support in their game. Let's let game developers decide if its worthwhile to include it in their game. If they're okay with having to pay a $2k fee when they hit 5000 sales then its their choice. Thanks for pointing out Ogg, I'll look into adding support for that as well. What would spur widespread use of Ogg I think, would be allowing users to choose between Ogg and MP3. If games get released which support both, end users may decide they prefer Ogg. Supporting only Ogg is just going to alienate your game and the music format from users who use MP3. As for CD audio, yes, I also plan on implementing that as well.
08/12/2001 (4:21 pm)
Wes: I was going to release the MP3 modification for V12 to the V12 community, probably through GG, so others can use it in their games as well. So, yah, portability is important. I'm using amp11 which is what XMMS (WinAMP clone in Linux) uses to play MP3s.Curt: I already listed reasons someone might want to include MP3 playing support in their game. Let's let game developers decide if its worthwhile to include it in their game. If they're okay with having to pay a $2k fee when they hit 5000 sales then its their choice. Thanks for pointing out Ogg, I'll look into adding support for that as well. What would spur widespread use of Ogg I think, would be allowing users to choose between Ogg and MP3. If games get released which support both, end users may decide they prefer Ogg. Supporting only Ogg is just going to alienate your game and the music format from users who use MP3. As for CD audio, yes, I also plan on implementing that as well.
#6
Sorry for the sidetracking of your question, which it doesn't look like anyone answered yet.
08/13/2001 (3:22 pm)
I agree, each team should make the choice, and there's nothing wrong with MP3 support, or with Fraunhofer making some money from it. One of the more deserving IMO. Was just trying to help out with the bottom line.Sorry for the sidetracking of your question, which it doesn't look like anyone answered yet.
#7
It is currently impossible to play any audio because the Miles code was ripped out uncleanly in a hurry. Meaning, it's going to take a lot of work rewiring the audio system to accept redirection to D3D, ALSA, OSS, or whatever. You're also going to have to download the latest snapshot of OpenAL (it wasn't actually included in the engine download) from www.openal.org in order to get yourself pointed in the right direction. I also think that the version of OpenAL that Dynamix used is now very outdated and several key things have changed in the library since then.
Also, it isn't necessary to edit the C++ code to play audio in the game. All of those functions I originally considered calling are used internally by the engine itself. When you want to play a sfx or music you make the call to the sound system from within the mod script. This is actually very convenient, that is it would have been convenient if the audio code in the engine worked.
It looks like getting the sound system working is on Tim's list of things "To Do" so we should be seeing something soon. I hope.
08/14/2001 (11:05 pm)
Okay here's what I know so far about the audio.It is currently impossible to play any audio because the Miles code was ripped out uncleanly in a hurry. Meaning, it's going to take a lot of work rewiring the audio system to accept redirection to D3D, ALSA, OSS, or whatever. You're also going to have to download the latest snapshot of OpenAL (it wasn't actually included in the engine download) from www.openal.org in order to get yourself pointed in the right direction. I also think that the version of OpenAL that Dynamix used is now very outdated and several key things have changed in the library since then.
Also, it isn't necessary to edit the C++ code to play audio in the game. All of those functions I originally considered calling are used internally by the engine itself. When you want to play a sfx or music you make the call to the sound system from within the mod script. This is actually very convenient, that is it would have been convenient if the audio code in the engine worked.
It looks like getting the sound system working is on Tim's list of things "To Do" so we should be seeing something soon. I hope.
#8
This latest drop of OpenAL sounds very cool. I will keep everyone posted as I start working on it.
--Rick
08/16/2001 (11:09 am)
I will be working on re-integrating the latest snapshot of OpenAL in the next couple weeks. Creative just sent me one of their new EAX 3.0 beta cards yesterday with new hardware accelerated OpenAL drivers.This latest drop of OpenAL sounds very cool. I will keep everyone posted as I start working on it.
--Rick
#9
If you're writing an encoder, you definitely have to pay up. The decoding doesn't seem to be covered by patents, but Fraunhofer will make demands anyway.
My recommendation: If all you want to do is play back your own game music, use OggVorbis. If you want your users to play their own music, let them use their own MP3 players. You probably don't want the licensing hassle.
08/18/2001 (12:02 pm)
Some information on MP3 patents:If you're writing an encoder, you definitely have to pay up. The decoding doesn't seem to be covered by patents, but Fraunhofer will make demands anyway.
My recommendation: If all you want to do is play back your own game music, use OggVorbis. If you want your users to play their own music, let them use their own MP3 players. You probably don't want the licensing hassle.
Torque Owner Curtis Turner II
39th Studios, LLC
http://www.xiph.org/ogg/vorbis/
Ogg Vorbis is a fully Open, non-proprietary, patent-and-royalty-free, general-purpose compressed audio format for high quality (44.1-48.0kHz, 16+ bit, polyphonic) audio and music at fixed and variable bitrates from 16 to 128 kbps/channel. This places Vorbis in the same class as audio representations including MPEG-1 audio layer 3, MPEG-4 audio (AAC and TwinVQ), and PAC.