This article belong to "518 supermarket broadcasting software development log" part of the series,
I in the development of "518 supermarket broadcast software" (http://www.518boyin.com/), is expressed in a linear volume in user level 0-100, but still use directshow play music, the range is 0-10000 is not linear, how convert? Here is my conversion code, the basic can be used, but does not guarantee that is the best the most correct code,
Int Tapp: : lin2ds (int vol, a BOOL bMute)
{
If (bMute | | vol & lt;=1) return - 10000;
The else return (log10 (vol) 1.0 * 2.0) * 5000.0;
}
Double Tapp: : lin2bass (int vol)
{
Double dVol=(double) vol/100.0;
Double RSL=(0.998 (dVol, 2) + 0.003 * * pow dVol 0.001);
If (RSL & lt; RSL=0.0 0.0);
Return RSL.
}