假如将播放器的控制音量切割成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
本文探讨了如何将播放器的音量控制从0-100转换为[-10000,0]范围,并提供了实现方法及参考文章。通过公式将不同范围的音量进行转换,实现更精细的声音效果控制。
840

被折叠的 条评论
为什么被折叠?



