#### Archived

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

# Decibels to linear volume

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

## Recommended Posts

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

##### Share on other sites
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.

##### Share on other sites
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));

##### Share on other sites
Thanks a lot - I will try them.

regards,

GeniX

www.cryo-genix.net

• 11
• 20
• 12
• 10
• 38
• ### Forum Statistics

• Total Topics
631401
• Total Posts
2999865
×