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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quake 2 by CROW_BAR: distorted music issues #6842

Closed
pal1000 opened this issue Sep 5, 2014 · 23 comments · Fixed by #12121
Closed

Quake 2 by CROW_BAR: distorted music issues #6842

pal1000 opened this issue Sep 5, 2014 · 23 comments · Fixed by #12121
Labels
MP3 Issue involves sceMp3 features.
Milestone

Comments

@pal1000
Copy link
Contributor

pal1000 commented Sep 5, 2014

1. Lag / long start-up problem
The lag problem is completely gone. Tested v1.8.0-132-g c82d75c
2. Music distortion
There is a music playback issue as well. It is distorted so badly that it doesn't worth adding the music files. According to the log it keeps attempting to resample the music tracks to 44100Hz although I have the music in that sample rate.

Video showing both issues:
https://www.youtube.com/watch?v=me868bf5mHk
i got the second demo to load right at the video start.
Log screenshot showing music resampling attempts:
quake2

@thedax
Copy link
Collaborator

thedax commented Sep 5, 2014

Try turning off the God of War hack under the graphics settings. It hurts this homebrew pretty badly, with regards to the "lag" (it's actually pausing for a bit then resuming over and over, at least on my PC).

@pal1000
Copy link
Contributor Author

pal1000 commented Sep 5, 2014

Yeah it helps a bit but the random lag can still vary from almost nothing to unplayable. Solves the glitches when using frameskip as seen in the video.

@unknownbrackets
Copy link
Collaborator

Interesting. If that hack hurts it, it must be flipping the buffer a ton during this time. I wonder why.

-[Unknown]

@thedax
Copy link
Collaborator

thedax commented Sep 8, 2014

I/O on thread has something to do with it too it feels like. If i turn it off, on some boots of the homebrew, it runs almost perfectly. On others, I experience the stuttering. Perhaps this port is extremely timing sensitive or something?

@pal1000
Copy link
Contributor Author

pal1000 commented Sep 9, 2014

I noticed that in order to maximize the chances to run smooth it is required to turn off the followings:
-God Of War hack;
-I/O on thread
And also enable real clock sync.
If I do all these tweaks simultaneously I get playable timing most of the time the game starts with the main demo. If it plays other demos that require minutes long loading it won't work. The lag would be too severe.

@pal1000
Copy link
Contributor Author

pal1000 commented Sep 10, 2014

Same problems in D3D. Tested v0.9.9.1-311-g 6fa1872.

@pal1000
Copy link
Contributor Author

pal1000 commented Sep 25, 2014

It also suffers from buffer overflow during loading sequences. This might be a cause for unexpected pauses.
menu_00002

@pal1000
Copy link
Contributor Author

pal1000 commented Nov 13, 2014

Uploaded a video with debug statistics: https://www.youtube.com/watch?v=ERzSpzU2f6c
Disabling JIT makes no difference.
Also switching to software renderer doesn't seam to help either.
However running the honebrew at such low speeds via interpreter or software renderer revealed something interesting in debug statistics, the more often SceGeListUpdateStallAddr is called, the lower the lag is going to be. Also, only in software renderer the debug statics text does not freeze along with the game, easy noticeable via frames counter. Debug statics text stalls along with the game in any other mode (hardware renderer with or without JIT).
Screenshot:
menu_00002

@pal1000
Copy link
Contributor Author

pal1000 commented Nov 13, 2014

When lagging occurs the following slowest syscalls get called more often:
menu_00003
menu_00002

@pal1000
Copy link
Contributor Author

pal1000 commented Nov 13, 2014

When lag is almost nonexistent the slowest and most active syscall tend to be:
menu_00002
most of the time.

@LunaMoo
Copy link
Collaborator

LunaMoo commented May 24, 2017

Blah, didn't noticed that earlier, but that's probably another homebrew using same time functions, so at least half of this issue(lag part) should be fixed by #9716.
Can't find a working download to even test this:].

Edit: Found the homebrew, but it currently doesn't work at all due to lack of memory which I mentioned in #8925 (comment), meaning memsize flag is not respected. Sound in the intro worked fine at least.:]

~
Forced ppsspp to gave double ram to run it and indeed there's no lag anymore:], music is still broken, by constantly looping the start, so it ends up as a noise:

54:30:364 mp3decode_th I[ME]: HLE\sceMp3.cpp:461 sceMp3ReleaseMp3Handle(0BFCEE74)
54:30:365 user_main    I[SCEIO]: HLE\sceIo.cpp:1018 stdout: mp3_start_play(./MP3/Track10.mp3) @ 0
54:30:365 user_main    I[SCEIO]: HLE\sceIo.cpp:1018 stdout: seek 0: 0/1953540
54:30:365 mp3decode_th I[ME]: HLE\sceMp3.cpp:182 sceMp3ReserveMp3Handle(0bfcee74)
54:30:366 user_main    I[SCEIO]: HLE\sceIo.cpp:1018 stdout: Playing ./MP3/Track10.mp3
54:30:366 mp3decode_th I[ME]: HLE\sceMp3.cpp:314 sceMp3Init(0bfcee74)
54:30:366 mp3decode_th I[ME]: HLE\sceMp3.cpp:332 sceMp3Init(): channels=2, samplerate=44100Hz, bitrate=128kbps
54:30:366 mp3decode_th I[ME]: HLE\sceMp3.cpp:425 sceMp3GetSamplingRate(0BFCEE74)
54:30:366 mp3decode_th I[ME]: HLE\sceMp3.cpp:401 sceMp3GetMp3ChannelNum(0BFCEE74)
54:30:366 mp3decode_th I[ME]: HLE\sceMp3.cpp:389 sceMp3SetLoopNum(0BFCEE74, 0)
54:31:945 mp3decode_th I[SCEIO]: HLE\sceIo.cpp:1018 stdout: mp3_end_play
54:31:945 mp3decode_th I[SCEIO]: HLE\sceIo.cpp:1018 stdout: Clear res
54:31:945 mp3decode_th I[ME]: HLE\sceMp3.cpp:461 sceMp3ReleaseMp3Handle(0BFCEE74)
54:31:951 user_main    I[SCEIO]: HLE\sceIo.cpp:1018 stdout: mp3_start_play(./MP3/Track10.mp3) @ 0
54:31:952 user_main    I[SCEIO]: HLE\sceIo.cpp:1018 stdout: seek 0: 0/1953540
54:31:952 mp3decode_th I[ME]: HLE\sceMp3.cpp:182 sceMp3ReserveMp3Handle(0bfcee74)
54:31:952 user_main    I[SCEIO]: HLE\sceIo.cpp:1018 stdout: Playing ./MP3/Track10.mp3
54:31:952 mp3decode_th I[ME]: HLE\sceMp3.cpp:314 sceMp3Init(0bfcee74)
54:31:952 mp3decode_th I[ME]: HLE\sceMp3.cpp:332 sceMp3Init(): channels=2, samplerate=44100Hz, bitrate=128kbps
54:31:952 mp3decode_th I[ME]: HLE\sceMp3.cpp:425 sceMp3GetSamplingRate(0BFCEE74)
54:31:952 mp3decode_th I[ME]: HLE\sceMp3.cpp:401 sceMp3GetMp3ChannelNum(0BFCEE74)
54:31:952 mp3decode_th I[ME]: HLE\sceMp3.cpp:389 sceMp3SetLoopNum(0BFCEE74, 0)
54:33:690 mp3decode_th I[SCEIO]: HLE\sceIo.cpp:1018 stdout: mp3_end_play
54:33:691 mp3decode_th I[SCEIO]: HLE\sceIo.cpp:1018 stdout: Clear res
54:33:691 mp3decode_th I[ME]: HLE\sceMp3.cpp:461 sceMp3ReleaseMp3Handle(0BFCEE74)

@LunaMoo LunaMoo changed the title Quake 2 by CROW_BAR: Random intensity lag with every start-up and distorted music issues Quake 2 by CROW_BAR: distorted music issues May 24, 2017
@LunaMoo
Copy link
Collaborator

LunaMoo commented May 24, 2017

Updated title to reflect what's left, the game is actually completely broken now, but with #9721 it'll work again and the "lag" was fixed yesterday, quite playable althrough default control mapping feels weird / hard to get used to:P.

@hrydgard
Copy link
Owner

Got any good download links to the port BTW? Would be cool to put on the homebrew store with just the demo levels. Though perhaps it'd be a bit too big.

@LunaMoo
Copy link
Collaborator

LunaMoo commented May 24, 2017

Unfortunately the only download I found myself potentially was a shady one ~ from description of some youtube video;] as while I was copying my own files into it, I had lots of questions to replace existing files, including one big pak file, that matched size from the full game.:]

