Class DynamicSoundEffectInstance
A SoundEffectInstance for which the audio buffer is provided by the game at run time.
public sealed class DynamicSoundEffectInstance : SoundEffectInstance, IDisposable
- Inheritance
-
DynamicSoundEffectInstance
- Implements
- Inherited Members
Constructors
DynamicSoundEffectInstance(int, AudioChannels)
public DynamicSoundEffectInstance(int sampleRate, AudioChannels channels)
Parameters
sampleRate
intSample rate, in Hertz (Hz).
channels
AudioChannelsNumber of channels (mono or stereo).
Properties
IsLooped
This value has no effect on DynamicSoundEffectInstance. It may not be set.
public override bool IsLooped { get; set; }
Property Value
PendingBufferCount
Returns the number of audio buffers queued for playback.
public int PendingBufferCount { get; }
Property Value
State
Gets the SoundEffectInstance's current playback state.
public override SoundState State { get; }
Property Value
Methods
Dispose(bool)
protected override void Dispose(bool disposing)
Parameters
disposing
bool
GetSampleDuration(int)
Returns the duration of an audio buffer of the specified size, based on the settings of this instance.
public TimeSpan GetSampleDuration(int sizeInBytes)
Parameters
sizeInBytes
intSize of the buffer, in bytes.
Returns
- TimeSpan
The playback length of the buffer.
GetSampleSizeInBytes(TimeSpan)
Returns the size, in bytes, of a buffer of the specified duration, based on the settings of this instance.
public int GetSampleSizeInBytes(TimeSpan duration)
Parameters
duration
TimeSpanThe playback length of the buffer.
Returns
- int
The data size of the buffer, in bytes.
Pause()
Pauses playback of the DynamicSoundEffectInstance.
public override void Pause()
Play()
Plays or resumes the DynamicSoundEffectInstance.
public override void Play()
Resume()
Resumes playback of the DynamicSoundEffectInstance.
public override void Resume()
Stop()
Immediately stops playing the DynamicSoundEffectInstance.
public override void Stop()
Remarks
Calling this also releases all queued buffers.
Stop(bool)
Stops playing the DynamicSoundEffectInstance.
If the immediate
parameter is false, this call has no effect.
public override void Stop(bool immediate)
Parameters
immediate
boolWhen set to false, this call has no effect.
Remarks
Calling this also releases all queued buffers.
SubmitBuffer(byte[])
Queues an audio buffer for playback.
public void SubmitBuffer(byte[] buffer)
Parameters
buffer
byte[]The buffer containing PCM audio data.
Remarks
The buffer length must conform to alignment requirements for the audio format.
SubmitBuffer(byte[], int, int)
Queues an audio buffer for playback.
public void SubmitBuffer(byte[] buffer, int offset, int count)
Parameters
buffer
byte[]The buffer containing PCM audio data.
offset
intThe starting position of audio data.
count
intThe amount of bytes to use.
Remarks
The buffer length must conform to alignment requirements for the audio format.
Events
BufferNeeded
The event that occurs when the number of queued audio buffers is less than or equal to 2.
public event EventHandler<EventArgs> BufferNeeded
Event Type
Remarks
This event may occur when Play() is called or during playback when a buffer is completed.