Game Audio APIs
What are you guys using for audio in your games?
I spent a little time this weekend futzing around with the waveOut APIs. I suppose that's what you would have to use for mixing multiple wave files since DirectSound isn't available.
Any other alternatives?
Jaybot said he used S3M and XM or something...
[center]Hooray, Post # 500 in this Forum![/center]
That's right, you have to use the waveOut family. It's not terribly fun programming either. If you just need rudimentary sound capability, like playing a single sample at a time, you can use the sndPlaySound function for simplicity.
Dan East
Um, I'm just a lowly sound engineer and composer, not a programmer anymore

; but from what I've gathered from various programmers.. becuase of the obvious lack of on board sound hardware, many programmers/developers who want to use music in their games are using a MOD file decoder/player, which can cover any of the mod formats xm, s3m, it, or mod, becuase of the ability to embed the instrument samples in the file. Some programming teams, such as brain drain (short story I don't want to tell), have asked to only write using 4 channels (which I might add, 4 channels is a total bitch btw, custom samples of different chords for same instruments.. if you know music stuff..) to leave plenty of room for SFX channels. On the other hand, Peter Balogh has only requested that I don't exceed eight sound channels, which is fine by me (only prob is trying to keep the samples low by compression without losing sound quality, for a samller file size); I believe I read (or heard?) somewhere that the PPC has something like 16 open sound channels using a method like this, while using normal wav files for SFX.
Then again, Fredrik Malmer (weeboo and argentum author), is sticking to mixing only plain wav files (not PCM), a short looped wav file for music, and other wavs mixed in for SFX.
I hope that cleared something up. If not, ignore everything I wrote above and pretend it never happened

