![]() |
Paradox Game Engine
v1.0.0 beta06
|
This class provides a loaded sound resource which is localizable in the 3D scene. More...
Public Member Functions | |
SoundEffectInstance | CreateInstance () |
Create a new sound effect instance of the sound effect. The audio data are shared between the instances so that useless memory copies is avoided. Each instance that can be played and localized independently from others. More... | |
void | Apply3D (AudioListener listener, AudioEmitter emitter) |
Applies 3D positioning to the sound. More precisely adjust the channel volumes and pitch of the sound, such that the sound source seems to come from the emitter to the listener . More... | |
void | Play () |
Start or resume playing the sound. More... | |
void | Pause () |
Pause the sounds. More... | |
void | Stop () |
Stop playing the sound immediately and reset the sound to the beginning of the track. More... | |
void | ExitLoop () |
Stop looping. That is, do not start over at the end of the current loop, continue to play until the end of the buffer data and then stop. More... | |
void | Reset3D () |
Cancel the effect of possible previous calls to Apply3D. More... | |
![]() | |
void | Dispose () |
override string | ToString () |
Static Public Member Functions | |
static SoundEffect | Load (AudioEngine engine, Stream stream) |
Create and Load a sound effect from an input wav stream. More... | |
Protected Member Functions | |
override void | Destroy () |
Disposes of object resources. More... | |
![]() | |
ComponentBase () | |
Initializes a new instance of the ComponentBase class. More... | |
ComponentBase (string name) | |
Initializes a new instance of the ComponentBase class. More... | |
virtual void | OnNameChanged () |
Called when Name property was changed. More... | |
Properties | |
float | Pan [get, set] |
float | Volume [get, set] |
SoundPlayState | PlayState [get] |
bool | IsLooped [get, set] |
![]() | |
long | Id [get, set] |
string | Name [get, set] |
Gets or sets the name of this component. More... | |
bool | IsDisposed [get, set] |
Has the component been disposed or not yet. More... | |
![]() | |
long | Id [get] |
Gets the id of this component. More... | |
string | Name [get] |
Gets the name of this component. More... | |
![]() | |
int | ReferenceCount [get] |
Gets the reference count of this instance. More... | |
![]() | |
ObjectCollector | Collector [get] |
Gets the collector. More... | |
![]() | |
float | Pan [get, set] |
Set the sound balance between left and right speaker. More... | |
![]() | |
SoundPlayState | PlayState [get] |
The current state of the sound. More... | |
bool | IsLooped [get, set] |
Does the sound is automatically looping from beginning when it reaches the end. More... | |
float | Volume [get, set] |
The global volume at which the sound is played. More... | |
Additional Inherited Members | |
![]() | |
PropertyContainer | Tags |
Gets the attached properties to this component. More... | |
This class provides a loaded sound resource which is localizable in the 3D scene.
SoundEffects are usually short sounds that are localized and need to be played with very low latency. Classical examples are gun shots, foot steps, etc... Sound effects can be looped to seem longer. Its is not recommended to use SoundEffect to play long track as the memory required will be considerable. For that use please refer to the SoundMusic class.
You can then create multiple instances of that sound resource by calling CreateInstance.
A SoundEffect contains the audio data and metadata (such as wave data and data format) loaded from a sound file. You can create multiple SoundEffectInstance objects, and play and localize them independently. All these objects share the resources of that SoundEffect. For convenience purposes a default SoundEffectInstance is automatically created and associated to each SoundEffect, so that you can directly play them without having the need to create a first instance.
You can create a SoundEffect by calling the static Load load function. Currently only wav files are supported for soundEffects.
The only limit to the number of loaded SoundEffect objects is memory. A loaded SoundEffect will continue to hold its memory resources throughout its lifetime. All SoundEffectInstance objects created from a SoundEffect share memory resources. When a SoundEffect object is destroyed, all SoundEffectInstance objects previously created by that SoundEffect stop playing and become invalid.
Disposing a SoundEffect object, stops playing all the children SoundEffectInstance and then dispose them.
Definition at line 46 of file SoundEffect.cs.
void SiliconStudio.Paradox.Audio.SoundEffect.Apply3D | ( | AudioListener | listener, |
AudioEmitter | emitter | ||
) |
Applies 3D positioning to the sound. More precisely adjust the channel volumes and pitch of the sound, such that the sound source seems to come from the emitter to the listener .
listener | The sound listener of the scene |
emitter | The emitter that correspond to this sound |
Apply3D can be used only on mono-sounds.
A call to Apply3D reset Pan to its default values.
A call to Apply3D does not modify the value of IPlayableSound.Volume, the effective volume of the sound is a combination of the two effects.
The final resulting pitch depends on the listener and emitter relative velocity. The final resulting channel volumes depend on the listener and emitter relative positions and the value of IPlayableSound.Volume. The intensity of the doppler and attenuation effects can be adjusted using the AudioEmitter.DopplerScale and AudioEmitter.DistanceScale properties.
ObjectDisposedException | The sound has already been disposed |
ArgumentNullException | Provided listener or emitter is null |
InvalidOperationException | The sound has more than one channels. 3D positioning can be applied only to mono-sounds. |
Implements SiliconStudio.Paradox.Audio.IPositionableSound.
Definition at line 212 of file SoundEffect.cs.
SoundEffectInstance SiliconStudio.Paradox.Audio.SoundEffect.CreateInstance | ( | ) |
Create a new sound effect instance of the sound effect. The audio data are shared between the instances so that useless memory copies is avoided. Each instance that can be played and localized independently from others.
ObjectDisposedException | The sound has already been disposed |
Definition at line 126 of file SoundEffect.cs.
|
protectedvirtual |
Disposes of object resources.
Reimplemented from SiliconStudio.Core.ComponentBase.
Definition at line 253 of file SoundEffect.cs.
void SiliconStudio.Paradox.Audio.SoundEffect.ExitLoop | ( | ) |
Stop looping. That is, do not start over at the end of the current loop, continue to play until the end of the buffer data and then stop.
A call to ExitLoop when the sound is Stopped or when the sound is not looping has no effects. That is why a call to ExitLoop directly following a call to Play may be ignored (short play latency). For a correct behaviour wait that the sound actually started playing to call ExitLoop.
ExitLoop does not modify the value of IsLooped.
ObjectDisposedException | The sound has already been disposed |
Implements SiliconStudio.Paradox.Audio.IPlayableSound.
Definition at line 243 of file SoundEffect.cs.
|
static |
Create and Load a sound effect from an input wav stream.
engine | Name of the audio engine in which to create the sound effect |
stream | A stream corresponding to a wav file. |
ArgumentNullException | engine or stream is null. |
NotSupportedException | The wave file or has more than 2 channels or is not encoded in 16bits. |
InvalidOperationException | The content of the stream does not correspond to a valid wave file. |
OutOfMemoryException | There is not enough memory anymore to load the specified file in memory. |
ObjectDisposedException | The audio engine has already been disposed |
Supported WAV files' audio format is the 16bits PCM format.
Definition at line 68 of file SoundEffect.cs.
References SiliconStudio.Core.ComponentBase.IsDisposed.
void SiliconStudio.Paradox.Audio.SoundEffect.Pause | ( | ) |
Pause the sounds.
ObjectDisposedException | The sound has already been disposed |
A call to Pause when the sound is already paused or stopped has no effects.
Implements SiliconStudio.Paradox.Audio.IPlayableSound.
Definition at line 233 of file SoundEffect.cs.
void SiliconStudio.Paradox.Audio.SoundEffect.Play | ( | ) |
Start or resume playing the sound.
ObjectDisposedException | The sound has already been disposed |
A call to Play when the sound is already playing has no effects.
Implements SiliconStudio.Paradox.Audio.IPlayableSound.
Definition at line 228 of file SoundEffect.cs.
void SiliconStudio.Paradox.Audio.SoundEffect.Reset3D | ( | ) |
Cancel the effect of possible previous calls to Apply3D.
Do not revert Pan to its value before Apply3D.
Implements SiliconStudio.Paradox.Audio.IPositionableSound.
Definition at line 248 of file SoundEffect.cs.
void SiliconStudio.Paradox.Audio.SoundEffect.Stop | ( | ) |
Stop playing the sound immediately and reset the sound to the beginning of the track.
ObjectDisposedException | The sound has already been disposed |
A call to Stop when the sound is already stopped has no effects
Implements SiliconStudio.Paradox.Audio.IPlayableSound.
Definition at line 238 of file SoundEffect.cs.
|
getset |
Definition at line 223 of file SoundEffect.cs.
|
getset |
Definition at line 201 of file SoundEffect.cs.
|
get |
Definition at line 218 of file SoundEffect.cs.
|
getset |
Definition at line 207 of file SoundEffect.cs.