- // Volume conversion from Greg Hazel
- long lVolume;
- // handle -INF
- dVolume *= 1 - pow(10.0, -5.0);
- dVolume += pow(10.0, -5.0);
- // convert to -100db to 0db
- dVolume = 20 * log10(dVolume);
- // scale to -10000 to 0
- lVolume = (long)(125 * dVolume);
-
- HRESULT hr = GetAM()->put_Volume( lVolume );
+ // inverse the transformation above
+ long lVolume = static_cast<long>(2000*log10(dVolume + (1 - dVolume)*0.00001));
+
+ HRESULT hr = GetAM()->put_Volume(lVolume);