public void PlaySound(SoundDefinition sound, Vector2 position) { var request = new SoundRequest(); request.Sound = sound; request.Position = position; soundRequests.Add(request); }
public void PlaySound(SoundDefinition sound) { var request = new SoundRequest(); request.Sound = sound; request.Position = null; soundRequests.Add(request); }
private void FireSound(SoundRequest request) { SoundEffectInstance instance = request.Sound.SoundEffect.CreateInstance(); if (request.Position != null) { Vector2 relative = (Vector2)request.Position - ListenerPosition; instance.Pan = MathHelper.Clamp(relative.X / PanDivisor, -PanClamp, PanClamp); } instance.Pitch = (request.Sound.MaxPitchVariation / 2.0f) - (float)random.NextDouble() * request.Sound.MaxPitchVariation; instance.Play(); playingSounds.Add(instance); }