how can I use float value to mark sound volumn?

Started by
4 comments, last by coolzhao 19 years, 10 months ago
(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?
Advertisement
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.

[edit] actually, you probably want to return an int.

[edited by - RavNaz on June 1, 2004 9:28:29 AM]
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).



I can''t remember clearly.
There may be a log relationship in the transformation.
ohh,I''ve found the result.

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

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]

This topic is closed to new replies.

Advertisement