/// <summary> /// Initializes a new instance of the <see cref="AudioManager" /> class. /// </summary> /// <param name="game">The game.</param> public AudioManager(Game game) : base(game) { Services.AddService(this); masterVolume = 1.0f; Speakers = Speakers.None; masteringLimiterParameters = new MasteringLimiterParameters { Loudness = MasteringLimiter.DefaultLoudness, Release = MasteringLimiter.DefaultRelease }; reverbParameters = (ReverbParameters)ReverbI3DL2Parameters.Presets.Default; InstancePool = new SoundEffectInstancePool(this); // register the audio manager as game system game.GameSystems.Add(this); }
/// <summary> /// Sets the mastering limiter parameters. /// </summary> /// <param name="release">Speed at which the limiter stops affecting audio once it drops below the limiter's threshold.</param> /// <param name="loudness">Threshold of the limiter.</param> /// <exception cref="ObjectDisposedException">Is thrown when this instance was already disposed.</exception> /// <exception cref="ArgumentOutOfRangeException">Is thrown when either <paramref name="release"/> or <paramref name="loudness"/> are outside of allowed ranges /// (<see cref="MasteringLimiter.MinimumRelease"/>/<see cref="MasteringLimiter.MaximumRelease"/> /// and <see cref="MasteringLimiter.MinimumLoudness"/>/<see cref="MasteringLimiter.MaximumLoudness"/> respectively).</exception> public void SetMasteringLimit(int release, int loudness) { DisposeGuard(); if (release < MasteringLimiter.MinimumRelease || release > MasteringLimiter.MaximumRelease) { throw new ArgumentOutOfRangeException("release"); } if (loudness < MasteringLimiter.MinimumLoudness || loudness > MasteringLimiter.MaximumLoudness) { throw new ArgumentOutOfRangeException("loudness"); } masteringLimiterParameters = new MasteringLimiterParameters { Loudness = loudness, Release = release }; if (MasteringVoice != null && masteringLimiter != null) { MasteringVoice.SetEffectParameters(0, masteringLimiterParameters); } }