More moving listener/sound tests

Francois Gouget fgouget at codeweavers.com
Mon Jul 19 12:55:15 CDT 2004


Running the ds3d sound test on Windows XP the sound would stop abruptly 
when running the moving listener/sound tests. I played with this test 
quite a bit trying to understand what was going on but I think this is 
caused by a bug on this machine because the test works fine in Windows 
98 in VMWare.

In the process I did the following changes:
  * first when I changed the sound time to 4 seconds a long time ago I 
messed up the test because the increment by which the positions are 
updated did not take into account the sound duration (or TIME_SLICE 
lenght for that matter). So instead of going from -5m to +5m, the 
listener was going from -5m to +66 metres! This patch makes the movement 
duration and TIME_SLICE independent by relying on the elapsed time to 
update the listener and sound positions.
  * the test now sets the velocity which should give DirectSound a 
chance to introduce a bit of doppler effect.
  * I increased the speed of the sound movement to increase the doppler 
effect: you don't get much a doppler effect when moving at 9km/h, now 
the sound source moves at 90km/h which should give us a better effect. I 
adjusted flMinDistance accordingly since the sound source now starts 
from much further away and we should reduce the attenuation. Maybe the 
sound source should be icreased further for better doppler effect.
  * the test now uses SetAllParameters() for the initial setup. It was 
not tested before.
  * added some traces so one can monitor the listener/sound positions 
with WINETEST_DEBUG=3


Changelog:

  * dlls/dsound/tests/ds3d.c

    Francois Gouget <fgouget at codeweavers.com>
    Make the listener/sound position update duration and TIME_SLICE 
independent.
    Set the sound and listener velocity and increase the sound source 
velocity so we may get some doppler effect.
    Added some traces so one can monitor the listener/sound positions 
with WINETEST_DEBUG=3.

-- 
Francois Gouget
fgouget at codeweavers.com

-------------- next part --------------
Index: dlls/dsound/tests/ds3d.c
===================================================================
RCS file: /var/cvs/wine/dlls/dsound/tests/ds3d.c,v
retrieving revision 1.3
diff -u -r1.3 ds3d.c
--- dlls/dsound/tests/ds3d.c	16 Jul 2004 23:42:32 -0000	1.3
+++ dlls/dsound/tests/ds3d.c	17 Jul 2004 10:54:53 -0000
@@ -455,35 +455,39 @@
             rc=IDirectSound3DListener_GetAllParameters(listener,&listener_param);
             ok(rc==DS_OK,"IDirectSound3dListener_GetAllParameters failed 0x%lx\n",rc);
             if (move_listener)
+            {
                 listener_param.vPosition.x = -5.0;
-            else
-                listener_param.vPosition.x = 0.0;
-            listener_param.vPosition.y = 0.0;
-            listener_param.vPosition.z = 0.0;
-            rc=IDirectSound3DListener_SetPosition(listener,listener_param.vPosition.x,listener_param.vPosition.y,listener_param.vPosition.z,DS3D_IMMEDIATE);
+                listener_param.vVelocity.x = 10.0/duration;
+            }
+            rc=IDirectSound3DListener_SetAllParameters(listener,&listener_param,DS3D_IMMEDIATE);
             ok(rc==DS_OK,"IDirectSound3dListener_SetPosition failed 0x%lx\n",rc);
         }
         if (buffer3d) {
             if (move_sound)
-                buffer_param.vPosition.x = 5.0;
-            else
-                buffer_param.vPosition.x = 0.0;
-            buffer_param.vPosition.y = 0.0;
-            buffer_param.vPosition.z = 0.0;
-            rc=IDirectSound3DBuffer_SetPosition(buffer,buffer_param.vPosition.x,buffer_param.vPosition.y,buffer_param.vPosition.z,DS3D_IMMEDIATE);
+            {
+                buffer_param.vPosition.x = 100.0;
+                buffer_param.vVelocity.x = -200.0/duration;
+            }
+            buffer_param.flMinDistance = 10;
+            rc=IDirectSound3DBuffer_SetAllParameters(buffer,&buffer_param,DS3D_IMMEDIATE);
             ok(rc==DS_OK,"IDirectSound3dBuffer_SetPosition failed 0x%lx\n",rc);
         }
 
         start_time=GetTickCount();
         while (buffer_service(&state)) {
             WaitForSingleObject(GetCurrentProcess(),TIME_SLICE);
+            now=GetTickCount();
             if (listener && move_listener) {
-                listener_param.vPosition.x += 0.5;
+                listener_param.vPosition.x = -5.0+10.0*(now-start_time)/1000/duration;
+                if (winetest_debug>2)
+                    trace("listener position=%g\n",listener_param.vPosition.x);
                 rc=IDirectSound3DListener_SetPosition(listener,listener_param.vPosition.x,listener_param.vPosition.y,listener_param.vPosition.z,DS3D_IMMEDIATE);
                 ok(rc==DS_OK,"IDirectSound3dListener_SetPosition failed 0x%lx\n",rc);
             }
             if (buffer3d && move_sound) {
-                buffer_param.vPosition.x -= 0.5;
+                buffer_param.vPosition.x = 100-200.0*(now-start_time)/1000/duration;
+                if (winetest_debug>2)
+                    trace("sound position=%g\n",buffer_param.vPosition.x);
                 rc=IDirectSound3DBuffer_SetPosition(buffer,buffer_param.vPosition.x,buffer_param.vPosition.y,buffer_param.vPosition.z,DS3D_IMMEDIATE);
                 ok(rc==DS_OK,"IDirectSound3dBuffer_SetPosition failed 0x%lx\n",rc);
             }


More information about the wine-patches mailing list