Module: wine Branch: master Commit: 315e998951b2e4aca7c56cbb4c2f988bf508b481 URL: https://gitlab.winehq.org/wine/wine/-/commit/315e998951b2e4aca7c56cbb4c2f988...
Author: Anton Baskanov baskanov@gmail.com Date: Mon Apr 24 09:19:43 2023 +0700
dsound: Limit the Doppler shift to +-0.5 speed of sound.
---
dlls/dsound/sound3d.c | 5 +++-- dlls/dsound/tests/ds3d.c | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/dlls/dsound/sound3d.c b/dlls/dsound/sound3d.c index 7cccef6cfe4..9a975324607 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; + D3DVALUE flFreq, flRelativeVel, flLimitedVel;
TRACE("(%p)\n",dsb);
@@ -307,8 +307,9 @@ 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)); /* formula taken from Gianicoli D.: Physics, 4th edition: */ - flFreq = dsb->ds3db_freq * (DEFAULT_VELOCITY/(DEFAULT_VELOCITY + flRelativeVel)); + flFreq = dsb->ds3db_freq * (DEFAULT_VELOCITY/(DEFAULT_VELOCITY + flLimitedVel)); TRACE("doppler: Relative velocity (component) = %f => Doppler shift: %ld Hz -> %f Hz\n", flRelativeVel, dsb->ds3db_freq, flFreq); dsb->freq = flFreq; diff --git a/dlls/dsound/tests/ds3d.c b/dlls/dsound/tests/ds3d.c index 99a1f16cf8e..e7e1ab7ab81 100644 --- a/dlls/dsound/tests/ds3d.c +++ b/dlls/dsound/tests/ds3d.c @@ -1446,9 +1446,7 @@ static void test_doppler(GUID *guid, BOOL play) check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, -90, 1, 0, 22050, 17640);
/* The Doppler shift is limited to +-0.5 speed of sound. */ - /* Wine TODO: The frequency is not limited. */ check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 0, 1, -240, 22050, 44100); - /* Wine TODO: The frequency is not limited. */ check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 0, 1, 240, 22050, 14700);
IDirectSound3DListener_Release(listener);