4 using System.Collections.Generic;
5 using System.Collections.Specialized;
7 using SiliconStudio.Core;
8 using SiliconStudio.Core.Serialization.Converters;
9 using SiliconStudio.Paradox.Audio;
10 using SiliconStudio.Paradox.EntityModel;
12 namespace SiliconStudio.
Paradox.Engine
39 internal readonly Dictionary<SoundEffect, AudioEmitterSoundController> SoundEffectToController =
new Dictionary<SoundEffect, AudioEmitterSoundController>();
50 AttachSoundEffects(soundEffectToAttach);
64 internal class ControllerCollectionChangedEventArgs
79 public NotifyCollectionChangedAction Action;
84 Controller = controller;
92 internal event EventHandler<ControllerCollectionChangedEventArgs> ControllerCollectionChanged;
107 if (soundEffect == null)
109 throw new ArgumentNullException(
"soundEffect");
111 if (!SoundEffectToController.ContainsKey(soundEffect))
113 throw new ArgumentException(
"The provided soundEffect has not been attached to the EmitterComponent.");
116 return SoundEffectToController[soundEffect];
129 if (soundEffect == null)
131 throw new ArgumentNullException(
"soundEffect");
133 if (soundEffect.WaveFormat.Channels > 1)
135 throw new InvalidOperationException(
"The provided SoundEffect has more than one channel. It can not be localized in the 3D scene.");
138 if(SoundEffectToController.ContainsKey(soundEffect))
142 SoundEffectToController[soundEffect] = newController;
143 if(ControllerCollectionChanged != null)
144 ControllerCollectionChanged.Invoke(
this,
new ControllerCollectionChangedEventArgs(
Entity, newController, NotifyCollectionChangedAction.
Add ));
157 if (soundEffects == null)
159 throw new ArgumentNullException(
"soundEffects");
162 foreach (var soundEffect
in soundEffects)
164 AttachSoundEffect(soundEffect);
177 if (soundEffect == null)
179 throw new ArgumentNullException(
"soundEffect");
181 if (!SoundEffectToController.ContainsKey(soundEffect))
183 throw new ArgumentException(
"The provided soundEffect is not currently attached to this emitter component.");
186 var oldController = SoundEffectToController[soundEffect];
187 SoundEffectToController.Remove(soundEffect);
188 if (ControllerCollectionChanged != null)
189 ControllerCollectionChanged.Invoke(
this,
new ControllerCollectionChangedEventArgs(
Entity, oldController, NotifyCollectionChangedAction.Remove));
201 if (soundEffects == null)
203 throw new ArgumentNullException(
"soundEffects");
206 foreach (var soundEffect
in soundEffects)
208 DetachSoundEffect(soundEffect);
226 public float DistanceScale
228 get {
return distanceScale; }
233 throw new ArgumentOutOfRangeException();
235 distanceScale = value;
238 private float distanceScale;
254 public float DopplerScale
256 get {
return dopplerScale; }
261 throw new ArgumentOutOfRangeException();
263 dopplerScale = value;
266 private float dopplerScale;
271 internal bool ShouldBeProcessed {
get; set; }
void AttachSoundEffects(IEnumerable< SoundEffect > soundEffects)
Attach a list of SoundEffect to this emitter component. Once attached a AudioEmitterSoundController c...
Game entity. It usually aggregates multiple EntityComponent
AudioEmitterComponent()
Create an instance of AudioEmitterComponent with no default SoundEffect associated.
void DetachSoundEffect(SoundEffect soundEffect)
Detach a SoundEffect from this emitter component. Once detach the controller previously associated to...
This class is used to control a SiliconStudio.Paradox.Audio.SoundEffect associated to a AudioEmitterC...
AudioEmitterSoundController GetSoundEffectController(SoundEffect soundEffect)
Return a AudioEmitterSoundController that can be used to control the provided SoundEffect.
This class provides a loaded sound resource which is localizable in the 3D scene. ...
AudioEmitterComponent(IEnumerable< SoundEffect > soundEffectToAttach)
Create an instance of AudioEmitterComponent with a list default SoundEffect associated.
Component representing an audio emitter.
void Add(EntityComponent component)
Adds the specified component using the EntityComponent.DefaultKey.
A class that represents a tag propety.
void AttachSoundEffect(SoundEffect soundEffect)
Attach a SoundEffect to this emitter component. Once attached a AudioEmitterSoundController can be qu...
void DetachSoundEffects(IEnumerable< SoundEffect > soundEffects)
Detach a list of SoundEffect from this emitter component. Once detach the controller previously assoc...