Sound effect from environment

Started by
4 comments, last by Kryzon 9 years, 10 months ago

Hey.

I'm currently facing the problem of how to implement sound effects emitted by the environment.

Examples for this would be a stream of lava, a river or any other objects that spans over a larger area.

I'm using the OpenAL API and I'm entirely unsure how to set the correct information on the sound source object:

This is easy to do for an object like an NPC or a sword-swing: Those have a well-defined single position in the game world,

so I just give OpenAL the position and it manages everything else.

But what about large objects that span a wide area?

Do I give them a position as well and 'move' the sound source?

Find the closest point between the listener and the object-boundary and position the sound source at that place?

That seems inefficient, because I'd had to do a ConvexSweepTest or something similar with Bullet whenever the player is moving,

for every environmental sound source in his vicinity.

I've never really done anything with 3D sound before and would like some pointers. smile.png

Advertisement

I'd be interested to see how other people handle this too.

My solution involves doing expensive calculations offline and pre-generating a map of volume and direction for each environmental "area" sound source (river, ocean, lava, etc...).

Several noise emitters placed in the world at regular intervals works like a charm.

I don't know if it's the case for OpenAL, but some audio engines, like Wwise, have the concept of multipoint emitters, which can use a single source over different positions. Barring that, it's hard to say whether it would be more efficient to place a series of different emitters or move one based on player location.

Several noise emitters placed in the world at regular intervals works like a charm.

just what i was thinking, for a system limited to point sound sources.

at a lower level, i'd probably use a separate channel for water,etc, (separate from the usual ambient channel), and vary the volume based on player BBox range to the source area. update volume X times per second, or once every X seconds, or once every X number of iterations of the sfx loop. more accurate range checks and more frequent volume adjustments would yield better 3d effects.

for even better 3d effect, range to each ear should be computed, and the left and right channels attenuated accordingly, also taking into account cutting the top end on signal sources behind the player. a 3d audio library will already be doing all this for a point source.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

If you have a stream of lava, you can project the player position onto a 3D linear spline that follows the river length-wise, and position the lava sound emitter at the result. This way the lava sound will always come from the point of the river that's closest to you.

For cuboid volumes such as a forest, for example, you can place one emitter near the ground-level of each face of the volume (except the top and bottom faces, perhaps).
When you're inside the volume, sound will come from all directions, and when you're outside, sound will mostly come from the face that's closest to you.

Most of the time, a clever positional trick allows you to use a single emitter to convey the atmosphere. In my understanding you need to keep the amount of emitters as low as possible.

This topic is closed to new replies.

Advertisement