I could strip it off those things and upload myself, but honestly not sure which files are copyrighted there and which aren't, the copy I got didn't really came with clear instructions:|.

@LunaMoo
Copy link
Collaborator

LunaMoo commented May 24, 2017

Ok I'm uploading it here as a jpg:
q2 psp homebrew
rename to 7z:].
Please remove if you find anything that might be copyrighted, but I think I removed everything I could find in my full game, surely there are no pak files now, hopefully only homebrew files are there.

To note - files which I found in original game and removed from this, starting from those stored in same directory in full game:
QuakeII\baseq2\gamex86.dll
QuakeII\baseq2\maps.lst
QuakeII\baseq2\pak0.pak
QuakeII\baseq2\pak1.pak
QuakeII\baseq2\pak2.pak
whole QuakeII\baseq2\players folder

files inside QuakeII\baseq2\crbot:
pak0.pak (in the full game I found it in Quake II\ctf)
and those which were just copies of QuakeII\baseq2 files:
MAPS.LST
GAMEX86.DLL

Stuff I figured out to do optionally:

  • QuakeII\baseq2\video folder might be copied as well(seems to work),
  • music converted to mp3 named from Track02 to Track21(full game from GOG includes ogg) can be placed into QuakeII\MP3, but it's currently buggy and will just start over a tiny loop resulting in noise:].

