How to: Use Submix Voices

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.

创建一个包括对Submix Voice引用的XAUDIO2_VOICE_SENDS结构体:
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.

当创建Source Voices的时候,将XAUDIO2_VOICE_SENDS结构体传递给它们:
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.

通过调节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.

比如:使用SetVolume函数来改动Submix Voice的音量,能够有效得改变全部输出到它的voices的volume。
pSFXSubmixVoice->SetVolume(0.1);

交流QQ:1245178753


posted on 2017-07-11 19:25  slgkaifa  阅读(211)  评论(0编辑  收藏  举报

导航