How to: Build a Basic Audio Processing Graph
The minimum requirement for enabling XAudio2 to play audio data is an audio processing graph, which is constructed from a single mastering voice and a single source voice.
- Initialize the XAudio2 engine by following the steps described in How to: Initialize XAudio2.
- Populate a WAVEFORMATEX and XAUDIO2_BUFFER structure by following the steps described in How to: Load Audio Data Files in XAudio2.
Create a source voice using the CreateSourceVoice function.
When you specify NULL for the pSendList argument of CreateSourceVoice, the source voice's output goes to the mastering voice created in step 1.
IXAudio2SourceVoice* pSourceVoice; if( FAILED(hr = pXAudio2->CreateSourceVoice( &pSourceVoice, (WAVEFORMATEX*)&wfx, 0, XAUDIO2_DEFAULT_FREQ_RATIO, NULL, NULL, NULL ) ) ) return hr;
A simple audio graph
if( FAILED(hr = pSourceVoice->SubmitSourceBuffer( &buffer ) ) ) return hr;
Use the Start function to start the source voice.
if ( FAILED(hr = pSourceVoice->Start( 0, XAUDIO2_COMMIT_NOW ) ) ) return hr;
Build date: 11/17/2013