11
\$\begingroup\$

I'm new to game programming, although I have some years of experience in console/web development. My problem is not so much that I can't find what I'm looking for, it's just that I don't have the terminology to actually perform a successful search.

I am looking for a physics engine which has great focus on sounds. In fact, I do not care at all for anything else. What I mean is better explained by an example:

Suppose a 1st person type game. You are facing North, and someone somewhere around you throws a flute at you (nevermind the absurdity of the situation). The flute spins while it is on its way, making sounds through its holes. There is a wind of say, 5 knots South.

I imagine a physics engine will be capable of calculating the trajectory of the flute, as well as the direction it takes after it hits. What I want is for the physics engine to calculate the precise sounds it will make, from any listener's perspective.

Does any such engine exists? If there are several, which one would be best for the example above?

\$\endgroup\$

8 Answers 8

10
\$\begingroup\$

You are asking the wrong question. You're making the mistake many new game programmers make. Games are not perfect simulations, they aren't even close. Games simulate just enough to be fun/interesting. Everything else is faked.

Case in point:
World of Goo: simulates mass, tensile strength, and elasticity. The rest is faked because it doesn't add the feel of the game. For instance it doesn't simulate gravity. All objects accelerate down with constant force. Boyancy is faked. Ballons pull up with a constant force and goo balls under water experience a constant upward force as well. This all works great for the game. It would however break down if you tried to make a space elevator using World of Goo's physics engine.

Lets imagine a near perfect physics based sound engine. What about environmental effects? Is the flute in a cave or in a field. Does the engine provide a predefined set of environments(how many?) or does it figure it out by calculating the actual physical topography(yeah right)? Does the player have directional ears (ala human) or just ear holes (ala dolphin or alien) or multidirectional like an animal? Is the air hot? How humid is it. This list can quickly get out of control.

Now assume for a moment such true physics sound engine existed. Would you really want to use it to make a game? How long would it take you to define the sound of flute flying through the air. How many parameter do you have to get just right (100's?).

What you should have asked is:
How can I simulate the sound a flute when it flies past the player?

OpenAL can do what you want.

  • Directional listener
  • Directional sound sources
  • source velocities and doppler effects.

I would suggest having a repeating sound effect of a spinning flute. Input the player position and the flute's position/velocity. Skip the directional stuff for now.
You could record the sound that comes from each end of a flute as the air flows by and have the flute use two sound sources. But I doubt it would be worth the effort unless the whole game mechanic revolved around thrown and spinning flutes.

\$\endgroup\$
3
  • \$\begingroup\$ Well, the whole game idea revolves around moving objects making sound. The example given is over-complex on purpose, however the game idea does involve realistically-sounding objects in movement. \$\endgroup\$ Feb 27, 2011 at 8:11
  • \$\begingroup\$ Most parameters would actually be controlled: consider a closed (sealed), cubic room with walls of a particular material (of which properties I define), air temp, pressure, humidity, etc are all controlled. Ears are human. I don't even need to consider the rest of the body. In fact, instead of black-listing, I can specify exactly which params I use, and define (constant) all the rest. It's my (virtual) world: I define it as I want it to be. \$\endgroup\$ Feb 27, 2011 at 8:56
  • \$\begingroup\$ My point was that the amount of effort that such an audio engine would require in the general case are not worth it. Especially when talented sound engineers can very convincingly fake any effects you need. Doppler is built in. echo, damping, etc can all be done with filtering. \$\endgroup\$
    – deft_code
    Feb 28, 2011 at 18:12
8
\$\begingroup\$

You want physical modeling? Try the Synthesis Toolkit:

https://ccrma.stanford.edu/software/stk/classstk_1_1Flute.html.

You'll have to write the glue code which sets the wind speed / amplitude yourself.

What you're asking for hasn't really been invented yet. We're getting close though- check this out, I saw it the other day:

http://www.physorg.com/news198351307.html

\$\endgroup\$
1
  • \$\begingroup\$ Interesting stuff. This is what I mean, and it being not done yet does not hinder me. I do not plan to begin actual (non-conceptual) work on it before 1-2 years. \$\endgroup\$ Feb 27, 2011 at 8:28
4
\$\begingroup\$

I doubt you'll find a physics-audio engine. What is more likely is to use any physics engine you like (such as Bullet) and use OpenAL for sound. Calculate the position of the flute, and use that as the position of the Source.

\$\endgroup\$
9
  • \$\begingroup\$ I want quite a bit more than that though. \$\endgroup\$ Feb 25, 2011 at 11:10
  • 1
    \$\begingroup\$ What more do you want? With my suggestion, you can have the position of the sound change every frame. I think I'm missing something. \$\endgroup\$ Feb 25, 2011 at 11:12
  • 6
    \$\begingroup\$ I think he means simulating the air waves and other vibrations in order to generate the sounds. And sure that's possible, but no computer (except maybe some super computer clusters) could calculate that for any useful size space in real time, so no, if you mean that then there is no such thing (nor is there any real need, use the physics engine and read collision data to play an appropriate sample is "close enough"). \$\endgroup\$
    – Elva
    Feb 25, 2011 at 11:59
  • 3
    \$\begingroup\$ If you want to get that advanced, not only is there a)Like Yourdoom said, no way that a normal computer could do it, and b)nobody would be able to tell the difference. \$\endgroup\$ Feb 25, 2011 at 12:00
  • 3
    \$\begingroup\$ There is still plenty that modern games do (and higher-level APIs like FMOD provide) that OpenAL cannot do, or at least does not do out of the box - such as (geometric) volume-based effectors, which can be additionally hooked up to portals to simulate audio passing through multiple rooms. It is not common, but it is done, and you can tell the difference. \$\endgroup\$
    – user744
    Feb 25, 2011 at 22:20
