Microsoft DirectX 8.1 (Visual Basic) |
The SetFormat method sets the format of the buffer. Whenever this application gains the input focus, DirectSound sets the primary buffer to the specified format.
Syntax
object.SetFormat(format As WAVEFORMATEX)
Parts
object
Resolves to a DirectSoundPrimaryBuffer8 object.
format
WAVEFORMATEX type that specifies the new format for the primary sound buffer.
Error Codes
If the method fails, an error is raised and Err.Number may be set to one of the following error values.
DSERR_BADFORMAT |
DSERR_INVALIDCALL |
DSERR_INVALIDPARAM |
DSERR_OUTOFMEMORY |
DSERR_PRIOLEVELNEEDED |
Remarks
The format of the primary buffer should be set before secondary buffers are created.
The method fails if the application has the DSSCL_NORMAL cooperative level.
If the application is using DirectSound at the DSSCL_WRITEPRIMARY cooperative level, the buffer must be stopped before SetFormat is called. If the format is not supported, the method fails.
If the cooperative level is DSSCL_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 call the DirectSoundPrimaryBuffer8.GetFormat method for the primary buffer and compare the result with the format that was requested with the SetFormat method.
This method is not available for secondary sound buffers. If a new format is required, the application must create a new DirectSoundBuffer object.
See Also