Platform SDK: DirectX |
DirectSound uses meters as the default unit of distance measurements. If your application does not use meters, it can set a distance factor, which is the number of meters in a vector unit.
After you have set the distance factor for a listener, use your application's own distance units in calls to any methods that apply to that listener. Suppose, for example, that the basic unit of measurement in your application is the foot. You call the IDirectSound3DListener::SetDistanceFactor method, specifying 0.3048 as the flDistanceFactor parameter. (This value is the number of meters in a foot.) From then on, you continue using feet in parameters to method calls, and they are automatically converted to meters.
You can retrieve the current distance factor set for a listener by using the IDirectSound3DListener::GetDistanceFactor method.
After you have set the distance factor for a listener, use your application's own distance units in calls to any methods that apply to that listener. Suppose, for example, that the basic unit of measurement in your application is the foot. You call the DirectSound3DListener.SetDistanceFactor method, specifying 0.3048 as the distanceFactor parameter. (This value is the number of meters in a foot.) From then on, you continue using feet in parameters to method calls, and they are automatically converted to meters.
You can retrieve the current distance factor set for a listener by using the DirectSound3DListener.GetDistanceFactor method.
The distance factor mainly affects Doppler shift (by changing the actual velocity represented by n units per second). It does not directly affect rolloff, because the rate of attenuation over distance is based on the minimum distance in units. If you set the minimum distance for a given sound at 2 units, the volume will be halved at a distance of 4 units, whether those units are in feet, meters, or any other measure. For more information, see Minimum and Maximum Distances.