Microsoft.Xna.Framework.Audio
Class DynamicSoundEffectInstance

java.lang.Object
  extended by Microsoft.Xna.Framework.Audio.SoundEffectInstance
      extended by Microsoft.Xna.Framework.Audio.DynamicSoundEffectInstance
All Implemented Interfaces:
IDisposable

public final class DynamicSoundEffectInstance
extends SoundEffectInstance

Provides properties, methods, and events for play back of the audio buffer.

Author:
Halofreak1990

Field Summary
 Event<EventArgs> BufferNeeded
          Event that occurs when the number of audio capture buffers awaiting playback is less than or equal to two.
 
Fields inherited from class Microsoft.Xna.Framework.Audio.SoundEffectInstance
IsLooped
 
Constructor Summary
DynamicSoundEffectInstance(int sampleRate, AudioChannels channels)
          Initializes a new instance of this class, which creates a dynamic sound effect based on the specified sample rate and audio channel.
 
Method Summary
protected  void Dispose(boolean disposing)
          Releases the unmanaged resources held by this SoundEffectInstance, and optionally releases the managed resources.
 TimeSpan GetSampleDuration(int sizeInBytes)
          Returns the sample duration based on the specified size of the audio buffer.
 int GetSampleSizeInBytes(TimeSpan duration)
          Returns the size of the audio buffer required to contain audio samples based on the specified duration.
 void Play()
          Begins or resumes audio playback.
 void SubmitBuffer(byte[] buffer)
          Submits an audio buffer for playback.
 void SubmitBuffer(byte[] buffer, int offset, int count)
          Submits an audio buffer for playback.
 
Methods inherited from class Microsoft.Xna.Framework.Audio.SoundEffectInstance
Apply3D, Apply3D, Dispose, finalize, getPan, getPitch, getState, getVolume, IsDisposed, Pause, Resume, setPan, setPitch, setVolume, Stop, Stop
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BufferNeeded

public Event<EventArgs> BufferNeeded
Event that occurs when the number of audio capture buffers awaiting playback is less than or equal to two.

Constructor Detail

DynamicSoundEffectInstance

public DynamicSoundEffectInstance(int sampleRate,
                                  AudioChannels channels)
Initializes a new instance of this class, which creates a dynamic sound effect based on the specified sample rate and audio channel.

Parameters:
sampleRate - Sample rate, in Hertz (Hz), of audio content.
channels - Number of channels in the audio data.
Method Detail

Dispose

protected void Dispose(boolean disposing)
Description copied from class: SoundEffectInstance
Releases the unmanaged resources held by this SoundEffectInstance, and optionally releases the managed resources.

Overrides:
Dispose in class SoundEffectInstance
Parameters:
disposing - Pass true to release both the managed and unmanaged resources for this SoundEffectInstance. Passing false releases only the unmanaged resources.

GetSampleDuration

public TimeSpan GetSampleDuration(int sizeInBytes)
Returns the sample duration based on the specified size of the audio buffer.

Parameters:
sizeInBytes - Size, in bytes, of the audio data.

GetSampleSizeInBytes

public int GetSampleSizeInBytes(TimeSpan duration)
Returns the size of the audio buffer required to contain audio samples based on the specified duration.

Parameters:
duration - TimeSpan object that contains the duration of the audio sample.

Play

public void Play()
Begins or resumes audio playback.

Overrides:
Play in class SoundEffectInstance

SubmitBuffer

public void SubmitBuffer(byte[] buffer)
Submits an audio buffer for playback. Playback starts at the beginning, and the buffer is played in its entirety.

Parameters:
buffer - Buffer that contains the audio data. The audio format must be PCM wave data.

SubmitBuffer

public void SubmitBuffer(byte[] buffer,
                         int offset,
                         int count)
Submits an audio buffer for playback. Playback begins at the specifed offset, and the byte count determines the size of the sample played.

Parameters:
buffer - Buffer that contains the audio data. The audio format must be PCM wave data.
offset - Offset, in bytes, to the starting position of the data.
count - Amount, in bytes, of data sent.