4
\$\begingroup\$

Phya is a "physical sampling" based collision audio synthesis library which can be driven by a game physics engine. (Bullet was used in the examples)

http://www.zenprobe.com/phya/

Not sure what the latest is, the last site update is over year ago now.

It is not so much geared to modeling resonance of air in a volume, but could perhaps be a good example of how to drive real-time audio synthesis from physics.

I think this does not need to be an impossibly cpu-expensive undertaking, The problem stated is entirely deterministic and should be achievable on modern hardware. (at least to a level suitable for an entertainment/learning product.)

The question to answer is how fully do you need to simulate, and how much can you fake? For audio just having some kind of realtime modulation of sound in a reasonably convincing manner gets you a lot without having to model acoustic vibrations down to the molecule.

Maybe this helps. Good question, btw.

-j

\$\endgroup\$
1
  • \$\begingroup\$ I can fake a lot. Just... much less than contemporary video games. Which is the point: I'm not creating a video game, but an audio game. Kinda. \$\endgroup\$ Feb 27, 2011 at 8:41
3
\$\begingroup\$

Actually doing an accurate simulation of the physics involved here would be substantially more complex (and computationally expensive) than a run-of-the-mill physics system like Havok or Bullet. A traditional physics system is optimized for rigid bodies and soft bodies, both of which are limited in their mesh complexity for speed reasons.

Sound, on the other hand, is a propagation of waves through air, and the frequencies generated by something like your example are dependent on tons and tons of properties. What material it made of? What mathematical model should we use for air particles interacting with that material? If it's a tube shape, what are the dimensions of the tube? (This determines the resonant frequency.) Etc., etc.

On top of all of this, you've got to run a pretty sophisticated particle simulation to model the air, as well as extracting particle motions waves which are essentially the sound waves hitting your eardrums. And let's not even mention the eardrums, because the resonance of the waves in your ear canal affects what you hear, too.

All in all, this is way too much simulation for a current game to perform, especially if you have any hope of an interactive frame rate. As deft_code noted, games are rarely accurate simulations, but rather gloriously faked ones. The best way to approach this would probably be to start with a large sound sample set and start running things through a DSP until you've got a grasp of how you can impact the effect of those sounds. DSPs are definitely fast enough for real-time games, and if the sound would be a big component then it makes sense to devote a decent chunk of your frame time to sound processing.

tl;dr: Accurate simulation is probably out the question for many years to come. Great games fake it. With a large enough sample set and enough DSP tweaking you can probably fake it, too.

\$\endgroup\$
2
\$\begingroup\$

Check our approach.

http://dsp.agh.edu.pl/en:research:rayav

Developed library utilizes beamtracing to provide user with realistic audio auralization. All audio effects are computed based on the actual geometry of a given game level as well as its acoustic properties (acoustic materials, air attenuation). The sound changes dynamically along with movement of the game character and sound sources. Sound path creation algorithm supports phenomena like specular reflections, diffuse reflections and edge diffraction, whilst audio processing supports signal filtering (modelling air dumping, reflection/diffraction impact and so on), Doppler effect modelling and spatial effects. Finally directional sound is implemented using HRTF per each soundpath.

\$\endgroup\$
0
\$\begingroup\$

I realize this is an old question, but things have been progressing in the last couple of years, and what you are describing is becoming more and more feasible, computationally.

Tools like Synthesis Toolkit are used to answer the following sort of question: "My physics engine told me that the flute is vibrating in such-and-such manner. What note does that produce?"

There is another major question that must be answered, though: "What does this note sound like from the listener's position?"

It is a common misconception that audio APIs like OpenAL take care of this. In fact, all they do is what is called positional audio. They do not model sound propagation: the interactions between the sound waves and the environment. Sound propagation involves answering questions like:

  • Is this room large enough for there to be noticeable reverb?
  • Or does the furniture in the room absorb most of the sound?
  • When standing outdoors, should I hear echoes from a distant hill? A nearby building?
  • Does the sound dissipate over long distances?
  • Is the sound source occluded (hidden) from the listener?
  • If so, are there alternate routes that sound waves can use to reach the listener? Perhaps from under a closed door, around a hallway corner, or through a vent?

Phonon is an audio-physics engine that answers these questions. (Full disclosure: I am involved in developing Phonon.) With Phonon, the user needs to specify a very small set of parameters (absorption and scattering coefficients). Phonon then performs just enough computation to be able to convincingly recreate sound propagation effects for the listener.

Phonon is currently available as a plugin for Unity. Apart from PC and mobile, Phonon can also run on VR platforms like Oculus Rift, and it makes a noticeable difference there too.

Hope this helps!

\$\endgroup\$
0
\$\begingroup\$

When reading your question, I can translate it two ways.

  1. Is there an engine that can create sounds based on physical simulations? Such as air blowing across a reed, or a hammer striking a string?

In gaming? not that I've heard of.

  1. Is there an engine that plays pre-existing sounds but modifies them based on physical information such as distance from microphone to simulate a "surround sound experience"?

Yes! they are called "3D sound engines" a well-known one is OpenAL.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged .