libretro / RetroArch

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

[Feature Request] Generalized "async mix" audio #13039

Open bobbybudnick opened 2 years ago

bobbybudnick commented 2 years ago

Description

I would like to see an "async mix" option for audio like the PCSX2 standalone emulator has. I am aware PCSX2 has made it to Retroarch but have not tried it yet. It would be good to have this feature for Playstation 1 emulation and others also.

Expected behavior

For sound to play at normal speed when fast forwarding.

Actual behavior

Sound plays at a sped up rate when fast forwarding.

Version/Commit

Environment information

hizzlekizzle commented 2 years ago

Most emulators don't have a concept of running the audio at a different speed from the game logic, but if they do (pretty much only going to be optical disc-based systems, I would think), that needs to be added to the core rather than the frontend.

bobbybudnick commented 2 years ago

Reading the music tracks from the CD audio would be a straightforward way to do it but I thought of another way.

Retroarch already supports running a "parallel state" of an emulator for acccuracy reasons but it could be used for sound emulation also. Every few seconds or perhaps milliseconds a "reference" emulator process is "spawned" and sped up similar to the "interactive" process emulator. Sound is recorded from the "reference" process and then slowed and time-matched appropriately to the "interactive" process which otherwise has it's sound muted. This may be similar to how PCSX2 does it because I believe even sound effects are affected.

The idea that this would have to be core specific is very unappealing. In theory an expert programmer could do this in an emulator-agnostic kind of way. It would be hugely performance heavy but computers are getting faster all the time.