Advertisement Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Sound Sources & Ambient

Sign in to follow this  


Sound Sources

Yesterday I added static sound sources to the game. The first step was to add them to the editor. I originall had in mind
a fairly complex scheme where each sound was represented by an OOBB. Within the OOBB, a character would hear the sound at
full volume, but outside it, it would hear the sound falloff. Then I realized that this wouldn't give proper panning effects,
and was more complicated than it needed to be.

Rather, I should just allow the level designer to place sound sources as points in the editor. The nearer you are to the point, the louder it is. Large sources, like a river, would need multiple sound sources placed to sound right.

Here is a shot of the 4 sound sources that represent the water.

Once things were working right in the editor, I added the sound sources to the level export process, and added code to read them in to the game engine. The whole thing probably took 4-5 hours of coding & debugging to do, which seems like a lot, and it tempted me to try to make the process easier, but that would undoubtedly take more than 4 hours to change, and chances are I will only need to add one or two more editable objects to the editor and game, and it's not clear how much time another system would save, so it doesn't seem worth the tradeoff.

In the editor, you can scale a sphere that represents the sound range. In the game, however, this value isn't used yet. I'm using FMOD, and treating the sound sources as 3D sounds. This gives the sounds an implicit volume just based on distance. I'm not sure, but I may be able to use the Channel::SetVolume method on top of the default 3D attenuation to adjust it. Another option would be to adjust the position I pass to fmod each frame.

With 3D sounds, you pass in the player location and the sound locations. I update the sound locations every frame, in case they're moving. FMOD does the subtraction to figure out the proper attenuation relative to the listener. If I want to manually force the sound to be quieter, I can move the sound into 'listener space', then scale the position up, then go back into world space, then pass in this virtual sound position.

Ambient Lighting

A while ago I experimented with putting an ambient light grid all through space. This stopped working when I changed my A* implementation, because I was using the 2d grid to store the ambient light info. So, I went back to the old scheme of raycasts, or at least I thought I did. I had a devil of a time getting the latest batch of md2 files into the game such that they weren't too dark. Turns out my ambient was going through the old calculation for the ambient grid and coming up with zero, since the grid was unpopulated. So, I fixed that and put back the old raycast method. Unfortunately, now the enemy characters look washed out.

Here is a shot of my new pillar models, and the washed-out characters :

Sign in to follow this  


Recommended Comments

If you can take control of how the volume is attenuated, couldn't you create new "shapes" for the editor?

Looking at your screenshot for the 4 sound sources along the water, that would probably be easier/better (??) if it were an ellipsoid or rectangular shape rather than 4 overlapping circles.

Depending on how sharp the falloff for the volume is, that 4-circle pattern could sound a bit odd if the player runs through them - difficult to explain without a diagram though [headshake].


Share this comment

Link to comment
I actually thought the same thing as Jack when I read your description. Having multiple sound sources to describe the river will make the sound oscillate louder and softer as you walk along the river bank.

One of the options that you mentioned Sim was to manipulate the "virtual" position of the sound before sending it to fmod. In the case of the river, you could define a line sound emitter to be placed along the river. Then the sound could be placed with a simple shortest distance from a point to a line algorithm. Then you wouldn't have to worry about changes in volume when there really shouldn't be any.

The different shapes that Jack mentions would lend themselves to an object oriented implementation for calculating the virtual distance to the sound receiver.

Of course, it will take more dev time and if your current system is good enough, then it is good enough :)

Share this comment

Link to comment
Great feedback!

I was having the same idea when I woke up this morning. For instance, a capsule-type falloff would be the best overall shape, b/c it can be reduced to a sphere, or be more rectangular.

But, I just did a test. I changed that level to 3 sound spheres, where they overlap near the bridges. That way the sound is a bit less over the bridge, which you might expect b/c the bridge is blocking some of the sound.

I had to fix a but that was only playing one sound source. I have a system in there to block too many of the same sound going off at once. Sometimes the AI all fires at once, and you get nice clamping sounds, so I put in code to disallow more than one of the same sound within some # of milliseconds. Of course, when it's initializing the level, all sounds come in at the same time, so I had to make an exception for max_priority sounds.

Anyway, it sounds fine in game with 3 point sound sources, so I'm leaving it as is for now...

Share this comment

Link to comment
Your screenshot makes it impossible for me to read your journal without horizontal scrolling. Could you use height and width attributes on your <img> tag, perhaps with a link to the full-size image?

I'm really interested in what you're working on. Thanks. [smile]

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!