Module: wine Branch: master Commit: 69d088ca5b0e85337d6f0c1c8655721a8fef0575 URL: https://gitlab.winehq.org/wine/wine/-/commit/69d088ca5b0e85337d6f0c1c8655721...
Author: Anton Baskanov baskanov@gmail.com Date: Mon Apr 24 15:07:32 2023 +0700
dsound: Take distance and Doppler factor into account.
---
dlls/dsound/sound3d.c | 5 +++-- dlls/dsound/tests/ds3d.c | 12 ------------ 2 files changed, 3 insertions(+), 14 deletions(-)
diff --git a/dlls/dsound/sound3d.c b/dlls/dsound/sound3d.c index 7ad37a30f8d..3fa9ff6801f 100644 --- a/dlls/dsound/sound3d.c +++ b/dlls/dsound/sound3d.c @@ -168,7 +168,7 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb) float a, ingain; /* doppler shift related stuff */ D3DVECTOR vRelativeVel; - D3DVALUE flFreq, flRelativeVel, flLimitedVel; + D3DVALUE flFreq, flRelativeVel, flLimitedVel, flVelocityFactor;
TRACE("(%p)\n",dsb);
@@ -308,7 +308,8 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb) NOTE: if buffer moves TOWARDS the listener, its velocity component is NEGATIVE if buffer moves AWAY from listener, its velocity component is POSITIVE */ flRelativeVel = ProjectVector(&vRelativeVel, &vDistance); - flLimitedVel = max(-DEFAULT_VELOCITY/2, min(DEFAULT_VELOCITY/2, flRelativeVel)); + flVelocityFactor = dsb->device->ds3dl.flDistanceFactor * dsb->device->ds3dl.flDopplerFactor; + flLimitedVel = max(-DEFAULT_VELOCITY/2, min(DEFAULT_VELOCITY/2, flRelativeVel * flVelocityFactor)); /* formula taken from Gianicoli D.: Physics, 4th edition: */ flFreq = dsb->ds3db_freq * (DEFAULT_VELOCITY/(DEFAULT_VELOCITY + flLimitedVel)); TRACE("doppler: Relative velocity (component) = %f => Doppler shift: %ld Hz -> %f Hz\n", diff --git a/dlls/dsound/tests/ds3d.c b/dlls/dsound/tests/ds3d.c index 14f83d9c0a0..9c65f674b3b 100644 --- a/dlls/dsound/tests/ds3d.c +++ b/dlls/dsound/tests/ds3d.c @@ -1459,17 +1459,11 @@ static void test_doppler(GUID *guid, BOOL play) hr = IDirectSound3DListener_SetDistanceFactor(listener, 10, DS3D_DEFERRED); ok(hr == S_OK, "Got hr %#lx.\n", hr);
- /* Wine TODO: The distance factor has no effect. */ check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 0, 0.1f, -9, 22050, 29400); - /* Wine TODO: The distance factor has no effect. */ check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 0, 0.1f, 9, 22050, 17640); - /* Wine TODO: The distance factor has no effect. */ check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 9, 0.1f, 0, 22050, 29400); - /* Wine TODO: The distance factor has no effect. */ check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, -9, 0.1f, 0, 22050, 17640); - /* Wine TODO: The distance factor has no effect. */ check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 0, 0.1f, -24, 22050, 44100); - /* Wine TODO: The distance factor has no effect. */ check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 0, 0.1f, 24, 22050, 14700);
hr = IDirectSound3DListener_SetDistanceFactor(listener, DS3D_DEFAULTDISTANCEFACTOR, DS3D_DEFERRED); @@ -1478,17 +1472,11 @@ static void test_doppler(GUID *guid, BOOL play) hr = IDirectSound3DListener_SetDopplerFactor(listener, 2, DS3D_DEFERRED); ok(hr == S_OK, "Got hr %#lx.\n", hr);
- /* Wine TODO: The Doppler factor has no effect. */ check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 0, 1, -45, 22050, 29400); - /* Wine TODO: The Doppler factor has no effect. */ check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 0, 1, 45, 22050, 17640); - /* Wine TODO: The Doppler factor has no effect. */ check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 45, 1, 0, 22050, 29400); - /* Wine TODO: The Doppler factor has no effect. */ check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, -45, 1, 0, 22050, 17640); - /* Wine TODO: The Doppler factor has no effect. */ check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 0, 1, -120, 22050, 44100); - /* Wine TODO: The Doppler factor has no effect. */ check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 0, 1, 120, 22050, 14700);
hr = IDirectSound3DListener_SetDopplerFactor(listener, DS3D_DEFAULTDOPPLERFACTOR, DS3D_DEFERRED);