Hi,
I was trying to implement an audio effect which takes as input a mono sound and outputs a stereo. The way I implemented it was to create a IXAudio2SubmixVoice voice and add an effect to it. Below is a snippet of my audio effect.
1 2 3 4 5 | MYX3DAudioFilter *pX3DFilter = new MYX3DAudioFilter((const XAPO_REGISTRATION_PROPERTIES*) rep); XAUDIO2_EFFECT_DESCRIPTOR descriptor; descriptor.InitialState = true; descriptor.OutputChannels = 2; descriptor.pEffect = pX3DFilter; |
Now, if I attach this effect when I create the IXAudio2SubmixVoice voice everything works fine. Below is the working snippet.
1 2 3 4 5 6 7 8 9 10 11 12 | XAUDIO2_EFFECT_CHAIN eChain; eChain.EffectCount = 1; eChain.pEffectDescriptors = &descriptor;
IXAudio2SubmixVoice* pSFXSubmixVoice; AudioManager* aManager = AudioManager::getManager(); if(FAILED(err = aManager->getEngine()->CreateSubmixVoice(&pSFXSubmixVoice, 1, 44100, 0, 0, 0, &eChain))) { char dumpString[100]; log->logMessage(LOG_ERROR, "Pipline Init Failure: XAUDIO3D_T"); log->logMessageArgs(LOG_ERROR, "%s", convertStr(dumpString, DXGetErrorString9(err))); return err; } |
However, if I initialize the IXAudio2SubmixVoice voice without the effect and then add the effect later using SetEffectChain() the code fails and gives the following error message:
"XAUDIO2: ERROR: Cannot use an effect chain that produces 2-channel audio, as it would change the number of channels produced by this voice (currently 1)"
1 2 3 4 5 6 7 8 9 10 | IXAudio2SubmixVoice* pSFXSubmixVoice; AudioManager* aManager = AudioManager::getManager(); if(FAILED(err = aManager->getEngine()->CreateSubmixVoice(&pSFXSubmixVoice, 1, 44100, 0, 0, 0, &eChain))) { char dumpString[100]; log->logMessage(LOG_ERROR, "Pipline Init Failure: XAUDIO3D_T"); log->logMessageArgs(LOG_ERROR, "%s", convertStr(dumpString, DXGetErrorString9(err))); return err; }
pSFXSubmixVoice->SetEffectChain(&eChain); |
I am not very sure why that happens. Though I have a working code it would still be helpful to know what I am doing wrong there.
Thanks,
Anish