Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Volume meter on Mixer with empty send list #243

Closed
W4RH4WK opened this issue Mar 12, 2021 · 2 comments · Fixed by #245
Closed

Volume meter on Mixer with empty send list #243

W4RH4WK opened this issue Mar 12, 2021 · 2 comments · Fixed by #245

Comments

@W4RH4WK
Copy link
Contributor

W4RH4WK commented Mar 12, 2021

We are using FAudio for porting an video game that uses XAudio. We discovered a discrepancy between FAudio and XAudio, although I am not sure whether the game is actually following the XAudio specification.

The game uses a dedicated mixer with the VolumeMeter effect attached to measure volume levels. This mixer is completely separate from the main mixer(s) used for playing sound effects. Certain sounds (mainly voice lines) are passed to one of the main mixers as well as this dedicated mixer for volume measurement.

Naturally, this results in the sound to be played twice as loud, since you are feeding it to two mixers in parallel. Setting the volume to 0 for the VolumeMeter mixer does not work as volume levels are calculated after the volume setting of the mixer is applied.

The workaround of the original developers was to initialize this dedicated mixer with an empty send list. Adapted, the code looks like this:

FAudioVoiceSends sendList;
sendList.pSends = NULL;
sendList.SendCount = 0;
FAudio_CreateSubmixVoice(m_pXAudio2, ppDestMixerVoice, m_uiOutputDeviceAudioChannels, m_uiOutputDeviceSampleRate, 0, 0, &sendList, &chain);

Apparently this works in XAudio, having the desired effect of being able to measure volume levels without having the mixer actually outputting sound. In FAudio, due to the empty send list, the process function of the VolumeMeter effect is never executed.

@flibitijibibo
Copy link
Member

Interesting, this probably means you just have to move the SendCount check to below XAPO processing. The only other place I can think of where this might matter is SetEffectChain which might use SendCount for the final output format, but I'd have to double check. Try moving the SendCount checks in MixSource/MixSubmix and see if that's enough to fix it.

@W4RH4WK
Copy link
Contributor Author

W4RH4WK commented Mar 12, 2021

I just moved the SendCount checks down, and it resolves my issue. So far sound is still working. However, I can't say whether this breaks anything else. The PR is up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants