Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

5 Answers 5

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

share|improve this answer
    
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. –  Félix Saparelli Feb 27 '11 at 8:28
    
Niiiiice. Thanks for the STK ^_^ –  Ray Dey Feb 27 '11 at 16:32
add comment

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.

share|improve this answer
    
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. –  Félix Saparelli Feb 27 '11 at 8:11
    
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. –  Félix Saparelli Feb 27 '11 at 8:56
    
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. –  deft_code Feb 28 '11 at 18:12
add comment

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.

share|improve this answer
    
I want quite a bit more than that though. –  Félix Saparelli Feb 25 '11 at 11:10
1  
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. –  The Communist Duck Feb 25 '11 at 11:12
6  
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"). –  Kevin van der Velden Feb 25 '11 at 11:59
3  
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. –  The Communist Duck Feb 25 '11 at 12:00
3  
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. –  user744 Feb 25 '11 at 22:20
show 4 more comments

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

share|improve this answer
    
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. –  Félix Saparelli Feb 27 '11 at 8:41
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.