Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
SiliconStudio.Paradox.Audio.SoundEffect Class Reference

This class provides a loaded sound resource which is localizable in the 3D scene. More...

Inheritance diagram for SiliconStudio.Paradox.Audio.SoundEffect:
SiliconStudio.Paradox.Audio.SoundBase SiliconStudio.Paradox.Audio.IPositionableSound SiliconStudio.Core.ComponentBase SiliconStudio.Paradox.Audio.IPlayableSound SiliconStudio.Core.IComponent SiliconStudio.Core.ICollectorHolder SiliconStudio.Core.IReferencable SiliconStudio.Core.IReferencable

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...
 
- Public Member Functions inherited from SiliconStudio.Core.ComponentBase
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...
 
- Protected Member Functions inherited from SiliconStudio.Core.ComponentBase
 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]
 
- Properties inherited from SiliconStudio.Core.ComponentBase
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...
 
- Properties inherited from SiliconStudio.Core.IComponent
long Id [get]
 Gets the id of this component. More...
 
string Name [get]
 Gets the name of this component. More...
 
- Properties inherited from SiliconStudio.Core.IReferencable
int ReferenceCount [get]
 Gets the reference count of this instance. More...
 
- Properties inherited from SiliconStudio.Core.ICollectorHolder
ObjectCollector Collector [get]
 Gets the collector. More...
 
- Properties inherited from SiliconStudio.Paradox.Audio.IPositionableSound
float Pan [get, set]
 Set the sound balance between left and right speaker. More...
 
- Properties inherited from SiliconStudio.Paradox.Audio.IPlayableSound
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

- Public Attributes inherited from SiliconStudio.Core.ComponentBase
PropertyContainer Tags
 Gets the attached properties to this component. More...
 

Detailed Description

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.

See also
SoundEffectInstance, SoundMusic, IPositionableSound

Definition at line 46 of file SoundEffect.cs.

Member Function Documentation

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 .

Parameters
listenerThe sound listener of the scene
emitterThe 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.

See also
AudioListener, AudioEmitter
Exceptions
ObjectDisposedExceptionThe sound has already been disposed
ArgumentNullExceptionProvided listener or emitter is null
InvalidOperationExceptionThe 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.

Returns
A new sound instance
Exceptions
ObjectDisposedExceptionThe sound has already been disposed

Definition at line 126 of file SoundEffect.cs.

override void SiliconStudio.Paradox.Audio.SoundEffect.Destroy ( )
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.

Exceptions
ObjectDisposedExceptionThe sound has already been disposed

Implements SiliconStudio.Paradox.Audio.IPlayableSound.

Definition at line 243 of file SoundEffect.cs.

static SoundEffect SiliconStudio.Paradox.Audio.SoundEffect.Load ( AudioEngine  engine,
Stream  stream 
)
static

Create and Load a sound effect from an input wav stream.

Parameters
engineName of the audio engine in which to create the sound effect
streamA stream corresponding to a wav file.
Returns
A new instance soundEffect ready to be played
Exceptions
ArgumentNullExceptionengine or stream is null.
NotSupportedExceptionThe wave file or has more than 2 channels or is not encoded in 16bits.
InvalidOperationExceptionThe content of the stream does not correspond to a valid wave file.
OutOfMemoryExceptionThere is not enough memory anymore to load the specified file in memory.
ObjectDisposedExceptionThe 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.

Exceptions
ObjectDisposedExceptionThe 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.

Exceptions
ObjectDisposedExceptionThe 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.

Exceptions
ObjectDisposedExceptionThe 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.

Property Documentation

bool SiliconStudio.Paradox.Audio.SoundEffect.IsLooped
getset

Definition at line 223 of file SoundEffect.cs.

float SiliconStudio.Paradox.Audio.SoundEffect.Pan
getset

Definition at line 201 of file SoundEffect.cs.

SoundPlayState SiliconStudio.Paradox.Audio.SoundEffect.PlayState
get

Definition at line 218 of file SoundEffect.cs.

float SiliconStudio.Paradox.Audio.SoundEffect.Volume
getset

Definition at line 207 of file SoundEffect.cs.


The documentation for this class was generated from the following file: