Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I generate somewhat realistic sound effects for collisions in a physics engine that simulates lots of objects?

E.g. take >10 marbles that are bouncing off walls and off each other.

If I generate a sound for each collision I would quickly overload the system (Windows Phone 7).

Is there an algorithm that lets me combine multiple collisions to create fewer sound effect instances?

share|improve this question
up vote 2 down vote accepted

Usually what you do in this case is let the sound system handle it.

So somewhere there's a collision happening. And where that collision happens you call a "play bounce sound" function.

In pseudocode just change your sound class to do something like this

void Update()
    timeSinceLastBounceSound += Time.deltaTime;

void PlayBounceSound()
    if( timeSinceLastBounceSound < someThreshold )

    // do whatever you do to play the sound
share|improve this answer
I basically took your approach but used time slices because they make it easier to calculate the volume. – laktak Dec 16 '10 at 10:40

You could create a new sound that is a sort of "many marbles hitting at once" sound, then play it if there are more than 10 active collisions at once. Play any individual collision under 10, and then the "many marbles" sound if there are more than 10.

Think of it like simulating a crowd applauding. At some point it just sounds like a crowd applauding, not a collection of individual claps.

share|improve this answer
+1 because it's an interesting idea – laktak Dec 16 '10 at 10:38

Your Answer


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.