#### Archived

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

# how can I use float value to mark sound volumn?

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

## 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 on other sites
not sure if this is what you want to do..but.....

You want to map DSBVOLUME_MIN to 0.0f, and
DSBVOLUMN_MAX to 1.0f.

float reMapDSBVOL( int Vol )
{
// Where Vol is your value between 0.0f & 1.0f
return ( (1.0f - Vol) * DBSVOLUME_MIN );
}

Probably want to write a macro to do this.

 actually, you probably want to return an int.

[edited by - RavNaz on June 1, 2004 9:28:29 AM]

##### Share on other sites
thank you,

I do not think the translation is linear,
because the dxsdk said the param in
HRESULT SetVolumn( LONG lVolume ) ;
is attenuation, in hundredths of a decibel (dB).

##### Share on other sites
I can''t remember clearly.
There may be a log relationship in the transformation.

##### Share on other sites
ohh,I''ve found the result.

http://www.internet4classrooms.com/sound_decibel.htm

##### Share on other sites
v = 0..1
x = -log10( (v*120) / 20 )

ds = (10000 * x)

ds = direct sound volume
x = scale
v = linear knob

[edited by - PeterTarkus on June 1, 2004 10:15:40 AM]

1. 1
Rutin
41
2. 2
3. 3
4. 4
5. 5

• 16
• 18
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633360
• Total Posts
3011524
• ### Who's Online (See full list)

There are no registered users currently online

×