Estimating Volume for New Sounds

From The DarkMod Wiki
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Originally written by Ishtvan on http://forums.thedarkmod.com/topic/3271

You may be wondering how to choose values for the volume of a sound. This document attempts to provide some guidance.

Sound volumes are stored in decibels (dB) of relative sound power, called Sound Power Level or Sound Watt Level:

SWL [dB] = 10*log_10( power in Watts/1E-12 Watts )

There are several approaches to choosing a volume for a new sound. Because the sound propagation system uses a pretty realistic falloff model, starting with a realistic value and then tweaking for gameplay works much better than guessing a sound volume via trial and error. Just a small variation in dB can have a huge effect on AI respones, so it would take forever to find the right behavior starting from a random guess.

Volume Guestimation Method #1 : Direct measurement in real life

If you are a sound engineer and you own a sound meter, measure the SPL at 1 meter from the sound. Then add about 8 to the SPL get the SWL (the number "8" assumes you are in a room with a hard floor, and the sound is located pretty close to the floor).

Volume Guestimation Method #2: Look it up online

Sound values for a variety of sounds may be found online. Some sites don't say whether it is SPL or SWL level; you have to try and judge it from the lowest sound they list.

This is what our very own MrD has to say:

Regarding your steps question - a whisper heard from 10cm is about 30dB loud. A normal talk between two people is approx 70 dB loud. Using these two as reference I'd say normal steps would be in the 50dB area, while running 60dB at least (add clothing noises, breathing etc). Sneaking steps would be in the 30dB area.

A 10dB increase in loudness is perceived twice as loud as the original sound. A 20db increase in loudness is perceived 4 times as loud as the original sound. Some trivia: sound becomes painful at 120dB and at 180dB your hearing tissue dies.

Here's another site that lists some SWL values:

From this site: http://www.kemt.fei.tuke.sk/Predmety/KEMT320_EA/_web/Online_Course_on_Acoustics/hearing.html

Sound Power, dB Re 10 -12 Watts
Saturn rocket 200
After burning jet engine 170
75 piece orchestra 140
Large chipping hammer 120
Blaring radio 110
Auto on highway 100
Food blenders-upper range 90
Dishwashers-upper range 80
Voice-conversational level 70
Voice-very soft whisper 30
Lowest audible sound for persons with excellent hearing 0

So you could look at that list, and think "Hmm, well, I guess a fire arrow exploding is somewhere between a large jackhammer and a 75 piece orchestra..."

By default, our DarkMod AI have a hearing threshold of 20 dB SPL (note SPL is the "sound pressure level" of the sound after it has propagated some distance. Do not confuse it with SWL, which is the total power at the point of the sound). See below for more info.

If you want, you can change the threshold of hearing on an individual AI by setting the spawnarg: "alert_aud_thresh". This threshold determines whether sounds are heard, so it has a slightly different effect than "acuity_aud" which multiplies the loudness of sounds that are definitely heard.

Volume Guestimation Method #3: Gameplay Driven

The default threshold of hearing in the ingame sound propagation system is 20 dB SPL for humans.

With the current AI, it takes two noises right on the threshold of their hearing for them to go into alert state #1.

Based on gameplay, decide the max distance that you want your sound to cause a level 1 alert (this is the lowest alert level, when the AI pause briefly in whatever they were doing and say something like "hmm, what was that?" and have a chance of looking over their shoulder if the sound came from behind them)

Then, use this formula to calculate the SWL of your sound for the desired distance:

SPL = SWL - 20*log_10(distance) - 8

Distance is where the AI just hear the sound, and is based on your gameplay decision. Set the SPL to 20 (threshold of audibility), but also keep in mind that it causes 2 sounds at 20dB SPL to reach alert state #1 (with default settings).

At default settings, an alertstate of 1 takes '2' alert units, where 1 alert unit is a barely perceptible sound. The formula I'm using to convert sound to alert units is: loudness = sound volume - 20 dB

So if you set your sound to 22 dB, and have an alert #1 threshold of "2" alert units, then your sound will definitely alert AI with only a single instance (as opposed to 2 instances of your sound at 20 dB).

So, figure out the distance that you want your sound to DEFINITELY send AI to alert state #1, and solve:

Solve:

Given threshold SPL = 22 :
22 = SWL - 20*log(dist) - 8
30 = SWL -20 * log_10( dist [meters] )

Assuming you set the threshold for AI Alert #1 to "2" alert units: Here is the formula for calculating the volume of the sound you should put in:

SWL = 30 + 20 * log_10( your desired distance for definite AI alert #1 [meters] )

If there is enough demand, I could make a little console command calculator for that or something.

Miscellaneous Tips and Notes

Tip: Rapid Volume Testing Ingame

It is a pain to change the def file and restart D3 every time you want to tweak a volume. Instead, set some volume for your sound that is your best guess. Then, when testing ingame with AI, use the consolve variable: tdm_ai_sndvol to turn the volume up and down for all sounds that AI hear, including your sound. When you see the behavior you want from the AI, record what you have set for tdm_ai_sndvol and add the volume offset to the test volume that you started with.

Warning: Objects in Game Are Farther Than They Appear

Finally, consider the fact that in FPS games, distances look a lot closer than they actually are due to perspective distortion. So a distance of 10 m in straight 3d coordinates might look more like 8m or something ingame. Keep that in mind when you're figuring out how far a sound should go in the gameplay.

I found that a standard walking footstep of 45 dB works pretty well. This corresponds to about 5.6 meters to definitely bring an AI to alert state #1 with 1 footstep, but ingame the distance of 5.6 meters looks much closer than it actually is.

Side note: The advantage of using SWL for a measure of sound: Easy physics to sound conversion

By using SWL, which is measured in Joules per second, we are completely compatible with D3's system that already calculates sound as a function of kinetic energy * some fraction for how much sound is converted into energy.

This is not yet implemented yet for our soundprop, but it will be pretty easy to calculate the kinetic energy the object had before collision, and right after (assuming its potential energy doesn't change if we take the measurement before it has time to bounce back up), then we use the fact that a frame is 1/60th of a second to calculate the energy lost per time, multiply that by some fraction for how much energy gets converted into sound for the given surface types of both the object that falls and the surface it falls on (wood cup falling on stone, etc), and presto! Instant physics to sound transformation!

NOTE: D3 already does this for sounds you can hear (although their formula is not exact).. they also take the surface that's impacted into account (wood stone etc), but not the material of the object that falls on it. This would be an easy hack for us to just check the falling object's material as well, and put those into a matrix to get back a fraction for collision energy converted to sound.

You'll notice this for audible sounds in D3 if you drop an idMoveable from some height, it sounds louder the higher up you drop it (up to a point; they don't want to blow out people's speakers)