Measuring loudness, AI hearing

Started by
6 comments, last by Kylotan 17 years, 4 months ago
My question is pretty simple, since I know little about the specific details. Is it safe or reasonable to write an algorithm to measure sound length waves for the purpose of calculating a "loudness" value to be used in-game to allow AI to 'hear' the sound? Is there already some calculation that can determine the distance that characters (or humans) can hear sounds based on anything that can be extracted from binary sound data? There are so many variables that effect how well sounds can be heard (background noise, characters being engaged in intense unrelated activities), that I'm not worried about getting it perfect. A lose approximation is what I want. I can simply manually specify "loudness" values for each sound I add to the game. So if determining the value is complicated, I may be better off going that way. Any information or ideas are welcome.
Advertisement
looking here:
Decible
Human Hearing Response

You can see that what you need is a starting decible level (ie something off the first wiki page)
and scale that down by as (start / distance) to get the dB at the AI listener.

From there you can determine if the AI can hear it by setting some threshold (20 dB or so) and see if the sound
is that loud at the destination. OR you can look at the actuall frequency decomposition of the sound file,
and compare that to the charts on the second wiki page, inorder to see if the AI could hear that acutal sound.
Key thing is that the Hearing Response threshold curves are for equal intensity heard.
So it takes 40dB at 100Hz to sound as loud as only 10dB at 1kHz.(bottom curve)

You mention "background" noises too, so you can take the ambiant noise around the AI, and subtract that from
the loudness of the sound in question. If the difference is above the threshold, then your AI is
capable of distinguishning that sound from what is arround him.

--Edit: Someone else here with more knowlege of sound files should be able to say
how to get the relative dB values from a frequency decomposition of a sound file.
Though I do know you need some sort of FFT(Fast Fourier transform) to turn the binary data of something
like a .wav file into a frequency decomposition.

[Edited by - KulSeran on December 7, 2006 1:45:19 PM]
Quote:Original post by Kest
Is there already some calculation that can determine the distance that characters (or humans) can hear sounds based on anything that can be extracted from binary sound data? There are so many variables that effect how well sounds can be heard (background noise, characters being engaged in intense unrelated activities), that I'm not worried about getting it perfect. A lose approximation is what I want.

I can simply manually specify "loudness" values for each sound I add to the game. So if determining the value is complicated, I may be better off going that way.


I would give sounds loudness values, based on their actual average loudness - use a sound tool to calculate this. Bear in mind that decibels is not an absolute or linear scale, but really you want a linear value here (unless your maths skills are pretty good).

Then I'd use the inverse square law to approximate the loudness of that given sound at the distance from the listener.

Then, you can then set an arbitrary threshold below which nothing can be heard, and also compare the perceived level of 'interesting' sounds vs. the total of uninteresting sounds reaching the same actor. Arbitrary thresholds may seem like a hack but really you're just condensing a load of variable and complex factors into one simple one that fits your game.

Ultimately many psychoacoustic factors would come into it, but I think the simple procedure above would give you a simulation better than games like Thief had (which was already pretty good).
Way, way, way too complicated, guys.

The AI is either listening or it's not. It can either hear a certain sound within a certain distance or it can't. The parameters are then tweaked to best fit with the gameplay - leave reality out of it.
I appreciate all of the information. Both of you brought up some terms that I've not heard before, and so have something to learn more about.

Although I want sound to be a factor of gameplay, I'm already cutting really large corners as far as realism and accuracy go. For example, I don't want to perform complex calculations for sound collision, based on different materials, on walls and other objects, so the sound volume effects will likely pass right through them to avoid the computations.

I'm considering finding a way to calculate the distance that sounds would be heard along their entire timeline, then applying that intensity to a spherical volume that grows and shrinks as it plays. The radius could be a generic human-hearing scale. Then characters could scale all sound radius up or down based on their own hearing ability. Certain species could use a scale of 1.4 for example, meaning 140% human hearing ability.

But as far as realism goes, I'm not even sure I want it. In a realistic simulation, a gunshot would be heard by everyone in a building, and possibly a few blocks around it. In my simulation, it's doubtful that everyone on a single floor of the building will hear it. So I'm really just looking for a way to parse through the sound data and extract a meaningful value over the timeline to apply to the simple spherical scaling.

Thanks again for the help [smile]
Quote:Original post by Kenbar
Way, way, way too complicated, guys.

The AI is either listening or it's not. It can either hear a certain sound within a certain distance or it can't. The parameters are then tweaked to best fit with the gameplay - leave reality out of it.


Never played Thief, have you?

If a guard is walking down a marble hallway in full armour, you wouldn't expect him to hear you dropping an apple on a carpet 15 paces away. However, if he's stood absolutely still in that hallway and making no noise of his own, you would. Similarly, you expect to be able to get away with making more noise from a larger distance without attracting the guard's attention. This is absolutely crucial to the gameplay. I'm not saying you want to model scientifically measured decibel levels at each frequency and so on. I'm just saying that taking the proper distance equation into account and comparing to the other ambient sounds will give you authentic-feeling gameplay that a naive thresholded distance never will.

I think we're on the same page. All you're varying is whether the AI can hear you or not - you can make it as simple or as complex as you like. My point was that doing realtime or offline analysis of the "loudness" of an individual sound is unnecessary, which you appear to agree with.

By all means pay homage to the propper fall-off curve, but it is ultimately irrelevant because you do what works for the gameplay.

I played Thief I and II and played with the mapping tools for Thief II. Great games.
Quote:Original post by Kenbar
My point was that doing realtime or offline analysis of the "loudness" of an individual sound is unnecessary, which you appear to agree with.


Some sound effects are louder than others though, so it helps to run them through a sound editor to determine the relative levels, rather than having to do them by trial and error, that's all I meant by using a sound tool to calculate it. It would just be a single click in a menu somewhere.

This topic is closed to new replies.

Advertisement