Game Development Community

Sound update (refactoring)

by Marcelo Oliveira · in Torque Game Engine · 04/24/2004 (1:58 pm) · 43 replies

Hello everyone,

Seems that many people there are a bit complained about the sound issues of the engine, while the graphics area is constantly being updated, the sound is a bit forgotten, so I've decided to do some upgrades into it.

Analizing the audio sources files, seems that there's a lot of duplicated code, for example, there are funcions and classes for looping and for streaming sounds, the non looping sounds are stored in global statics, etc.

So I've remade all the code, always following the OpenAL specification, as an example, the audio.cc source gone from 2466 lines to 938, and it's seems blazing fast and stable in my tests.

I've also decided to control the sound falloff entirely in torque, disabling any falloff and manually controlling it by using AL_GAIN, this way I can detect sound and cull the sounds with great precision.

So, here's a list of implemented features:

- Precise sound falloff and culling: controlled by TGE only, providing a great control of the sounds distance, as seen is this graphic:

raintree.hpg.com.br/oal_graph1.gifreferenceDistance = 100
maxDistance = 1000
The red line is the usual Inverse Distance (used in DS and OpenAL), the black line is the sound falloff when the MuteAtMaxDistance flag is enabled, providing an smooth but precise falloff.

- Code cleanup: Reuse of common code, instead of creating classes and arrays for looping, other for streaming, other for normal sounds, etc.

- Volume priority: Only the 16 (configurable amount) highest volume sounds are processed. The others are set to an culled state, but go back to playing state soon as an slot is avaiable or reaches great priority than other playing sound.

- Doppler:Enable the doppler effects on sources (using the already posted resource).

- Other bug fixes:
-AudioDatablocks missing links (when you reference a description in the profile it may be not created yet)

Here's the implementation plans:
- Enable EAX and environment stuff.
- Refactoring of AudioEmmiter (code cleanup).
- Implementation of visual feedback of AudioEmmiter (posted resource).


Well, what I need from you:
- Send lists of bug to be fixed.
- And wanted improvements.
- On finished, help testing on different platforms and machines (I've only have windows)

After the code is finished I'll submit it as a patch to garagegames (and also setup a resource).

Thanks
#21
05/24/2004 (6:48 pm)
And we're coming up with new reasons all the time. :)

Marcelo and I are indeed working together on this. I'm not making any promises, but we're making good progress. Assuming Marcelo continues writing high quality code like he has so far, you'll be seeing some neat new audio code. :)
#22
05/24/2004 (10:29 pm)
Sounds like some good news. I hope this gets into Head.
#23
07/28/2004 (12:50 pm)
I'm without time to work on this right now, but most of the code is done and we are using it in our games. I think I'll post a resource so the community can test it, but I think that the full version (with support for multiple API's such as OpenAL and DirectSound) will be TSE only.
#24
10/15/2004 (2:19 am)
Bump , any progress with this at all esp the tse stuff?
#25
10/15/2004 (4:07 am)
Yeah, it would be cool to hear something about this.

Sound is such a important feature in a game.
#26
10/15/2004 (7:29 am)
The audio layer will change so much that it will take more time than I expected (it will look like TSE GFX layer), but I can submit a resource with some previous refactoring, at least it fixes many problems people are having with audio in TGE.
#27
10/15/2004 (7:31 am)
If it is no problem for you Marcelo, that would be more than great.
#28
10/15/2004 (7:31 am)
Im looking manyly at TSE stuff at the momment , might intergrate fmod or fmod Ex for the momment
#29
10/15/2004 (1:01 pm)
Marcelo, I'd definitely like to see what you've done so far as a resource, and perhaps we'll incorporate it into HEAD. Thanks if you have time to submit that. Or email me joshw@garagegames.com and we can take care of it for ya.

Going even further and making a GFX-like layer would be great, but I'd definitely like to take what we can get right now. Thanks. :)
#30
10/15/2004 (1:44 pm)
Well, so far we used it in two games and seems that no critical bugs appeared, so I'll prepare a resource, but please note that will be an outdated version, since I'm now working on a GFX-like layer (maybe TSE only?)

Before moving into HEAD it's better to keep it for some weeks as a resource for bug and compatibility testing.

Let the diff begin :)
#31
11/03/2004 (9:38 am)
Just an update.

I'm having some problems with OpenAL on Windows XP, soon as it got fixed I'll post the source, sorry for the delay.
#32
11/03/2004 (10:42 am)
Very cool Marcelo :) I'm sure many look forward to this.
#33
11/09/2004 (6:07 pm)
Any news on this?
#34
11/29/2004 (10:09 pm)
I have a problem with OpenAL and sound acceleration where the sounds from player's gun, vehicle, etc are all very VERY quiet, if I turn my sound acceleration down from the control panel, suddenly the sounds sound like they should, I'm using 1.3 self-installer and windows XP

(interesting as well: with this problem, the player's gun is loud enough to hear when firing straight up or down but gets quieter as aim moves toward horizon)
#35
11/30/2004 (6:55 am)
This is awesome Marcelo. Since you asked for improvement suggestions, I have one for you. I want to have AI that can "hear" in a realistic manner. I havent really looked into the current TGE sound implemention too much yet. But from just a quick glance, I would need to implement a bunch of "hooks" all over the place to track all of the sounds and get the information I need about those sounds. And I dont know maybe I dont need to do this, again I have not looked closely at it yet. Anyway since you are rewriting the sound engine, it would be nice if you kept this in mind.

At the very minimum I would like a central location where I can check volume and position of all the sounds currently playing whether audible or not. So basically some sort of data structure that contains all the sounds. And it would be nice for that data structure to have as much information as possible. But other than position and volume I dont know what else I would need for AI right now, but I bet there is other information I could use.

Oh and if there already is a data structure like this in TGE, what and where is it?
#36
11/30/2004 (7:02 am)
Carlos,

AFAIK that's not a sound change, it's just an AI change. The AI doesn't REALLY hear, it just simulates it.
#37
11/30/2004 (9:06 am)
I think that I found a "solution" to the Win XP crash, I've downloaded OpenAL CVS and compiled the dll's, and the problem seems to go away, but another problem appeared, if you try to change the default doppler scale all the sounds get messed.

So I'll supply the dll renamed as DefOpenAL32.dll, if the game can't find the lib in the system directory it will use the supplied one. This way if an user complains about game crashes you can suggest him to delete the OpenAL32.dll from the System32 directory.

Carlos, really the AI can't use the sound system because it's is mainly client based, but there will be functions to calculate the falloff that can be run on server too.
#38
11/30/2004 (10:52 am)
Stefan - Of course AI cant really hear, of course its simulated. But that doesnt mean you cant have a central database of all the current sounds. If I was designing an engine from scratch, it would be the sound engine's job to store this. Im not asking him to calculate the AI portion of hearing, I can do that easily. What Im asking for a central location where I can easily extract information about each sound. Like storing position and volume, especially position cause I can fudge volume. The actual algorithm for how that sound travels through the world would be my job. Understand? Id be happy to explain with pseudo-code or something if you really care that much.

Marcelo - Thats a shame, guess Ill have put in all those hooks to collect the sounds into one list. Still be nice to have EAX effects and all that. :)
#39
12/13/2004 (6:32 pm)
Also curious as to how this is coming along. Is it ready to be released as a resource?
#40
12/14/2004 (3:21 am)
I posted it as a resource, it should be approved soon I hope. :)