Partager via


Step 3: Change Buffer Parameters

Now that you have the IDirectSound3DBuffer8 interface, you can use it to move the sound in space. The tutorial sample application does so when the user closes a series of message boxes. For example, the following code immediately moves the sound to the left:

pDSB->SetPosition( -0.1f, 0.0f, 0.0f, DS3D_IMMEDIATE );

The first three parameters specify the new position of the sound source in relation to the default listener. The default listener is at coordinates (0.0, 0.0, 0.0), facing toward the positive z-axis, with the top of the head toward the positive y-axis. Distance units are meters by default. Because the x-axis is positive from left to right, the new position of the sound is 10 centimeters directly to the left of the listener.

The last parameter of the IDirectSound3DBuffer8::SetPosition method specifies whether the change is to be made immediately or deferred until all changes are committed.

© 2004 Microsoft Corporation. All rights reserved.