This homebrew also seeks more PAK files inside "baseq2", but GOG version of the full game stores everything in separate folders starting from pak0.pak in every of them and I'm not sure which to rename to which if any order is even needed:].

@hrydgard
Copy link
Owner

Alright, cool. Seems a tiny bit scary though. I might have a look when I find some time :)

@LunaMoo
Copy link
Collaborator

LunaMoo commented Apr 25, 2019

Slight update, with #11993 it now spams:

45:50:161 mp3decode_th I[ME]: hle\scemp3.cpp:494 sceMp3SetLoopNum(00000000, 0)
45:50:470 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: Opn: ./baseq2/pak0.pak w_i: 2
45:50:471 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: ICl: ./baseq2/pak0.pak w_i: 2
45:50:566 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: Opn: ./baseq2/pak0.pak w_i: 2
45:50:568 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: ICl: ./baseq2/pak0.pak w_i: 2
45:50:977 mp3decode_th I[SCEIO]: hle\sceio.cpp:1031 stdout: mp3_end_play
45:50:977 mp3decode_th I[SCEIO]: hle\sceio.cpp:1031 stdout: Clear res
45:50:978 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: mp3_start_play(./MP3/Track08.mp3) @ 0
45:50:978 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: seek 0: 0/2981792
45:50:978 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: Playing ./MP3/Track08.mp3
45:50:979 mp3decode_th I[ME]: hle\scemp3.cpp:494 sceMp3SetLoopNum(00000000, 0)
45:50:989 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: Opn: ./baseq2/pak0.pak w_i: 2
45:50:994 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: ICl: ./baseq2/pak0.pak w_i: 2
45:51:782 mp3decode_th I[SCEIO]: hle\sceio.cpp:1031 stdout: mp3_end_play
45:51:782 mp3decode_th I[SCEIO]: hle\sceio.cpp:1031 stdout: Clear res
45:51:795 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: mp3_start_play(./MP3/Track08.mp3) @ 0
45:51:795 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: seek 0: 0/2981792
45:51:795 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: Playing ./MP3/Track08.mp3
45:51:796 mp3decode_th I[ME]: hle\scemp3.cpp:494 sceMp3SetLoopNum(00000000, 0)
45:52:190 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: Opn: ./baseq2/pak0.pak w_i: 2
45:52:194 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: ICl: ./baseq2/pak0.pak w_i: 2
45:52:600 mp3decode_th I[SCEIO]: hle\sceio.cpp:1031 stdout: mp3_end_play
45:52:600 mp3decode_th I[SCEIO]: hle\sceio.cpp:1031 stdout: Clear res
45:52:603 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: mp3_start_play(./MP3/Track08.mp3) @ 0
45:52:604 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: seek 0: 0/2981792
45:52:604 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: Playing ./MP3/Track08.mp3
45:52:604 mp3decode_th I[ME]: hle\scemp3.cpp:494 sceMp3SetLoopNum(00000000, 0)
45:52:792 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: Opn: ./baseq2/pak0.pak w_i: 2
45:52:796 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: ICl: ./baseq2/pak0.pak w_i: 2
45:53:416 mp3decode_th I[SCEIO]: hle\sceio.cpp:1031 stdout: mp3_end_play
45:53:416 mp3decode_th I[SCEIO]: hle\sceio.cpp:1031 stdout: Clear res
45:53:420 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: mp3_start_play(./MP3/Track08.mp3) @ 0
45:53:420 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: seek 0: 0/2981792
45:53:421 user_main    I[SCEIO]: hle\sceio.cpp:1031 stdout: Playing ./MP3/Track08.mp3
45:53:421 mp3decode_th I[ME]: hle\scemp3.cpp:494 sceMp3SetLoopNum(00000000, 0)

