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.

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

2 Answers 2

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 )
        return;

    // 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. –  hcris 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 –  hcris Dec 16 '10 at 10:38

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.