【发布时间】:2013-04-08 15:51:43
【问题描述】:
我正在使用 DirectX.DirectSound 开发音乐播放器。我的音量有问题。直接音量是对数。这意味着对于无声的声音,对幅度的微小变化比对大声的声音更敏感。这也意味着使用线性音量滑块,我们对音量变化有一种对数的感觉,而这感觉不太对劲。我的问题是:我怎样才能使它成为线性的? 直到这里我的代码是:
if (trkBalance.Value == trkBalance.Minimum)
{
foreGroundSound.Volume = (int)DS.Volume.Min;
}
else if (trkBalance.Value == trkBalance.Maximum)
{
foreGroundSound.Volume = (int)DS.Volume.Max;
}
else
{
foreGroundSound.Volume = (int)(-5000 * Math.Log10(100 - trkBalance.Value));
}
【问题讨论】:
-
trkBalance.Value在什么范围内?如果要还原对数刻度,则必须使用反函数 (Math.Exp)。DS.Volume.Min/Max是什么值?您需要找到一个函数v(t) = c * Math.Exp(t),其中v(minValue) == DS.Volume.Min和v(maxValue) == DS.Volume.Max。 -
@NicoSchertler 最小值为 -10000,最大值为 0,我的轨迹栏为 0-100。我正在尝试
foreGroundSound.Volume = Math.Exp((trkBalance.Value * 100) - 10000),但没有运气。
标签: c# directx directsound