Understanding the Audio Capture Raw-Console C++ Sample

Kinect for Windows 1.5, 1.6, 1.7, 1.8

The Audio Capture Raw-Console C++ sample in the Developer Toolkit does not use the KinectAudio DirectX Media Object (DMO) to access the Kinect audio stream, but uses the underlying Windows Audio Session API (WASAPI) to capture the raw audio stream from the microphone array. This approach is substantially more complex than using the KinectAudio DMO, but will be useful for developers familiar with the capabilities of Windows Audio Session programming. This topic, and its subtopics, are a walkthrough of this sample.

The WASAPI is COM-based, and this walkthrough assumes that you are familiar with the basics of how to use COM objects and interfaces. You do not need to know how to implement COM objects.

Program Description

Project Files

The Audio Capture Raw-Console sample is a C++ console application that is implemented in the following files:

  • AudioCaptureRaw.cpp contains the application's entry point and manages overall program execution.
  • WASAPICapture.cpp and its associated header (WASAPICapture.h) implement the CWASAPICapture class, which handles the details of capturing the audio stream.
  • ResamplerUtil.cpp and its associated header (ResamplerUtil.h) implement a resampler class that takes that takes the mix format (IAudioClient::GetMixFormat) -- a WAVE_FORMAT_EXTENSIBLE structure -- and converts it to a WAVE_FORMAT_PCM. It does not change the sampling rate or the number of channels, but with small modifications this can be done as well if needed. It does change the PCM format from 32-bit float to 32-bit signed integer.

Program Flow

The Audio Capture Raw-Console basic program flow is:

  1. Enumerate the attached Kinect sensors and establish a connection to the first active, unused sensor.
  2. Set up the audio connection to the sensor.
  3. Capture and write the audio data to the capture file. The capture file is named KinectAudio_HH_MM_SS.wav, where HH:MM:SS is the local time at which the sampling started. This file is placed in your Music directory.

In This Section

Community Additions