How to: Use Submix Voices

This topic shows you how you can set groups of voices to send their output to the same submix voice. This enables a single change to a submix voice to affect a whole group of voices.

  1. Create a submix voice to which all of the game's sound effect voices will send.

    IXAudio2SubmixVoice * pSFXSubmixVoice;
  2. Create an XAUDIO2_VOICE_SENDS structure that contains a reference to the submix voice.

    XAUDIO2_SEND_DESCRIPTOR SFXSend = {0, pSFXSubmixVoice};
    XAUDIO2_VOICE_SENDS SFXSendList = {1, &SFXSend};
  3. Pass the XAUDIO2_VOICE_SENDS structure to new source voices as they are created.

    IXAudio2SourceVoice* pSFXSourceVoice;
    if( FAILED(hr = pXaudio2->CreateSourceVoice( &pSFXSourceVoice, (WAVEFORMATEX*)&wfx,
        0, XAUDIO2_DEFAULT_FREQ_RATIO, pCallback, pSFXSendList, NULL ) ) )
        return hr;
  4. Apply changes to all sound effect voices by adjusting the submix voice.

    In this example, changing the volume of the submix voice with the SetVolume function effectively changes the volume of all voices that output to it.



XAudio2 Programming Guide

How to: Build a Basic Audio Processing Graph