Decibels to linear volume
So what?? Im too lazy to work it out myself!
But since youre already here...
DirectSound wants a decibel rating from -10000 to 0
I want to have a linear volume from 0 to 255.
I cant just convert the linear volume straight to a value out of 10000 and subtract 10000 because then if the linear volume is 190, the sound is very soft.
If the linear volume is 255, it is loud.
I need to take into account the fact that the decibel volume is logarithmic. Help? A formula would be nice?
regards,
GeniX
www.cryo-genix.net
regards,GeniXwww.cryo-genix.net
I think this macro will work
#define DSVOLUME_TO_DB(volume) ((DWORD)(-30*(100 - volume)))
"All you touch and all you see is all your life will ever be --Pink Floyd
Quidquid latine dictum sit, altum viditur.
Need help? Well, go FAQ yourself.
#define DSVOLUME_TO_DB(volume) ((DWORD)(-30*(100 - volume)))
"All you touch and all you see is all your life will ever be --Pink Floyd
Quidquid latine dictum sit, altum viditur.
Need help? Well, go FAQ yourself.
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi
This is the code I have in my sound engine I wrote a while ago (and that I use currently). This converts a sound volume from 0,100 to -10000,0.
This deals with the logarithmic scale of decibels I think...
long lVolume = (long) (-5000.0F + 5000.0F * log(1.0F + (LN_BASE - 1.0F) * (float) fVolume / 100.0F));
This deals with the logarithmic scale of decibels I think...
long lVolume = (long) (-5000.0F + 5000.0F * log(1.0F + (LN_BASE - 1.0F) * (float) fVolume / 100.0F));
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement