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.17k stars 2.17k forks source link

Delay with playing atrac3plus radiostations in GTA Liberty City Stories & GTA Vice City Stories #2075

Closed majesticR3 closed 10 years ago

majesticR3 commented 11 years ago

if atrac3+ audio file have longer duration then it starts to play with delay about 1-5 secs, and FPS reduced at that delay time.

Sorry for horrible English

Squall-Leonhart commented 11 years ago

Expand on the scenario where you see this occuring

dbz400 commented 11 years ago

Still happening in latest git build ?

majesticR3 commented 11 years ago

Squall-Leonhart

This problem exists in GTA Liberty City Stories and GTA Vice City Stories. Delay occurs when game trying to load radio stations which in atrac3plus format. Cutscene audio starts to play without delay. I think delay occurs when atrac3plus library trying to decode long duration audio files (all radios duration are about 30-40 min of music) and that takes a time and processor resources and causes lowering game FPS

raven02

Yeah. :(

Squall-Leonhart commented 11 years ago

I'm not sure if you recall, but the console and PC versions both had the same problem.

majesticR3 commented 11 years ago

Original PSP has maximum 1 sec delay before radio starts to play, but emulator has about 4-7 secs. PS2 version of GTA on PCSX2 don't have that problem - youtube videos proove that

hrydgard commented 11 years ago

It's definitely an issue, really not sure about the cause though.

Squall-Leonhart commented 11 years ago

is ppsspp doing a full seek of the file prior to playing or just playing as streamed through the decoder?

oioitff commented 11 years ago

@majesticR3 Could you show a detail logs? Thanks. The decoding step for atrac3plus is just on the fly, so it means following codes takes about 4-7 secs:

atrac->data_buf = new u8[atrac->first.filesize];
Memory::Memcpy(atrac->data_buf, buffer, std::min(bufferSize, atrac->first.filesize));

That's really crazy and unbelievable!

EZtouch commented 11 years ago

If it takes time to decode the at3+ audios , can we add an option under audio to decode the whole at3+ files from a selected game and save it in ppsspp directory so next time it will play instantly without the need to be decoded? There is a way to decode and batch at3+ for jpcsp, it loads the already decoded audio files from a folder not the game cant we do this?

*** :: Method A :: JPCSP Connector *** supported formats = Atrac3, Atrac3+, pmf

  1. A Real PSP [Required] ATRAC3 audio is saved under tmp \ATRAC To decode the audio, copy the files to your REAL PSP memcard under ms0/tmp and run JPCSPConnector on your REAL PSP then follow the onscreen instructions. After decoding on the PSP, move the files back to Jpcsp under" tmp\ATRAC" you can delete the files on the PSP. JPCSP Connector can be found under ms0\PSP \GAME\JpcspConnector\ in the Jpcsp Release.
oioitff commented 11 years ago

@EZtouch Actually the decoding step for atrac3plus only take little time, because it just need to decode current frame ( less than 1Kb ). It might be ever faster than load wav files from disk.

hrydgard commented 11 years ago

Yes, it's fast, exporting to wav files is useless.

This sound delay must have another cause - if those two lines really took 5s, then the game would be completely frozen for those 5s, it wouldn't just slow down, like @majesticR3 describes it.

EZtouch commented 11 years ago

Maybe it has something to do with #2104 ?

majesticR3 commented 11 years ago

Log from Liberty City Stories: lcs_vcs

Log from Vice City Stories: lcs_vcs2

unknownbrackets commented 11 years ago

Could easily be some syscall not rescheduling when it should or something.

-[Unknown]

oioitff commented 11 years ago

Hmm, probably sceAtracAddStreamData needs hleDelayResult.

majesticR3 commented 11 years ago

I think I know why that delay appears.

As we know, GTA have timer for all radiostations and when we switch radiostations music starts to play not from start position, but from position according to that timer

After few experiments I noticed what time of delay depends of current position in atrac3plus file from which game starts to play music - if that position is near of beginning of atrac3plus file - delay is very small, if position is near of end of file - delay is very big, because atrac3plus library needs to skip many samples from beginning of file to reach position according to timer.

Sorry for my English :)

hrydgard commented 11 years ago

@majesticR3 , good thinking! I think that's the best theory yet - that would mean that ResetPlayPosition might be a bit off, or something.

majesticR3 commented 11 years ago

Probably this is more global issue, and solving it take effect in other games with similar problem It is hard to fix this?

Squall-Leonhart commented 11 years ago

im sorry, but it is absolutely imposible to measure 0.1 seconds of latency.

even the most sensitive of people cannot feel the delay till about 0.7s

hrydgard commented 11 years ago

That's absolutely not true (talking general audio latency). If I connect a MIDI keyboard to my PC and use it play a softsynth, and have a draggable latency setting (like in Propellerheads Reason), I can feel latency down to 10ms.

Of course, hearing exactly when a background music radio station starts in GTA is another thing entirely, and it doesn't really matter. But in Patapon where the Atrac music is integrated to other rhythmic audio events, it's really easy to hear when it's wrong if you've heard how it's supposed to sound when it's right before. So I believe him.

majesticR3 commented 11 years ago

It is possible to fix current issue? This delay is still exists.

majesticR3 commented 10 years ago

With new atrac3+ codec radio stations starts to play immediately without delay as meant to be (I tested GTA Liberty City Stories) but there are rare random short-term FPS slowdowns when I switch radio stations. Anyway thanks for developers for their awesome work :-)