Microsoft DirectX 8.1 (Visual Basic)

Creating the DirectSound Object

Create the DirectSound8 object by using the DirectX8.DirectSoundCreate method. The single parameter specifies the GUID of the device to be associated with the object. You can obtain this GUID by Enumeration of Sound Devices, or you can specify a default device by passing one of the following values:

DSDEVID_DEFAULTPLAYBACK

The default system audio device. You can also specify this device by passing vbNullString in the device GUID parameter. The default device is the one enumerated as "Primary DirectSound Driver".

DSDEVID_DEFAULTVOICEPLAYBACK

The default voice communications device. Typically this is a secondary device such as a USB headset with microphone.

The creation method raises an error if there is no sound device or if the sound device is under the control of an application using the waveform audio (non-DirectSound) functions. You should prepare your applications for this call to fail, so that they can either continue without sound or prompt the user to close the application that is already using the sound device.

The following example code creates a DirectSound8 object using the default system device:

Dim m_dx As New DirectX8
Dim m_ds As DirectSound8
Set m_ds = m_dx.DirectSoundCreate(vbNullString)