Share via


DynamicSoundEffectInstance.SubmitBuffer Method (Byte , Int32, Int32)

Submits an audio buffer for playback. Playback begins at the specifed offset, and the byte count determines the size of the sample played.

Syntax

'Declaration
Public Sub SubmitBuffer ( _
         buffer As Byte(), _
         offset As Integer, _
         count As Integer _
)
public void SubmitBuffer (
         byte[] buffer,
         int offset,
         int count
)
public:
void SubmitBuffer(
         unsigned char buffer[],
         int offset,
         int count
)

Parameters

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

Exceptions

Exception type Condition
ObjectDisposedException The exception thrown if SubmitBuffer is called after DynamicSoundEffectInstance is disposed.
ArgumentException The exception thrown when buffer is null, is zero length, or does not satisfy format alignment restrictions. This exception also is thrown if offset is less than zero or is greater than or equal to the size of the buffer.
ArgumentOutOfRangeException The exception thrown when count is less than or equal to zero, or if the sum of offset and count exceeds the size of the buffer.

Remarks

The buffer must conform to the format alignment; for example, the buffer length must be aligned to the block alignment value for the audio format type. For PCM audio format, the block alignment is calculated as BlockAlignment = BytesPerSample * AudioChannels. DynamicSoundEffectInstance supports only PCM 16-bit mono or stereo data. Therefore, BlockAlignment = 2 * AudioChannels (Channels is 2 for mono content and 4 for stereo). The offset and count values also must conform to the format alignment restrictions.

For information about an audio format using XNA Game Studio, see Audio API Developers Guide.

Silverlight applications must ensure that FrameworkDispatcher.Update is called regularly in order for "fire and forget" sounds to work correctly. SubmitBuffer throws an InvalidOperationException if FrameworkDispatcher.Update has not been called at least once before making this call. For more information, see Enable XNA Framework Events in Windows Phone Applications.

Requirements

Namespace: Microsoft.Xna.Framework.Audio

Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

See Also

Concepts

Sounds Overview
Audio API Developers Guide

Reference

DynamicSoundEffectInstance Class
DynamicSoundEffectInstance Members
Microsoft.Xna.Framework.Audio Namespace

Platforms

Windows Phone