DirectX Audio API Reference

The DirectX Audio APIs provide a comprehensive set of tools for developers to integrate advanced audio functionalities into their Windows applications and games. This section details the core interfaces, structures, and functions used for audio playback, recording, mixing, and effects processing.

Core Components

The DirectX Audio subsystem is built around several key components:

XAudio2 Interfaces

XAudio2 provides a rich set of interfaces for managing audio data, effects, and playback devices.

IXAudio2

The primary interface for interacting with XAudio2. It's used to create voices, manage mastering, and access audio devices.

// Creating an XAudio2 engine instance
IXAudio2* pXAudio2 = nullptr;
HRESULT hr = XAudio2Create(&pXAudio2, 0, XAUDIO2_DEFAULT_PROCESSOR);
if (SUCCEEDED(hr)) {
    // Engine created successfully
}
                

IXAudio2MasteringVoice

Represents the audio device that the application will output sound to. All other voices are typically connected to the mastering voice.

IXAudio2SourceVoice

Represents a sound source. You submit audio buffers to a source voice for playback.

IXAudio2SubmixVoice

Used to create submixes for applying effects to multiple source voices collectively.

Common Structures and Enums

Several data structures and enumerations are fundamental to using the DirectX Audio APIs.

XAUDIO2_BUFFER

Defines the properties of an audio buffer to be submitted for playback.

XAUDIO2_VOICE_STATE

Provides the current state of an audio voice.

XAUDIO2_SEND_DESCRIPTOR

Describes a connection from one voice to another (a send).

Key Functions

These functions are commonly used when working with DirectX Audio.

XAudio2Create

Initializes the XAudio2 engine.

IXAudio2::CreateMasteringVoice

Creates a mastering voice for the default audio device.

IXAudio2::CreateSourceVoice

Creates a source voice for playing audio.

IXAudio2SourceVoice::SubmitSourceBuffer

Submits an audio buffer to a source voice for playback.

IXAudio2SourceVoice::StartVoice

Starts playback on a source voice.

IXAudio2SourceVoice::StopVoice

Stops playback on a source voice.

API Reference Table

Interface/Function Description Documentation Link
IXAudio2 Main XAudio2 engine interface. Link to IXAudio2 docs
XAudio2Create Initializes the XAudio2 engine. Link to XAudio2Create docs
IXAudio2::CreateMasteringVoice Creates a mastering voice. Link to CreateMasteringVoice docs
IXAudio2::CreateSourceVoice Creates a source voice. Link to CreateSourceVoice docs
IXAudio2SourceVoice::SubmitSourceBuffer Submits an audio buffer for playback. Link to SubmitSourceBuffer docs
XAUDIO2_BUFFER Structure representing an audio buffer. Link to XAUDIO2_BUFFER docs

Advanced Topics