libretro / RetroArch

Cross-platform, sophisticated frontend for the libretro API. Licensed GPLv3.
http://www.libretro.com
GNU General Public License v3.0
10.15k stars 1.82k forks source link

[Bounty Feature Request] Fix audio crackling during fast forward #15160

Closed hilltop804 closed 1 year ago

hilltop804 commented 1 year ago

Request Outline

When using fast forward in RA, the audio becomes a crackly mess regardless of speed or hardware. I'm requesting a fix that would at least allow games to be played between 1-2x speed on modest hardware (Steam Deck) without crackling audio. This is possible on other standalone emulators, so I think it should be possible within RA.

Guidelines

hilltop804 commented 1 year ago

https://app.bountysource.com/issues/118858006-bounty-feature-request-fix-audio-crackling-during-fast-forward

felipetavares commented 1 year ago

@hilltop804 can you give me a concrete example of what you are trying to play?

hizzlekizzle commented 1 year ago

a lot of people run pokemon games at 2x+ speed because it's just so slow, in general.

hilltop804 commented 1 year ago

@felipetavares - Mostly retro RPGs: Golden Sun on GBA, Pokémon on GBA, Chrono Trigger on SNES, Shining Force II on Genesis.

felipetavares commented 1 year ago

@hilltop804 are you able to test the fix?

EDIT: I tested chrono trigger and metroid with the bsnes core, but my machine is pretty powerful.

hilltop804 commented 1 year ago

@felipetavares Thanks for working on this! I tested the changes across a bunch of different systems and games, and they work very well overall. But, they do cause an intermittent force close upon activating fast-forward.

I tried logging, and it comes through as 'segmentation error: core dumped. It seems related to activating fast-forward immediately after a big screen or area transition. The most reliable way I've found to replicate is Sonic 3. Load into the first stage, beat the bonus stage near the entrance to get the chaos emerald, and activate FF as soon as you drop back into the primary game world. It will force close 100% of the time. (You can play on normal speed up to that point. It seems to be the actual triggering of FF that causes the crash).

I've experienced this crash on all games and systems tested, and confirmed I could not replicate on the main branch. Since your fix is using an average, I wonder if certain transitions or events in-game reset the info being averaged which results in an insufficient look-back period (just a guess).

felipetavares commented 1 year ago

@hilltop804 There's one uninitialized variable in my current patch, the crashes might be related. Do you know if it happens the first time you try enabling fast-forward in the run or can you get it to work a few times before the crash?

hilltop804 commented 1 year ago

@felipetavares It's not related to the first activation. In my Sonic 3 example - I usually FF to the special stage, complete it at normal speed, and crash upon activating again after the stage transition.

felipetavares commented 1 year ago

@hilltop804 Added another small patch to my PR, can you check if it makes any difference?

hilltop804 commented 1 year ago

@felipetavares I did some more testing with the updated PR and haven't encountered any additional bugs. I think this might be it!

pressRtowin commented 1 year ago

I experience heavy crackling while using fast forward in every just about every core on Android (Fold4). Is this related?

hilltop804 commented 1 year ago

I experience heavy crackling while using fast forward in every just about every core on Android (Fold4). Is this related?

Are you using the setting added in the related PR? Without that, the audio is basically guaranteed to be a mess when using FF. Also, just as a heads-up, the stable release hasn't been updated with this patch yet. You have to install the nightly version to get it.

pressRtowin commented 1 year ago

the stable release hasn't been updated with this patch yet.

That was it. Didn't realize it was only in nightly. I just installed it to try it out and while the audio issue is resolved, unfortunately the current nightly is unusable for me because for whatever reason, the viewport behavior was changed since the stable and now the viewport is centered vertically on the display if using integer scaling with a core-provided aspect ratio and there doesn't seem to be any option to change it back to the current behavior of aligning to the top of the display (so that there's actually room for on-screen controls).