Jay,
Thanks for your perspective.
You wrote:
>>Then again, Fredrik Malmer (weeboo and argentum author), is sticking to mixing only plain wav files (not PCM), a short looped wav file for music, and other wavs mixed in for SFX.
From all I know, plain wav files are PCM encoded, with the addition of a RIFF header. Can you clarify a bit? Maybe I'm missing something.
Querying the hardware in my iPaq shows that there is a single output device with only 2 channels (stereo). If you want to play multiple sounds simultaneously, that means software mixing. That is what I'm playing around with now. My software must combine the PCM data from multiple buffers and then write those to the hardware using waveOutWrite. If you have docs on these reported 16 channels of audio on a PPC, then pass them along. I'm definitely interested.
I have no idea what XM, SM3, or MOD players are, but since the hardware can only play PCM data from a buffer, they would end up doing something similar to what I'm doing anyway. My iPaq only seems to support uncompressed, raw PCM data so any decompression would be done in software.
Anyway, thanks for the response. It's good to hear from people who have experience from the "content" side of the game development process.
You can add support for mod audio files with a lib called MikMod which i think you can get from
http://www.xsolution-online.de/the nice thing about mod files is that their file size is very small. I was going to use it in Argentum but it was kind of slow on my E-125, Jacco Bikker says it runs just fine on an Ipaq.
The PCM thing was just something that Fredrik Mentioned in a Chat..let's see, "Fredrik Malmer: (4:26 PM) remember not to use PCM or something. Has to be plain wave
Fredrik Malmer: (4:26 PM) and you should run your files through this app (StripWAV), that removes stuff some codecs add"
I'm not sure if that's exactly what he meant, because he did say 'or something' maybe he can clear that up.
As for the 16 sound channels.. I'm not sure exactly where I heard that.. it's possible it might have been the sound mixing software that BD was using for G-Prime.
Carpe,
I'll check out that link - thanks. I'm going to work strictly with PCM data though. It's a level that I'm comfortable with. Sounds like MOD files are similar to MIDI, in that note info is stored in the file and the library has the PCM data (or whatever it takes) to play.
Jay,
Perhaps he made a slip and really meant ADPCM? I might investigate using simple compression on the wav data, by encoding relative sample position rather than absolutes, then quantizing these steps using a 16-entry lookup table. I think I could decode this pretty quickly when the hardware buffer is loaded, but if it's slow I'm going to dump it.
Yes, I ment ADPCM...sorry for the confusion...As for "stripwav" it is a utility that removes the extra stuff some codecs add to the wave file, such as icons and descriptions. The wave-file reader is based on sourcecode from microsoft, and somehow it doesn't support that stuff in the wave file. The fun part is that Microsoft Codecs add the extra stuff!
// Fredrik
From what I gather about ADPCM, the "extra stuff" in the encoded wav file include the coefficients necessary to describe the base waveform for the adaptive compression.
I'm not really clear on why you would have extra info for a normal run-of-the-mill PCM-encoded wav file. Perhaps some audio tools allow you to add composer information or some such?
A normal plain PCM file COULD contain stuff like a special icon for the wave file and who the author is, a describtion etc...
// Fredrik
Hey,
MikMod is indeed for playing sound and music. If you want to use it, keep in mind the following:
1. Use .MOD files. Those are only 4 channels, wich saves a lot of mixing.
2. Alter the MikMod sources; take out the volume stuff. This saves a multiply for every sample in every channel, this reduced the processor load of MikMod to less than 10% when running at 30fps on my iPaq (wich still means that an E-125 game running at 100 fps would spend almost all it's time in MikMod...)
But, it saves you a lot of hassle. And it sounds great.
- Jacco.
"The devil, who deceived them, was cast into the lake of fire and brimstone where the beast and the false prophet are. And they will be tormented day and night forever and ever"
ummm you scare me
"dir pwl: i'm the troll from under the bridge i've come to piss you off"
uhhh. you scare me
Last modification: Diego Cueva - 05/30/01 at 09:56:14
MOD files son't have the same quality as S3M, IT or XM files though, mainly becuase of the way the samples are played back. However, you can program a S3M, XM or IT file to only use 4 channels as well.
Chuckie wrote:
ummm you scare me
Well that's what's gonna happen to him. Many people think the devil rules in hell. The truth is that hell was created for the devil and his angels as a punishment.
// Fredrik
PS. Sorry Chris if I'm off-topic...DS.
As for the music in argentum we will use a little bit different approach. We will have short wave files that are looped. This is what turjah do, which makes the music awfully repeditive. To avoid that we have built in a playlist that says what smaples to play. So with a few wave files that are short you can build a song that is 4 minutes long.
Works very well...
// Fredrik
2. Alter the MikMod sources; take out the volume stuff.
Jacco, could you indicate more specifically what you modified? Does that affect only the master volume, or does it also remove the internal mixing capability of the mod's tracks as specified by the composer?
Dan East
wow, this is old, i completely forgot about this.

actually jacco, you were talking about saving space using .mod files; so i went through the .mod files you were using in lemmings, and converting them to .xm (and removed like 17 instruments from two of the files that werent even being used) and saved about 72k, which is quite a difference when talking about saving space on a PPC. Thats almost enought room for another XM file

you can save even more using .s3m (about 96K) but s3ms aren't as flexible

Hm, I didn't know xm's are smaller than .mods. I use mods because they are smaller than .wavs.

That's what I meant when I said 'saving space'.
Dan: I once removed sample volume stuff to speed up the library. The reason for this is that each sample is multiplied by the channel volume. At 44.1Khz, 4 channels, that's more than 160.000 multiplies a second. I figured it would help to remove those. Later on, I put them back, since it sounded too bad. If you have your own musician however, he could take into account the lack of volume control and do good music without it. That would thus safe time, while you still keep the advantages of small music modules that can have near endless variations. That's still lots better than a 1 minute wave file.
I like how Hyperspace Delivery boy did it. They used ultra low bit-rate MP3s and play them back with FMOD. 42kb I believe.
-Hosed
I haven't posted to this forum in a long, long time - a buncha months ago I posted about trying to create a sound API library.
My greatest success before my free time dropped to zero was to create and mix a solid, stereophonic wave output and actually not experiencing any crashes (!). Obviously, not enough to write home about. I did some research and actually found some 3rd party sound multi-channel mixing API that appeared fairly decent, with a (I _think_) $99-per-game flat licensing fee.
Since developing that API seemed as fun as chewing tinfoil, I'd probably go that route. I'm pretty sure the API I saw didn't do any pitch or volume manipulation, but if you did that yourself than I bet you can turn a lot of mini WAVs into instruments and you have yourself a pocket orchestra.
- Richard
We hashed this out in another thread somewhere (maybe in Jacco's forum). There are two primary sound libraries available (for playing mod, xm, etc, as well as mixing waves). FMod is probably what you are talking about. I believe it's around $99 for "shareware" apps. The cost skyrockets for "commercial" apps (close to $1000 I believe). I don't know where the line is drawn between the two, but down the road if the FMod author ever decided you fell into the commercial category, you could be in trouble. The other alternative is MikMod. It is open source and free. I don't think it supports as many mod formats as FMod, but that is not a true issue for games. Of course you would pick a single supported format and stick with it for your game, as opposed to just trying to play whatever came along. I have heard anecdotal reports that FMod requires fewer CPU cycles to play a given mod than MikMod. It would be nice to quantify that exactly so developers could make a more educated decision. Apparently FMod creates a thread to handle the processing, which makes it a bit more difficult to determine its CPU use by timing update calls. However, a plugin that is nearly ready for DEXplor will make it easy to determine exactly how hard FMod is working.
Dan East
hang on, i thought they use fmod in snails - does that mean you guys spent $1000 just to get the game made?!
no, likely they paid $100 for it. read their site. They explain in detail who fits where quite clearly.
-Hosed
yeah okay, no need to be a dick about it.
heh, didn't mean to be. May have been a little curt, but it wasn't directed at anyone in particular.
-Hosed
Yep, mikmod is the way to go, I've got a .mod playing back at only 11KHz, mono etc, to drop cpu load, It sounds great.....
-brendan
Here are some "benchmarks" I completed with the new DEXplor plugin (it's not released to the public yet - sorry). Playing Jaybot's menu.xm from the Snails game at 11khz:
MikMod: 7% CPU Use
FMod: 6% CPU Use
(After I downloaded the FMod player I found it already displays its own CPU usage. Its value followed the value shown by DEXplor, so it appears to be accurate.)
Now for higher quality playback:
MikMod 44khz: 23% CPU Use
MikMod 22khz: 13% CPU Use
The FMod player has no configuration options, so I could not get it to play at a higher quality for comparison. If someone feels like building a simple test player that allows configuration options then I'll test it. I don't have the time to build it myself at the moment.
So the verdict; FMod performs marginally better than MikMod playing that particular xm mod. However, I bet that with some optimization, and perhaps ARM ASM work, MikMod could outperform FMod - for free.
Dan East
Thanks for your help, Dan. It seems clear that for a real live game developer, something that's open source and free and performs almost-equivalently to a not-free product is pretty close to night and day.
Another thought is to use the mixing libraries therein and skip the MOD libraries entirely, and just mix in MP3's using one of several publically available sources.
Or... here's a subversive thought... use the OGG/Vorbis sources, since the sound compression therein is state-of-the-art (I think around 30% the size of MP3s for the same quality) and it also is open source. And subversive thought #2, compress the MOD samples in Ogg/Vorbis, decompress on the fly, and that way you can utilize the MOD music library with cool sounding samples without the space-suckage of storing lots of big uncompressed samples, OR the CPU suckage of decompressing things on the fly.
Oh, if only I didn't have 15 other things to do
- Richard