From: Anton Baskanov baskanov@gmail.com
--- dlls/dsound/tests/ds3d.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/dlls/dsound/tests/ds3d.c b/dlls/dsound/tests/ds3d.c index 5e6ba4d204e..bfd632f3a00 100644 --- a/dlls/dsound/tests/ds3d.c +++ b/dlls/dsound/tests/ds3d.c @@ -1441,6 +1441,12 @@ static void test_doppler(GUID *guid, BOOL play)
check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 0, 0, -90, 22050, 22050);
+ /* The Doppler shift does not depend on the frame of reference. */ + /* Wine TODO: The frequency is too low. */ + check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 90, 1, 0, 22050, 29400); + /* Wine TODO: The frequency is too low. */ + check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, -90, 1, 0, 22050, 17640); + IDirectSound3DListener_Release(listener); ref = IDirectSoundBuffer_Release(primary); ok(!ref, "Got outstanding refcount %ld.\n", ref);
From: Anton Baskanov baskanov@gmail.com
It's less physically correct but closer to the native behavior. --- dlls/dsound/sound3d.c | 18 ++++++++---------- dlls/dsound/tests/ds3d.c | 2 -- 2 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/dlls/dsound/sound3d.c b/dlls/dsound/sound3d.c index b062917b219..7cccef6cfe4 100644 --- a/dlls/dsound/sound3d.c +++ b/dlls/dsound/sound3d.c @@ -167,7 +167,8 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb) int i, num_main_speakers; float a, ingain; /* doppler shift related stuff */ - D3DVALUE flFreq, flBufferVel, flListenerVel; + D3DVECTOR vRelativeVel; + D3DVALUE flFreq, flRelativeVel;
TRACE("(%p)\n",dsb);
@@ -292,6 +293,7 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb) dsb->freq = dsb->ds3db_freq;
/* doppler shift*/ + vRelativeVel = VectorBetweenTwoPoints(&dsb->device->ds3dl.vVelocity, &dsb->ds3db_ds3db.vVelocity); if (!VectorMagnitude(&dsb->ds3db_ds3db.vVelocity) && !VectorMagnitude(&dsb->device->ds3dl.vVelocity)) { TRACE("doppler: Buffer and Listener don't have velocities\n"); @@ -301,18 +303,14 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb) dsb->ds3db_ds3db.vVelocity.z == dsb->device->ds3dl.vVelocity.z) && !(vDistance.x == 0.0f && vDistance.y == 0.0f && vDistance.z == 0.0f)) { - /* calculate length of ds3db_ds3db.vVelocity component which causes Doppler Effect + /* calculate length of vRelativeVel component which causes Doppler Effect NOTE: if buffer moves TOWARDS the listener, its velocity component is NEGATIVE if buffer moves AWAY from listener, its velocity component is POSITIVE */ - flBufferVel = ProjectVector(&dsb->ds3db_ds3db.vVelocity, &vDistance); - /* calculate length of ds3dl.vVelocity component which causes Doppler Effect - NOTE: if listener moves TOWARDS the buffer, its velocity component is POSITIVE - if listener moves AWAY from buffer, its velocity component is NEGATIVE */ - flListenerVel = ProjectVector(&dsb->device->ds3dl.vVelocity, &vDistance); + flRelativeVel = ProjectVector(&vRelativeVel, &vDistance); /* formula taken from Gianicoli D.: Physics, 4th edition: */ - flFreq = dsb->ds3db_freq * ((DEFAULT_VELOCITY + flListenerVel)/(DEFAULT_VELOCITY + flBufferVel)); - TRACE("doppler: Buffer velocity (component) = %f, Listener velocity (component) = %f => Doppler shift: %ld Hz -> %f Hz\n", - flBufferVel, flListenerVel, dsb->ds3db_freq, flFreq); + flFreq = dsb->ds3db_freq * (DEFAULT_VELOCITY/(DEFAULT_VELOCITY + flRelativeVel)); + 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 bfd632f3a00..5fa558f7c87 100644 --- a/dlls/dsound/tests/ds3d.c +++ b/dlls/dsound/tests/ds3d.c @@ -1442,9 +1442,7 @@ static void test_doppler(GUID *guid, BOOL play) check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 0, 0, -90, 22050, 22050);
/* The Doppler shift does not depend on the frame of reference. */ - /* Wine TODO: The frequency is too low. */ check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 90, 1, 0, 22050, 29400); - /* Wine TODO: The frequency is too low. */ check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, -90, 1, 0, 22050, 17640);
IDirectSound3DListener_Release(listener);
From: Anton Baskanov baskanov@gmail.com
--- dlls/dsound/tests/ds3d.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/dlls/dsound/tests/ds3d.c b/dlls/dsound/tests/ds3d.c index 5fa558f7c87..99a1f16cf8e 100644 --- a/dlls/dsound/tests/ds3d.c +++ b/dlls/dsound/tests/ds3d.c @@ -1445,6 +1445,12 @@ static void test_doppler(GUID *guid, BOOL play) check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 90, 1, 0, 22050, 29400); 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); ref = IDirectSoundBuffer_Release(primary); ok(!ref, "Got outstanding refcount %ld.\n", ref);
From: Anton Baskanov baskanov@gmail.com
--- 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);
From: Anton Baskanov baskanov@gmail.com
--- dlls/dsound/tests/ds3d.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/dlls/dsound/tests/ds3d.c b/dlls/dsound/tests/ds3d.c index e7e1ab7ab81..77d3f09ec13 100644 --- a/dlls/dsound/tests/ds3d.c +++ b/dlls/dsound/tests/ds3d.c @@ -1449,6 +1449,10 @@ static void test_doppler(GUID *guid, BOOL play) check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 0, 1, -240, 22050, 44100); check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 0, 1, 240, 22050, 14700);
+ /* The shifted frequency is limited to DSBFREQUENCY_MAX. */ + /* Wine TODO: The frequency is not limited. */ + check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 0, 1, -90, 176400, 200000); + IDirectSound3DListener_Release(listener); ref = IDirectSoundBuffer_Release(primary); ok(!ref, "Got outstanding refcount %ld.\n", ref);
From: Anton Baskanov baskanov@gmail.com
--- dlls/dsound/sound3d.c | 2 +- dlls/dsound/tests/ds3d.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/dlls/dsound/sound3d.c b/dlls/dsound/sound3d.c index 9a975324607..c22a3d5509f 100644 --- a/dlls/dsound/sound3d.c +++ b/dlls/dsound/sound3d.c @@ -312,7 +312,7 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb) 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; + dsb->freq = max(DSBFREQUENCY_MIN, min(DSBFREQUENCY_MAX, (DWORD)flFreq)); }
DSOUND_RecalcFormat(dsb); diff --git a/dlls/dsound/tests/ds3d.c b/dlls/dsound/tests/ds3d.c index 77d3f09ec13..9c149dbcd9b 100644 --- a/dlls/dsound/tests/ds3d.c +++ b/dlls/dsound/tests/ds3d.c @@ -1450,7 +1450,6 @@ static void test_doppler(GUID *guid, BOOL play) check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 0, 1, 240, 22050, 14700);
/* The shifted frequency is limited to DSBFREQUENCY_MAX. */ - /* Wine TODO: The frequency is not limited. */ check_doppler(dsound, listener, play, DS3DMODE_NORMAL, 0, 0, 1, -90, 176400, 200000);
IDirectSound3DListener_Release(listener);
The relative velocity thing is strange - I guess they got confused with light...
This merge request was approved by Huw Davies.