From cb9ef7a8b8c30e9a3042be39cb13fd041fa3b045 Mon Sep 17 00:00:00 2001 From: Pyr0Byt3 Date: Wed, 3 Jul 2019 15:11:53 -0400 Subject: [PATCH] fix volume scaling --- SourceX/miniwin/dsound.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SourceX/miniwin/dsound.cpp b/SourceX/miniwin/dsound.cpp index eaf8739d8..95d30111b 100644 --- a/SourceX/miniwin/dsound.cpp +++ b/SourceX/miniwin/dsound.cpp @@ -74,8 +74,7 @@ HRESULT DirectSoundBuffer::Play(DWORD dwReserved1, DWORD dwPriority, DWORD dwFla } Mix_Volume(channel, volume); - int panned = 255 - 255 * abs(pan) / 10000; - Mix_SetPanning(channel, pan <= 0 ? 255 : panned, pan >= 0 ? 255 : panned); + Mix_SetPanning(channel, pan <= 0 ? 255 : abs(pan), pan >= 0 ? 255 : pan); return DVL_DS_OK; }; @@ -87,14 +86,15 @@ HRESULT DirectSoundBuffer::SetFormat(LPCWAVEFORMATEX pcfxFormat) HRESULT DirectSoundBuffer::SetVolume(LONG lVolume) { - volume = MIX_MAX_VOLUME - MIX_MAX_VOLUME * lVolume / VOLUME_MIN; + volume = pow(10, lVolume / 2000.0) * MIX_MAX_VOLUME; return DVL_DS_OK; }; HRESULT DirectSoundBuffer::SetPan(LONG lPan) { - pan = lPan; + pan = copysign(pow(10, -abs(lPan) / 2000.0) * 255, lPan); + return DVL_DS_OK; };