IDirectSoundBuffer::SetVolume的参数与音量分贝的函数关系

来源:互联网 发布:python win32api 安装 编辑:程序博客网 时间:2024/05/01 15:04

假如将播放器的控制音量切割成0-100的话,由于IDirectSoundBuffer::SetVolume(LONG lVolume)中参数的输入值是[-10000,0]

MySetVolume( DWORD inputVolume){    double decibels;    DWORD dsVol;    if (inputVolume==0)        dsVol = DSBVOLUME_MIN;    else if (inputVolume>10000)        dsVol = DSBVOLUME_MAX;    else    {        decibels = 20.0 * log10((double)inputVolume / 100.0);        dsVol = (DWORD)(decibels * 100.0);    }    pDSBuffer->SetVolume( dsVol );}


当然,也可以将音量控制分割成0--10000了,基本的公式就是这样的。


有篇文章可以参考参考:http://www.animations.physics.unsw.edu.au/jw/dB.htm#definition

原创粉丝点击