Platform SDK: DirectX |
The DirectSoundBuffer.SetFormat method sets the format of the primary sound buffer for the application. Whenever this application gains the input focus, DirectSound sets the primary buffer to the specified format.
object.SetFormat(format As WAVEFORMATEX)
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 |
DSERR_UNSUPPORTED |
This method succeeds even if the hardware does not support the requested format. DirectSound sets the buffer to the closest supported format, and mixes the sound in the requested format and converts it before sending it to the primary buffer. To determine whether this is happening, an application can call the DirectSoundBuffer.GetFormat method for the primary buffer and compare the result with the format that was requested with the SetFormat method.
The method fails if the calling application has the DSSCL_NORMAL cooperative level.
This method is not valid for secondary sound buffers. If a secondary sound buffer requires a format change, the application should create a new DirectSoundBuffer object using the new format.