How to: Use Submix Voices:https://msdn.microsoft.com/en-us/library/windows/desktop/ee415794(v=vs.85).aspx
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.
这篇文章向你展示怎样设置一组声音,使它们的输出发送到同一个Submix Voice。这样能够实现一个Submix Voice一个改变能够影响一整组声音。
1.Create a submix voice to which all of the game's sound effect voices will send.
创建一个全部游戏声效都会输出到此的Submix Voice:
IXAudio2SubmixVoice * pSFXSubmixVoice; pXAudio2->CreateSubmixVoice(&pSFXSubmixVoice,1,44100,0,0,0,0);
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;
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.
pSFXSubmixVoice->SetVolume(0.1);
交流QQ:1245178753