how can I use float value to mark sound 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?
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]
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 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).
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]
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
Popular Topics
Advertisement