Calculating sound volume (distance & speed)

This topic is 4129 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I want to calculate (aproximate) the sound volume of a bouncing ball, depending on the distance from the viewer and the speed at wich it hits the surface. I have a ball.z variable (distance from view) and a ySpeed variable, but I'm new to the 3rd dimension and I'm not sure of the exact formula for taking them both into acount. The Z depth ranges from -150 (front) to 200 (back), so in all it's 350 deep. The ySpeed variable can range from -3 (min) to around -100. The volume parameter has a range from 0 (silence) to 100 (full volume). I hope anybody can help me out with this...

Share on other sites
Well, my first guess would be to make the volume relative to the speed and relative to the inverse square of the distance from the player(though I doubt anyone would notice if you just used the inverse of the distance not squared). So that would be something like V= A*yspeed/(z+151) where A is some constant that could be found by plugging in your max and min values and solving so V has the desired max and min. Note I used +151 to prevent a division by zero that might occur if you used 150. Honestly though, the only way to know what sounds good would be to try several different formulas.

Share on other sites
I don't know the exact equations, but usually, volume is function of the inverse distance, and the speed of impact. Maybe some kind of polynomial, exponential equation.

Share on other sites
Volume = (((Current Distance)/(Max Distance))*((Max Volume)-(Min Volume)))+ (Min Volume)

Distance is the viewers distance from the starting point of the sound

or if you take the speed of the ball

CD = Current Distance
MD = Max Distance
MV = Max Volume
MnV = Min Volume
MS = Max Speed
MnS = Min Speed

(CD/MD)*((MV-MnV)*Abs(ySpeed/(MS-MnS)) = Volume

that looks right to me

so
(CD/MD)*((100)*Abs(ySpeed/(-100/-3))
= Volume

Share on other sites
I'm not feeling this inverse-linear dissipation of loudness.

Just like all radially-uniform phenomena in three dimensions, the energy of a sonic event evolves as the inverse-square of distance. This is direct from energy conservation. Now loudness is a logarithmic function of kinetic energy (of the air particles). So I get:

V(r) = V1 - 2ln((√2p)r) for r > 1/√2p

where V1 is the loudness at distance 1 from the source.
It seems a little counter-intuitive. Any guesses?

Share on other sites
The power drops off proportionally to the inverse squared distance, but what we hear is related to the amplitude of the wave. The power of a wave is proportional to the amplitude squared, so the amplitude is actually inversely proportional to distance (linear, not quadratic). Acoustics is confusing...

I think if you're going to be generating the sound wave, you can stop somewhere around here knowing that the amplitude is inversely proportional to distance. There's probably more complicated things that can be added to the model too...

If you actually want to measure how loud the sound will be perceived as opposed to just generating the sound, you need to run the sound wave through a psychological model.

Share on other sites
Modeling sound accurately is pretty hard. Doppler effect and speed of sound, environmental effects and various sort of filtering as the sound trasverse different mediums, and gets absorbed or bounces off surfaces.

But yeah, if you restrict yourself to seomething very simple such as...

float s1 = 0.03f;
float s2 = 1.0f;
float s3 = 0.05f;

float d1 = 0.03f;
float d2 = 0.9f;
float d3 = 0.01f;

volume_speed = s1 + s2 * (speed) + s3 * (speed * speed)
volume_dist = d1 + d2 * (dist) + d3 * (dist * dist)

volume = volume_speed / volume_dist;

Note that the polynomial coefficients s... and d... are almost completely random. It's just as an example on how to use a polynomial.

Share on other sites
Quote:
 Original post by VorpyThe power drops off proportionally to the inverse squared distance, but what we hear is related to the amplitude of the wave. The power of a wave is proportional to the amplitude squared, so the amplitude is actually inversely proportional to distance (linear, not quadratic).

Thanks for clearing that up.

Share on other sites
Woooo, thanks! Never thought sound could be so confusing (in 2d I simply used speed)...

Much of these examples go much further then what I need, I have used Alrecenks example with a few tweaks. Plus a cheap hack to keep the sound within it's limmits, but I think it works nicely (you can hear the result in this test environment).

Thanks for all the suggestions and options.

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 11
• 37
• 12
• 12
• 11
• Forum Statistics

• Total Topics
631414
• Total Posts
2999953
×