SoundEffect

class SoundEffect : System.Object, System.IDisposable

Represents a loaded sound resource.

readonly System.TimeSpan Duration

Gets the duration of the SoundEffect.

string Name

Gets or sets the asset name of the SoundEffect.

float MasterVolume

Gets or sets the master volume scale applied to all SoundEffectInstances.

float DistanceScale

Gets or sets the scale of distance calculations.

float DopplerScale

Gets or sets the scale of Doppler calculations applied to sounds.

float SpeedOfSound

Returns the speed of sound used when calculating the Doppler effect..

readonly bool IsDisposed

Indicates whether the object is disposed.

SharpDX.Multimedia.Speakers Speakers
public SoundEffectInstance CreateInstance()

Creates a new SoundEffectInstance for this SoundEffect.

Returns:A new SoundEffectInstance for this SoundEffect.
public SoundEffect FromStream(System.IO.Stream stream)

Creates a new SoundEffect object based on the specified data stream.

Parameters:
  • stream (System.IO.Stream) – A stream containing the PCM wave data.
Returns:

A new SoundEffect object.

public System.TimeSpan GetSampleDuration(int sizeInBytes, int sampleRate, AudioChannels channels)

Returns the duration for 16bit PCM audio.

Parameters:
  • sizeInBytes (int) – The length of the audio data in bytes.
  • sampleRate (int) – Sample rate, in Hertz (Hz). Must be between 8000 Hz and 48000 Hz
  • channels (Microsoft.Xna.Framework.Audio.AudioChannels) – Number of channels in the audio data.
Returns:

The duration of the audio data.

public int GetSampleSizeInBytes(System.TimeSpan duration, int sampleRate, AudioChannels channels)

Returns the data size in bytes for 16bit PCM audio.

Parameters:
  • duration (System.TimeSpan) – The total duration of the audio data.
  • sampleRate (int) – Sample rate, in Hertz (Hz), of audio data. Must be between 8,000 and 48,000 Hz.
  • channels (Microsoft.Xna.Framework.Audio.AudioChannels) – Number of channels in the audio data.
Returns:

The size in bytes of a single sample of audio data.

public bool Play()

Gets an internal SoundEffectInstance and plays it.

Returns:True if a SoundEffectInstance was successfully played, false if not.
public bool Play(float volume, float pitch, float pan)

Gets an internal SoundEffectInstance and plays it with the specified volume, pitch, and panning.

Parameters:
  • volume (float) – Volume, ranging from 0.0 (silence) to 1.0 (full volume). Volume during playback is scaled by SoundEffect.MasterVolume.
  • pitch (float) – Pitch adjustment, ranging from -1.0 (down an octave) to 0.0 (no change) to 1.0 (up an octave).
  • pan (float) – Panning, ranging from -1.0 (left speaker) to 0.0 (centered), 1.0 (right speaker).
Returns:

True if a SoundEffectInstance was successfully created and played, false if not.

SoundEffectInstance GetPooledInstance(bool forXAct)

Returns a sound effect instance from the pool or null if none are available.

Parameters:
  • forXAct (bool) –
public void Dispose()

Releases the resources held by this T:Microsoft.Xna.Framework.Audio.SoundEffect.

SharpDX.XAudio2.XAudio2 get_Device()
SharpDX.XAudio2.MasteringVoice get_MasterVoice()
SharpDX.X3DAudio.X3DAudio get_Device3D()
SharpDX.XAudio2.SubmixVoice get_ReverbVoice()
void InitializeSoundEffect()

Initializes XAudio.

void PlatformSetReverbSettings(Microsoft.Xna.Framework.Audio.ReverbSettings reverbSettings)
Parameters:
  • reverbSettings (Microsoft.Xna.Framework.Audio.ReverbSettings) –
void PlatformShutdown()