News | Forum | People | FAQ | Links | Search | Register | Log in
Mapping Help
This is the place to ask about mapping problems, techniques, and bug fixing, and pretty much anything else you want to do in the level editor.

For questions about coding, check out the Coding Help thread: https://www.celephais.net/board/view_thread.php?id=60097
First | Previous | Next | Last
Sound Thinking 
We can pick atten to lie between 0 and 4. The engine now defines:

nom_atten = atten / 1000

dist = nom_atten * length(sound.origin - player.origin);

So the crucial thing here is to notice how the attenuation affects the distance.
Attenuation 2 samples are effectively twice as far away as attenuation 1 sounds.
Attenuation 0 sounds are always treated as distance 0 away.

The next thing you need to know is that the volume is multiplied by
( 1 - dist) * rscale in the right ear and (1 - dist) * lscale in the left ear.

rscale is equal to 1 + v_right*normalise(sound.origin - player.origin)
lscale is equal to 1 - v_right*normalise(sound.origin - player.origin)

Don't worry too much about what rscale and lscale mean, just be aware that they are never negative and sum to 2.

We need to compute when both the left and right ear go to zero volume, as in that case the sound is not played.
We know that lscale and rscale are never both equal to 0. So the only case we need to think about is

1 - dist <= 0

this implies that
dist >= 1
so
nom_atten * length(sound.origin - player.origin) >= 1

atten * length(sound.origin - player.origin) >= 1000

It is best to keep the inequality in this form, so that you don't have to worry about dividing by 0 if either the attenuation or the length go to zero.

In real terms, this means a sound with attenuation 1 is audible 1000 units away, attenuation 2 is 500 units away, etc. 
First | Previous | Next | Last
You must be logged in to post in this thread.
Website copyright © 2002-2025 John Fitzgibbons. All posts are copyright their respective authors.