]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
UAE AHI ignored AHI sound volume and master volume was converted incorrectly
authorToni Wilen <twilen@winuae.net>
Sun, 14 Jan 2024 17:12:13 +0000 (19:12 +0200)
committerToni Wilen <twilen@winuae.net>
Sun, 14 Jan 2024 17:12:13 +0000 (19:12 +0200)
od-win32/ahidsound_dsonly.cpp

index f89aebf8b8b1e79150b79df63875743c609b75ef..155bfa2a5f8de73243e5d9a76aac22150666370a 100644 (file)
@@ -298,14 +298,21 @@ static int ahi_init_record_win32 (void)
        return 1;
 }
 
-void setvolume_ahi (LONG vol)
+void setvolume_ahi(LONG volume)
 {
        HRESULT hr;
+
        if (!lpDS2)
                return;
-       hr = IDirectSoundBuffer_SetVolume (lpDSB2, vol);
-       if (FAILED (hr))
-               write_log (_T("AHI: SetVolume(%d) failed: %s\n"), vol, DXError (hr));
+
+       float adjvol = (100.0f - currprefs.sound_volume_board) * (100.0f - volume) / 100.0f;
+       LONG vol = DSBVOLUME_MIN;
+       if (adjvol > 0) {
+               vol = (LONG)((DSBVOLUME_MIN / 2) + (-DSBVOLUME_MIN / 2) * log(1 + (2.718281828 - 1) * (adjvol / 100.0)));
+       }
+       hr = IDirectSoundBuffer_SetVolume(lpDSB2, vol);
+       if (FAILED(hr))
+               write_log(_T("AHI: SetVolume(%d) failed: %s\n"), vol, DXError (hr));
 }
 
 static int ahi_init_sound_win32 (void)