DirectX SDK

DirectSound.CreateSoundBuffer

The DirectSound.CreateSoundBuffer method creates a DirectSoundBuffer object to hold a sequence of audio samples.

object.CreateSoundBuffer(bufferDesc As DSBUFFERDESC, _
    format As WAVEFORMATEX) As DirectSoundBuffer

Parameters

object
Object expression that resolves to a DirectSound object.
bufferDesc
A DSBUFFERDESC type that contains the description of the sound buffer to be created.
format
A WAVEFORMATEX type that describes the format of waveform-audio data.

Return Values

If the method succeeds, a DirectSoundBuffer object is returned.

Error Codes

If the method fails, an error is raised and Err.Number may be one of the following error values:

DSERR_ALLOCATED
DSERR_BADFORMAT
DSERR_INVALIDPARAM
DSERR_NOAGGREGATION
DSERR_OUTOFMEMORY
DSERR_UNINITIALIZED
DSERR_UNSUPPORTED

Remarks

Before it can play any sound buffers, the application must specify a cooperative level for a DirectSound object by using the DirectSound.SetCooperativeLevel method.

The bufferDesc parameter points to a type that describes the type of buffer desired, including format, size, and capabilities. The application must specify the needed capabilities, or they will not be available. For example, if the application creates a DirectSoundBuffer object without specifying the DSBCAPS_CTRLFREQUENCY flag, any call to DirectSoundBuffer.SetFrequency will fail.

The DSBCAPS_STATIC flag can also be specified, in which case DirectSound stores the buffer in on-board memory, if available, to take advantage of hardware mixing. To force the buffer to use either hardware or software mixing, use the DSBCAPS_LOCHARDWARE or DSBCAPS_LOCSOFTWARE flag. Additionally, you can have DirectSound assign a hardware or software resource during playing by using the DSBCAPS_LOCDEFER flag.

See Also

DSBUFFERDESC, DirectSound.DuplicateSoundBuffer, DirectSound.SetCooperativeLevel, DirectSoundBuffer, DirectSoundBuffer.GetFormat, DirectSoundBuffer.GetVolume, DirectSoundBuffer.Play, DirectSoundBuffer.SetFormat, DirectSoundBuffer.SetFrequency