• Advertisement

Archived

This topic is now archived and is closed to further replies.

Guest Anonymous Poster

DirectSound, volume, and distance

This topic is 6685 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Guest Anonymous Poster
I'm sure somebody out there must have done something like
this similiar. Am I wrong to try to use equations to calculate
panning and sound volume based on distance for a 2D scrolling game?
I don't see how D3D Sound would help me with this. Anyone
have some advice on this?

Share this post


Link to post
Share on other sites
Advertisement
Hmm. Panning should be fairly easy; you just compare object's screen x-coordinate to midpoint of screen and set pan accordingly...
(-10000dB when object's far enough at left)

dB level is quite basic physics, but I don't have my physics book with me, so I can give only hunches;

dB = 20 * log ( I / I0 )

I = Intensity; If I remember correctly, it is is something like B/(r^3), where B is "baselevel" of volume, and I0 is intensity of basic scale, our previous value of B would do just fine. And r of course is range from sound source.

Formula 'dB = 20*log( B/r^3 )' might do fairly well most of the time, but you just have to find good values for B...

And of course, since we're dealing with computers here, you might want to alter
the formula a bit if [when?] this sounds bad...

As a reminder, -96dB is practically silence, since that's near the theoretical limit of 16-bit audio!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The wouldn't work well with panning, since this is a large
2D map and what the player sees on the screen is only a small
portion of the map. So if you place the player at the center
of a circle, the x,y coords. of a distant sound source from an
angle should somehow convert to panning dBs and volume dBs.

I also don't have any physics books lying around, so I can't
really look up equations. I can take the easy approach and
map distance and volume using a simple ratio based on the
max/min boundaries of my map, but this isn't using real physics,
so I appreciate your help!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
What's a good equation (using DirectSound, not 3D) to calculate
volume dB based on the x,y distance of a sound that is off the
player's screen for a 2D scrolling game? So as I scrolled closer
to where the sound was coming found, it would get louder until
the source appears on the screen.

Also, could anyone point me to a DirectSound example where
they use 2D panning as well?

-Placid

Share this post


Link to post
Share on other sites

  • Advertisement