4 using System.Collections.Generic;
5 using System.Diagnostics;
7 using SiliconStudio.Core.Extensions;
8 using SiliconStudio.Core.Mathematics;
9 using SiliconStudio.Paradox.Audio;
13 namespace SiliconStudio.
Paradox.Engine
32 [DebuggerDisplay(
"Controller for {soundEffect.Name}")]
48 private readonly HashSet<SoundEffectInstance> associatedSoundEffectInstances =
new HashSet<SoundEffectInstance>();
58 if(soundEffect == null)
59 throw new ArgumentNullException(
"soundEffect");
61 this.soundEffect = soundEffect;
73 var newInstance = soundEffect.CreateInstance();
75 associatedSoundEffectInstances.Add(newInstance);
86 soundInstance.Dispose();
87 associatedSoundEffectInstances.Remove(soundInstance);
93 internal void DestroyAllSoundInstances()
95 foreach (var instance
in associatedSoundEffectInstances)
99 associatedSoundEffectInstances.Clear();
108 if (!associatedSoundEffectInstances.Any())
121 if(associatedSoundEffectInstances.Any(x=>x.PlayState ==
SoundPlayState.Playing))
128 private bool isLooped;
137 foreach (var instance
in associatedSoundEffectInstances)
139 instance.IsLooped = value;
149 internal bool ShouldBePlayed;
153 playState = SoundPlayState.Playing;
160 parent.ShouldBeProcessed =
true;
161 ShouldBePlayed =
true;
169 playState = SoundPlayState.Paused;
171 foreach (var instance
in associatedSoundEffectInstances)
175 ShouldBePlayed =
false;
180 playState = SoundPlayState.Stopped;
182 foreach (var instance
in associatedSoundEffectInstances)
186 ShouldBePlayed =
false;
189 internal bool ShouldExitLoop;
193 ShouldExitLoop =
true;
195 foreach (var instance
in associatedSoundEffectInstances)
201 private float volume;
210 volume = MathUtil.Clamp(value, 0, 1);
212 foreach (var instance
in associatedSoundEffectInstances)
214 instance.Volume = volume;
This class is used to control a SiliconStudio.Paradox.Audio.SoundEffect associated to a AudioEmitterC...
This class provides a loaded sound resource which is localizable in the 3D scene. ...
SoundPlayState
Current state (playing, paused, or stopped) of a sound implementing the IPlayableSound interface...
void Pause()
Pause the sounds.
void Play()
Start or resume playing the sound.
void ExitLoop()
Stop looping. That is, do not start over at the end of the current loop, continue to play until the e...
Interface for a playable sound. A playable sound can loop (ref IsLooped), be played (ref Play)...
void Stop()
Stop playing the sound immediately and reset the sound to the beginning of the track.
Component representing an audio emitter.
Instance of a SoundEffect sound which can be independently localized and played.