我正在用DirectX.DirectSound開發音樂播放器。我的音量有問題。直接音量是對數。這意味着在無聲的情況下,對幅度的微小變化比對響亮的聲音要敏感得多。這也意味着,對於線性音量滑塊,我們會有音量變化的對數感覺,並且感覺不對。我的問題是:我怎樣才能使它線性? 我的代碼,直到這裏是: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'。 – 2013-04-08 16:00:13
@NicoSchertler它用於-10000 Min和0 for Maximum,我的軌跡欄是0-100。我正在嘗試'foreGroundSound.Volume = Math.Exp(((trkBalance.Value * 100) - 10000)',但沒有運氣。 – 2013-04-08 16:07:20