How can use float value to mark volumn?
(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?
June 01, 2004 08:17 AM
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; }
#define FLOATTOVOL(fv, lv) { lv = (long)(fv * 10000) - 10000; }
but I do not think the translation is linear.
because I heard the sound(-5000) is more light than half sound(0).
because I heard the sound(-5000) is more light than half sound(0).
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
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
visit my site http://www.fullf1.com for all your formula 1 and music creation needs.
June 01, 2004 09:49 AM
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.
-5000 = 50 dB, etc. This is a linear transition.
June 05, 2004 08:15 AM
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement