[ODE] Easy Newbie Question

Jimmy jimmy at jimmysworld.org
Wed Jan 28 20:04:57 MST 2004

This is probably a little off topic, but I'm currently in the middle of
solving the same problem, so I figured I'd share.

I'm using C++, but the concept works well enough anywhere, I think.

I've solved this by making a singleton to take the position, type and
intensity  (some arbitrary calculation based on the interpenetration of
bodies, or their velocities) of sound effects and place them in a
priority queue to be played later.  The singleton can also be told that
a source should be blocked for x milliseconds.

By defining a source as a unsigned long, you can just send the body id's
along with the length of the sound sample and everything just magically
works out.  This is similar to your solution, but generally you want to
have more than one collision emit sound, just not more than one sound
from collision's between the same events.  Keeping a timer alone will
silence all collisions everywhere.

The other advantage to this system is that you can prioritize out, and
even cull sound effects which are farther away from your observer and/or
lower intensity.  If you're regulated to a fixed number of channels this
can be invaluable, or you might use all of your channels up on distant
effects, while something silently hits your player.

On Wed, 2004-01-28 at 17:38, coberr at scottsdaleins.com wrote:
> I have just started using ODE a little bit ago - and I think it is
> fantastic!
> However, I have a simple question:
> In my application, I want to play a sound when two objects collide.  In
> this case, there are shapes bouncing on a plane.
> Initially,  I have tried to play a sound everytime there is a collision.
> Specifically, I play a sound if dCollide() returns any contact points at
> all.  dCollide() is called from a callback registered with dSpaceCollide().
> The problem is that the sound is being played much too frequently -
> obviously many contact points are created within any given small timeframe.
> The solution I am considering is to only play a sound if there is a
> collision AND a certain amount of time has elapsed.
> My question is whether this is the best approach.
> Thanks in advance for any insight or advice
> Bob
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode

More information about the ODE mailing list