Using 44100mhz, 128kbps stereo mp3's(which seems to work best without any warnings), it basically starts playing an mp3 and ends instantly ~ repeats without end.

@LunaMoo LunaMoo added the MP3 Issue involves sceMp3 features. label Apr 25, 2019
@unknownbrackets
Copy link
Collaborator

Does it work in Jpcsp? I took a quick look at its buffer handling to get an idea of what to test, and noticed some areas where it's probably wrong - but in a different way than PPSSPP is wrong.

What PPSSPP does is:

  1. Ask the game to fill the buffer (minus workarea with that pull.)
  2. Once a decode happens, ask the game to provide that additional packet.
  3. Use the MP3 buffer as a place to read into a C++ managed buffer.

What Jpcsp does is:

  1. Ask the game to fill half the buffer minus workarea.
  2. Once a decode happens, ask the game to provide that additional packet (I think, from reading the code briefly.)
  3. Unclear to me where the data is managed.

What PSP does is:

  1. Ask the game to fill the buffer minus workarea.
  2. When a decode happens, don't ask for more data until half the buffer has been used up. Then ask for half.
  3. Manage the data in the MP3 buffer (presumably just swapping halves and using the workarea to stitch together frames that cross boundaries.)

It's possible that Quake is getting confused because it's being asked to provide new data right away, which doesn't happen on a PSP.

-[Unknown]

@LunaMoo
Copy link
Collaborator

LunaMoo commented Apr 25, 2019

Hoped I can live without Java on my pc;p, but heh ok I tried and indeed it works on jpcsp just fine, at least music, it has some other problems.

Edit: I guess JPCSP is not that fine after all, the music works fine in the auto-play demo, but doesn't seem to even start when later entering the game, maybe things break because of it's performance which is very poor, it also has lots of graphical glitches compared to PPSSPP, but we have the music broken same way in auto-play demo and in-game.
Out of curiosity I tested PPSSPP software rendering and there are slight glitches there so I include the dump:
QUAK00649_0001.zip
but it's just an unrelated thing, the game works pretty great with hardware acceleration anyway.(also ignore the red ~ it's just blood, on a side note it's kind of hard to see the blood particles outside of 1x res, they seems to be 1 pixel size ;o)

@LunaMoo
Copy link
Collaborator

LunaMoo commented Apr 25, 2019

I found a demo of Quake II that can reproduce mp3 problem so I'm uploading it here:
Quake 2 demo.zip

Place some mp3's into mp3 folder, they have to be named Track02.mp3 to Track21.mp3(Track02.mp3 should be enough to reproduce the problem). Run the homebrew press start and then X like two times to start a new game. It will spam some content missing making it almost impossible to see in-game the constant spam about re-starting mp3, but it can still be observed in the info log.

@pal1000
Copy link
Contributor Author

pal1000 commented Apr 28, 2019

That demo version crashes almost always when starting game @LunaMoo

@LunaMoo
Copy link
Collaborator

LunaMoo commented Apr 28, 2019

Disable fast memory, it's still useful to reproduce mp3 issue, but I guess the homebrew wasn't really ment for running anything else than full game so it has some problems when using content of the demo.

@unknownbrackets
Copy link
Collaborator

unknownbrackets commented Apr 28, 2019

Changing the ID3 handling helps (I think it may be safe to remove ctx->EatSourceBuff(0x400);), but I think this is actually related to sceAudioSRC*.

Commenting out chans[PSP_AUDIO_CHANNEL_SRC].reset(); (but I don't think it's correct to comment this out, exactly) makes the audio play at the right speed. I suspect that maybe it should actually block the thread until the queue is drained or something.

-[Unknown]

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

Successfully merging a pull request may close this issue.

5 participants