Jump to content
  • Advertisement

Archived

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

coolzhao

How can use float value to mark volumn?

This topic is 5221 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

(Sorry!My English is poor,but I''ll try my best to express my notion.) In directsound,the DSBVOLUMN_MAX is defined as 0 and the DSBVOLUME_MIN is defined as -10000. Now , I am writing a sound manager.I want to define the maximum volumn as 1.0f and minimum volumn as 0.0f , but I do not know how to transfer. Would you please tell me how can I do?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Uhh, I really don''t see what the problem is, but you could scale your float with a macro or something like

#define FLOATTOVOL(fv, lv) { lv = (long)(fv * 10000) - 10000; }


Share this post


Link to post
Share on other sites
but I do not think the translation is linear.

because I heard the sound(-5000) is more light than half sound(0).

Share this post


Link to post
Share on other sites
not used direct sound but can you directly program into it?

and use cast operation eg


int a = 9;
int b = 5;
float c;

c = (float)a/b;

that will let you take a different datatype

im not sure thats all the programming i can help with until i have a look at direct sound myself


Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The MS value represents attenuation of the volume in one hundredths of a decibel, -10000 = 100 dB (effectively silence),
-5000 = 50 dB, etc. This is a linear transition.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hey Coolzhao, the MS value is in hundredths of a decibel, or millibels (mB). Decibels are a logarithmic scale, because human hearing works logarithmically. To translate, you can use:

MilliBelFigure = (int) (1000 * log10(FloatFigure))

and

FloatFigure = pow(10, MilliBelFigure / 1000)

Hope this helps.

Note that if FloatFigure is very small, log10(FlostFigure) will become a very large -ve value. If it goes below -10, say, you want to clamp it to lie in range.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!