Creating the Capture Object


If your application will capture and record sounds, you will create and use a Capture object.

The following C# example shows how to initialize a Capture object for the default device.
[C#]
private Capture dsCapture = null; dsCapture = new Capture();
The following C# example creates a device from a globally unique identifier (GUID), represented by the deviceGuid variable. This GUID can be obtained by enumeration of devices.
[C#]
dsCapture = new Capture(deviceGuid);

You can also use one of the following values to specify a default device.

Value Description
DSoundHelper.DefaultCaptureDevice The default system capture device. This is the same as the device created when no parameter is passed to the Capture constructor.
DSoundHelper.DefaultVoiceCaptureDevice The default voice capture device. Typically this is a secondary device such as a USB headset with microphone.

The object cannot be created if there is no capture device or, under VxD virtual device drivers, if the sound device is under the control of an application using the standard Microsoft Win32 waveform-audio functions.

If your application will capture sounds as well as play them, you should create both Device and Capture objects.

If you want the playback and capture objects to coexist, you should create and initialize the Device object before creating and initializing the Capture object.

Some audio devices are not configured for full duplex audio by default. If your application has problems with creating and initializing both a Device object and a Capture object, you should advise the user to check the audio device properties to ensure that full duplex is enabled.


Send comments about this topic to Microsoft. © Microsoft Corporation. All rights reserved.

Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center