I'm trying to get a reverb effect on every source voice in addition to having a reverb effect on a master Submix, whenever I have both running the audio is garbage. Is it possible to do this?
I've tried a couple things: Below is setting up the sumix master with its reverb effect
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
// Reverb effect in XAudio2 currently only supports mono channel count const XAUDIO2_EFFECT_DESCRIPTOR effects[] = { { pReverbEffect, TRUE, 1 } }; const XAUDIO2_EFFECT_CHAIN effectChain = { 1, effects };
// Create our submix voices if( FAILED(hr = pXAudio2->CreateSubmixVoice( &pSubmixMaster, 1, details.OutputFormat.Format.nSamplesPerSec, 0, 1, NULL, &effectChain ) ) ) { pXAudio2->Release(); pReverbEffect->Release(); pReverbEffect=NULL; pXAudio2=NULL; Debug::Notify("Failed CreateSubmixVoice"); return; }
// Set default FX params XAUDIO2FX_REVERB_PARAMETERS native; ReverbConvertI3DL2ToNative( &PRESET_EFX[0], &native ); pSubmixMaster->SetEffectParameters( 0, &native, sizeof(native) ); |
1. Each SourceVoice gets routed to a SubmixVoice (which has a reverb effect) which then gets routed to the master Sumix (which also has a reverb effect). This clips the audio extremely badly. Below shows what I'm doing
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
IUnknown* tempEfx; // Create reverb effect if ( FAILED(hr = XAudio2CreateReverb( &tempEfx, flags ) ) ) { pXAudio2->Release(); pXAudio2=NULL; Debug::Notify("Failed XAudio2CreateReverb"); return; } g_XA2Buffers .m_ReverbEfx = tempEfx;
const IXAudio2Voice* voices[] = { pMasteringVoice, pSubmixMaster }; const XAUDIO2_VOICE_SENDS sendList = { 2, (IXAudio2Voice**)voices };
const XAUDIO2_EFFECT_DESCRIPTOR effects[] = { { tempEfx, TRUE, 1 } }; const XAUDIO2_EFFECT_CHAIN effectChain = { 1, effects };
IXAudio2SubmixVoice* tempMixer; if( FAILED(hr = pXAudio2->CreateSubmixVoice( &tempMixer, 1, details.OutputFormat.Format.nSamplesPerSec, 0, 0, &sendList, &effectChain ) ) ) { pXAudio2->Release(); pReverbEffect->Release(); pReverbEffect=NULL; pXAudio2=NULL; Debug::Notify("Failed CreateSubmixVoice"); return; } tempMixer->SetEffectParameters( 0, &native, sizeof(native) ); g_XA2Buffers .m_EfxMixer = tempMixer;
const IXAudio2Voice* voices[] = { pMasteringVoice, pSubmixMaster, (IXAudio2SubmixVoice*)m_EfxMixer }; const XAUDIO2_VOICE_SENDS sendList = { 3, (IXAudio2Voice**)voices }; IXAudio2SourceVoice* tmpBuff; if (FAILED(hr= pXAudio2->CreateSourceVoice( &tmpBuff, wavformat, 0, XAUDIO2_DEFAULT_FREQ_RATIO, NULL, &sendList ) )) { Debug::Notify("Failed CreateSourceVoice"); return; } |
2. Each SourceVoice gets a reverb effect using the effect chain param in CreateSourceVoice(..) and is then send to the master Submix (which has its own reverb effect). This yields silence.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
const IXAudio2Voice* voices[] = { pMasteringVoice, pSubmixMaster };const XAUDIO2_VOICE_SENDS sendList = { 2, (IXAudio2Voice**)voices };// Create reverb effect IUnknown* tempReverb=NULL; int flags = 0; #ifdef _DEBUG flags = XAUDIO2_DEBUG_ENGINE; #endif if ( FAILED(hr = XAudio2CreateReverb( &tempReverb, flags ) ) ) { Debug::Notify("Failed XAudio2CreateReverb"); }
// Create the source voice IXAudio2SourceVoice* tmpBuff; if (tempReverb) {
const XAUDIO2_EFFECT_DESCRIPTOR effects[] = { { tempReverb, TRUE, 1 } }; const XAUDIO2_EFFECT_CHAIN effectChain = { 1, effects };
if (FAILED(hr= pXAudio2->CreateSourceVoice( &tmpBuff, wavformat, XAUDIO2_VOICE_USEFILTER, XAUDIO2_DEFAULT_FREQ_RATIO, NULL, &sendList, &effectChain ) )) { Debug::Notify("Failed CreateSourceVoice"); return; } XAUDIO2FX_REVERB_PARAMETERS native; ReverbConvertI3DL2ToNative( &PRESET_EFX[0], &native ); tmpBuff->SetEffectParameters( 0, &native, sizeof(native) ); m_ReverbEfx = tempReverb; } else { if (FAILED(hr= pXAudio2->CreateSourceVoice( &tmpBuff, wavformat, 0, XAUDIO2_DEFAULT_FREQ_RATIO, NULL, &sendList ) )) { Debug::Notify("Failed CreateSourceVoice"); return; } } |
I basically need the ability to have an effect on any source voice in addition to having an effect running on the submix master.
Any advice on what I'm doing wrong or a method to do this would be great.
Bino