Share via


Buffer.Format Property (Microsoft.DirectX.DirectSound)

Retrieves or sets a description of the sound data format in the buffer.

Definition

Visual Basic Public Property Format As WaveFormat
C# public WaveFormat Format { get; set; }
C++ public:
property WaveFormat Format {
        WaveFormat get();
        void set(WaveFormat value);
}
JScript public function get Format() : WaveFormat
public function set Format(WaveFormat);

Property Value

Microsoft.DirectX.DirectSound.WaveFormat
A WaveFormat object that represents the current sound data format in the buffer or sound data format values to set.

This property is read/write. 

Remarks

The Buffer.Format property sets the format of the primary buffer. Whenever this application has the input focus, Microsoft DirectSound will set the primary buffer to the specified format.

The format of the primary buffer should be set before secondary buffers are created.

Setting the property fails if the application has the CooperativeLevel.Normal cooperative level.

If the application is using DirectSound at the CooperativeLevel.WritePrimary cooperative level, the buffer must be stopped before Buffer.Format is called to set a new WaveFormat. If the format is not supported, the method fails.

If the cooperative level is CooperativeLevel.Priority, DirectSound stops the primary buffer, changes the format, and restarts the buffer. The method succeeds even if the hardware does not support the requested format; DirectSound sets the buffer to the closest supported format. To determine whether this has happened, an application can obtain the WaveFormat object using Buffer.Format property for the primary buffer and compare the result with the format that was set using Buffer.Format property.

This property is not available for secondary sound buffers. If a new format is required, the application must create a new Buffer object.

Exceptions

ArgumentExceptionLeave Site An invalid parameter was passed to the called method.
BadFormatException The specified wave format is not supported.
InvalidCallException The method call is invalid for the current state of this object.
OutOfMemoryExceptionLeave Site DirectSound could not allocate sufficient memory to complete the call.
PriorityLevelNeededException A cooperative level of Priority or higher is required.
UnsupportedException The function called is not supported at this time.

Applies To

SecondaryBuffer