hrydgard / ppsspp

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us on Discord at https://discord.gg/5NJB6dD or just send pull requests / issues. For discussion use the forums at forums.ppsspp.org.
https://www.ppsspp.org
Other
11.23k stars 2.17k forks source link

Audio Popping or Craking in multiple games (Motorola G31) #16745

Open Ralulol opened 1 year ago

Ralulol commented 1 year ago

Game or games this happens in

ULUS-10482 Lunar - Silver Star Harmony, UCUS-98700 Jeanne d'Arc, NPUG-80403 Patchwork Heroes and others

What area of the game / PPSSPP

The popping sound appears randomly in many different games. I was starting jean d' Arc when i first nottice it, the audio has a popping sound, very minor but sometimes very annoying, it happened all across the first cinematic. they don't seem to have a pattern, but in some parts of the game, like the title screen and a lot of the gameplay, the audio is smooth and just functions fine.

I have tried changing the audio settings to fix it whit no result, i also tried changing the grafic settings to get the most satable 60 FPS possible but that didn't work either.

I stumbled across Issue #12705 that seem to have the same problem as me but in a different platform, but it appears to be resolved. the game they use to reliably reproduce the popping is Lunar Silver Star Harmony, inside the title screen after the intro, it just pops like no tomorrow.

I notice using the dev menu and activating the audio buffer that the poping sounds coincide whit the underrun value going up 1 to 1. this is the screenshot of the audio buffer.

WhatsApp Image 2023-01-06 at 9 10 50 PM

This problem happens in every version i have tried, in 1.12.2 1.13.2 and th last as this post is made. Something to point out is the oldest versions have the least amount of underruns in average running the same scenes

I have noticed that in a PC running windows 11 this doesn't happens (or maybe just my pc but i cant be sure).

I also have noticed thet seems to happen more during cutscenes than over gamplay, and in other games like Fat princess fistfull of cake it seems to not happen at all.

What should happen

the audio should not have any popping sounds.

Logs

No response

Platform

Android

Mobile phone model or graphics card

Motorola G 31

PPSSPP version affected

v1.14.4-100-g4cc473160

Last working version

No response

Graphics backend (3D API)

Vulkan

Checklist

hrydgard commented 1 year ago

Got a report of this on Discord, happening on Realme GT Master. https://www.gsmarena.com/realme_gt_master-11001.php

Apparently it has quite a short optimal audio buffer size (144 samples), though it's not the shortest known, so might not be related.

I'll probably need to get my hands on a device with a known problem.. Of these, Moto G31 is the cheapest by far. I've ordered one, let's see.

In the debug screen there, the "effective input rate" sure looks suspicious...

hrydgard commented 1 year ago

Shipment of the phone is delayed for some reason. Bumping to v1.15.2.

unknownbrackets commented 1 year ago

Does enabling auto frameskip help this? Outside the small buffer, I will say the input rate seems close to the % speed indicated. Maybe this is a device that doesn't actually go above 59 FPS or something?

-[Unknown]

Ralulol commented 1 year ago

Hi, I am very sorry for the very late response. First of all, I want to adress the great support you and all of the people willing to help are putting in this community and in the improvement of PPSSPP and game preservation.

The first point to adress is that, whit auto frameskipping on, the problem dissapears completly, there is just no more popping during gameplay or cutscenes in the three games mention and other games that i have played. Thanks to -[Unknown] for pointing this out.

Second of all, the motorola G31 has suffered terrible performance issues since the Android 12 update has been introduced, half of the games that used to run smoothly now stutter a lot, but the issue of popping whitout autoframskipping remains whitout little or no changes, some times the audio cracks when the game is loading or lagging but the issue of just randomly popping.

Apart from that, i have also notice that in the games the audio pops, it only happens at parts in the game that are not cap at a frame rate lower than 60 fps. For example, in UCUS-98700 Jeanne d'Arc in the main menu, when normally the game is at /30 fps the issue does not appear, but in the intro cinematic after starting a new game, running at /60 fps it does pops. Also the popping apears when running cheats that allows the fps cap parts to run at 60 fps.

That is all i hace notice, i hope it helps to improve the app. Thank you.

unknownbrackets commented 1 year ago

Unfortunately, this probably means that your device (possibly only as of Android 12, which would be terrible) can't actually run at 59.94 FPS and has a slower screen. For example, I used to use a Nexus 5 which was great in many ways. But for some reason the firmware would only allow the screen to run at 58 FPS. Because of this, I had the same problem as you describe - I had to use frameskip for anything above 40 FPS or it wouldn't run smoothly.

If your device can't actually display 60 frames, then you have two options basically:

Modern games are often written to have dynamic FPS, meaning a modern game can just render 59 frames each second and they're evenly spaced without skipping anything. Unfortunately, PSP games were pretty specifically written around their FPS, with AI, animations, game logic, all kinds of things tied to running at 60 (or 30) FPS. They just weren't coded the modern way.

Because of that and how bad it "feels" to play at 59+1 skipped, PPSSPP doesn't even have an option implemented to do it currently. Auto frameskip will just take you down to the next even multiple.

-[Unknown]

hrydgard commented 1 year ago

Well, we actually have one more option, which we don't currently support - slow down emulation by a factor of 59/60, and let our audio resampler handle the discrepancy. This does mean that emulation will run slightly slower and will slowly go out of sync with the realtime clock etc, but most games won't notice.

Adding an option for this might happen as part of later work on #17685 , although not sure it's a great idea.

I have one of these devices now, so I'll be able to test various solutions.

unknownbrackets commented 1 year ago

Ah, right, yes. Like how some poor PAL 50 Hz ports were done... well, at 59 Hz it's probably not that bad. Real clock and game clock would skew by a minute every hour which might be the most noticeable impact for some people.

-[Unknown]

hrydgard commented 1 year ago

Hm, I can reproduce this on the Motorola G31. However the phone itself seems to report 60hz in sysinfo, although framerate hovers around 59 even in simple stuff like Webfest.

For whatever reason our audio resampler seems to not to adjust properly to the situation, it always eats a little more samples than it produces and the pitch shift doesn't compensate correctly. Weird stuff..

hrydgard commented 9 months ago

Weirdly, I don't seem to be able to repro this on my G31 anymore. Not sure what to do here - maybe PPSSPP changed, or it got updated and I didn't notice.