From 72c7c2ffd1bc34b016dc3644919d7cfad0ae9c0d Mon Sep 17 00:00:00 2001 From: Frank-74 Date: Fri, 29 Sep 2017 00:52:28 +0100 Subject: [PATCH] Fix Volume --- Source/Project64-audio/Driver/DirectSound.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Source/Project64-audio/Driver/DirectSound.cpp b/Source/Project64-audio/Driver/DirectSound.cpp index 19d2df018..d57464af1 100644 --- a/Source/Project64-audio/Driver/DirectSound.cpp +++ b/Source/Project64-audio/Driver/DirectSound.cpp @@ -132,10 +132,16 @@ void DirectSoundDriver::SetFrequency(uint32_t Frequency) void DirectSoundDriver::SetVolume(uint32_t Volume) { - /*DWORD dsVolume = ((DWORD)Volume * -25); - if (Volume == 100) dsVolume = (DWORD)DSBVOLUME_MIN; - if (Volume == 0) dsVolume = DSBVOLUME_MAX; - if (lpdsb != NULL) lpdsb->SetVolume(dsVolume);*/ + LPDIRECTSOUNDBUFFER & lpdsb = (LPDIRECTSOUNDBUFFER &)m_lpdsb; + int32_t dsVolume = - 10 ^ ((100 - Volume) * 33); + if (Volume == 0) + { + dsVolume = DSBVOLUME_MIN; + } + if (lpdsb != NULL) + { + lpdsb->SetVolume(dsVolume); + } } void DirectSoundDriver::SetSegmentSize(uint32_t length, uint32_t SampleRate) @@ -278,4 +284,4 @@ void DirectSoundDriver::AudioThreadProc() lpdsbuf->Stop(); } WriteTrace(TraceAudioDriver, TraceDebug, "Audio Thread Terminated..."); -} \ No newline at end of file +}