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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

mcpx: Mitigate ADPCM audio crackling #1616

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kumpulak
Copy link

@kumpulak kumpulak commented Mar 23, 2024

Adds a workaround for audio crackling that frequently occurs when non-streaming ADPCM voices are requested to be deactivated before finishing using NV1BA0_PIO_VOICE_OFF. Fixes the issue #339 most likely similar issues with other games too.

I noticed the NV1BA0_PIO_VOICE_OFF arrives to the vp_write callback after something has already written garbage data to the voice processor memory region. At that point it would not be possible to retroactively clear the output buffers, since the voices have already been mixed together. So I created a workaround which detects this garbage data before it is decoded and written to sample buffers.

This will have a very minimal performance impact (could not notice at all when profiling). It is however a hack around a root issue I do not have the expertise to debug. In ideal scenario the NV1BA0_PIO_VOICE_OFF would arrive in time before the memory contains this garbage data.

I tested the fix with USA version of standalone Jet Set Radio Future, where both mono and stereo ADPCM voices exhibited this issue. Now both are fixed and there are no other downsides that I could find. I can't come up with a scenario where a valid ADPCM header would contain all identical non-zero values and still represent audio someone wants to hear 馃檪

I tested the code on Ubuntu 22.04 (x86), Windows 11 (x86) and M1 Mac (arm64), identical behavior on those platforms.

@MasonT8198
Copy link
Contributor

The logic/code seem sound to me, I can't think of any case where it would end up muting any audio that would be intended to be heard by the player...

Although as another test case I'd be interested to see if it also applies to https://youtu.be/t08VA1_sflM?t=27 which affects for PGR1/2 on multi car collision.

@kumpulak
Copy link
Author

The logic/code seem sound to me, I can't think of any case where it would end up muting any audio that would be intended to be heard by the player...

Although as another test case I'd be interested to see if it also applies to https://youtu.be/t08VA1_sflM?t=27 which affects for PGR1/2 on multi car collision.

The RalliSport Challenge seems to use normal PCM instead of ADPCM for the engine sounds/other effects so this doesn't fix anything there. I took a quick look and it seems all of the different engine sounds are playing at the same time, no wonder it sounds horrible when they are mixed together 馃槄. Maybe the developers were misusing the APU hardware in a way that is not currently supported.

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

Successfully merging this pull request may close these issues.

None yet

2 participants