SoundEffect.DistanceScale Property
Gets or sets a value that adjusts the effect of distance calculations on the sound (emitter).
Namespace: Microsoft.Xna.Framework.Audio
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)
Syntax
public static float DistanceScale { get; set; }
Property Value
A value that adjustments the effect of Distance and Doppler calculations on the sound (emitter).
Remarks
If sounds are attenuating too fast, which means the sounds get quiet too quickly as they move away from the listener, you need to increase the DistanceScale. If sounds are not attenuating fast enough, decrease the DistanceScale.
Adjustment | Effect |
---|---|
DistanceScale = 0.0 | Invalid (DistanceScale will be reset to default of 1.0) |
0.0 < DistanceScale <= 1.0 | Increases the effect of distance attenuation |
DistanceScale = 1.0 | No scaling (this is the default setting) |
DistanceScale > 1.0 | Decrease the effect of distance attenuation |
Distance attenuation is calculated using the inverse square law:
volume = 1.0 / distance
Adding DistanceScale into the equations give:
If (distance > DistanceScale) volume = DistanceScale / distance else volume = 1.0
See Also
Reference
SoundEffect Class
SoundEffect Members
Microsoft.Xna.Framework.Audio Namespace
Platforms
Xbox 360, Windows XP SP2, Windows Vista, Zune