sahlberg / pop-fe

Python script to automate the process of fetching boxart and installing PS1 games (onto your PSP/VITA/PS2/PS3)
135 stars 13 forks source link

V-Rally 2 music cuts off. #59

Closed Webardo closed 8 months ago

Webardo commented 8 months ago

Hello, everything good?

So, the problem is that after a track finishes playing, instead of starting the next one, it just plays the last second of the previous track, followed by silence.

This issue may be caused by Atracdenc, because when merging the tracks and converting the game with PSX2PSP along with CDDA enabler this problem doesn't happen. I just wanted to ask if this could be fixed or if it's out of your reach.

sahlberg commented 8 months ago

That sounds really odd. I am not sure if it is atracdenc related, atracdenc does not know the concept of multiple songs and I invoke it separately one track at a time.

Might be something odd with how it extracts the tracks. Let me have a look tomorrow and see if I can reproduce. Which disc-id did you test and see this issue with?

Webardo commented 8 months ago

It was SLUS-01003. You can test it quickly by just waiting for about a minute in-race.

Thank you for your attention!

sahlberg commented 8 months ago

I can reproduce. As far as I can tell, there is nothing wrong with the audio files. They are all ripped to WAV files correctly and they are all converted correctly to Atrac3.

During the race it plays track 2 and after it fades out in the end it just stops and does not continue to play track3. I tested on PS3 and there when track2 ends then it goes on to play track3 automatically. But PS3 is a different implementation so ...

I think the issue is how the game handles audio tracks. And perhaps the difference between how the two different audio playes deal with when a track ends. My thinking is that the game just tells the (emulated) CDROM drive to "start play track2" and on real cdrom drive, and also the emulated cdrom drive for cdda tracks, once a track ends, a cdrom will automatically start playing the next track automatically until you reach the end of the disc. And the game depends on this behavior "Tell the cdrom to start play this track and it will automatically play the next track and the next" but on PSP with the ATRAC3 handling I think that is not longer the case and when the track ends the audio ends as well unless the game explicitely tells it "play the next track".

I will try to build a test version of this game with the CDDA tracks embedded but NO ATRAC3 audio. And see if that works.

Webardo commented 8 months ago

Hm, what you say makes sense. Perhaps the PSP handles Atrac3 in more of an external way rather than just emulating the proper CD behaviour.

Using the CDDA tracks without the ATRAC3 format does work on PSP properly, although with the use of the CDDA_Enabler plugin. For PS Vita I got no clue at all.

sahlberg commented 8 months ago

Tested it on PSP without ATRAC3 audio but with the CDDA tracks intact and then it does automatically go on an start the next track automatically. But I also get a very annoying background noice when the music plays. That noice is why I originally added the "truncate the BIN to only contain the data track in the first place:-)

But yeah, for this game, creating an EBOOT that contains all the CDDA track DOES make it play all the tracks automatically but at the cost of the annoying noice.

What I can do is add a checkbox to pop-fe-psp to "Use CDDA instead of ATRAC3" where users can select this mode on a case by case basis. I can also flag this game in the database to select this automatically when generating a PSP EBOOT for this game.

sahlberg commented 8 months ago

Hm, what you say makes sense. Perhaps the PSP handles Atrac3 in more of an external way rather than just emulating the proper CD behaviour.

Using the CDDA tracks without the ATRAC3 format does work on PSP properly, although with the use of the CDDA_Enabler plugin. For PS Vita I got no clue at all.

What is that plugin ? (I don't know very much about PSP) And will it fix the very annoying noice that the PSP does when playing CDDA audio?

Webardo commented 8 months ago

I take it you're using a Vita then? This plugin allows the PSP to play CDDA tracks on PS1 games. Sony disabled official support for CDDA after firmware 4.01, so this was the only way to restore it without using Popsloader to select 4.01 and below. Adrenaline on Vita has its own type of CDDA code, so there's no need for external plugins.

Do you want me to provide my eboot? I didn't have any noise with it. I made it using BinMerger and PSX2PSP, which I believe had its repository deleted, so feel free to download it from here:

V-Rally 2 eboot: https://www.mediafire.com/file/9vvppo6tqi8fs8d/SLUS01003.zip/file

BinMerger: https://www.mediafire.com/file/n1ehlr14b27shg7/BinMerger-windows-static-x64.rar/file

I believe the best of both solutions is to automatically flag this game, but still having the tick for either ATRAC3 or original CDDA.

sahlberg commented 8 months ago

I am on PSP but I don't recall adding any other plugins than the ones for the SD card adapter. But it was a long time ago so maybe I did. I mostly play PS1 games on PS3 though so ...

Thanks for the link. I will test that EBOOT and see. Maybe I am doing something wrong when creating the EBOOT and that causes it.

sahlberg commented 8 months ago

I think that too has some background noise. Maybe I am just imagining things. I have added ways to switch from atrac3 to cdda though. It does not make sense to have both on psp as it for mysterious reasons it seems it will try to play BOTH at the same time and things get even worse :-)

Webardo commented 8 months ago

I'm really grateful for this! I'll test it and comment if I have any issue. :)

Webardo commented 8 months ago

By noise, did you mean a constant buzz?

sahlberg commented 8 months ago

yeah, a constant buzz, well not constant it seems to come and go, sometimes it is there and sometimes it is not. Do you hear it too?

Webardo commented 8 months ago

I can hear it now, but just after converting the game with the latest build.

sahlberg commented 8 months ago

Ok, and it is not there, or not as pronounced in the eboot you sent me? (My hearing was never really all that great and nowadays it is worse) I can try to compare the two eboots and see if I can detect any differences.

Webardo commented 8 months ago

It is not there in the eboot I sent you. I believe the buzz comes mainly from the left speaker, that way you can notice it more easily.

The music not playing after finishing did get fixed however, so that's still one less issue :).

sahlberg commented 8 months ago

Ok. I will need to try to figure out what goes wrong here. The odd thing is that the exact same EBOOT (but with different compression settings) do play CDDA perfectly on PS3. So will start by looking at all the other metadata that differs between your EBOOT andthe one I generate first.

Webardo commented 8 months ago

Ain't that a lot of work? I'll let you know that I used level 1 compression on PSX2PSP, just in case.

Goatman13 commented 8 months ago

Not sure if that's issue here but track 2 is always not aligned to 4 bytes in eboot. For every single game with aea tracks, here is V Rally 2:

77 FA 12 10 00 8C 16 00 00 00 00 00 00 00 00 00
80 86 29 10 00 9C 3C 00 00 00 00 00 00 00 00 00
80 22 66 10 00 F4 2F 00 00 00 00 00 00 00 00 00
80 16 96 10 00 D2 3C 00 00 00 00 00 00 00 00 00
80 E8 D2 10 00 5C 52 00 00 00 00 00 00 00 00 00
80 44 25 11 00 60 51 00 00 00 00 00 00 00 00 00
80 A4 76 11 00 B0 2E 00 00 00 00 00 00 00 00 00

Btw. cdda enabler just force end MM:SS:FF to 80:00:00 (bcd) as far as i know, is not needed with pop-fe and can even break some games.

sahlberg commented 8 months ago

Can you expand on that? binmerge that I use to merge it into a single bin should just be concatenating the files together and as track 1 has a size of 458597664 and that is a multiple of 4, so track 2 shhould be 4 byte aligned?

Can you explain in more details what you mean?

Goatman13 commented 8 months ago

Sorry, i wasn't clear enough here. I mean aea file offset for track 2 in iso header, in audio tracks table ("PSISOIMG0000" + 0x0C00). Not sure if file is really on offset 0x1012FA77 or just pointer is wrong, but i think that can be issue for some emulators.

sahlberg commented 8 months ago

Ah, ok. I don't think that is the problem here. The problem is when we create a EBOOT without any AEA files and instead use the raw CDDA tracks that are part of the disk image.

Still, I can add padding to 32bit align the start of every AEA file that is injected. that would not hurt but it is not the issue we have with V-Rally.

Please open an issue to "add padding to make injected AEA files 32-bit aligned" and I will add that when I time.

Goatman13 commented 8 months ago

I think that can be issue with V-Rally 2 because it's failing to play track 3. Which can be caused by emulator expecting tracks offset to be aligned, and due to that never reaching track 3 or expected track 2 end.

Just in case i mean original issue from first post about Atrac tracks stop playing after track 2, not that buzzing sound issue.

sahlberg commented 8 months ago

ok, I will try that.

Goatman13 commented 8 months ago

Just in case i made some calculations and on V Rally 2 example:

Audio track 3 offset - audio track 2 size (0x10662280 - 0x3C9C00) = audio track 2 start offset (0x10298680) Audio track 2 offset - audio track 1 size (0x10298680 - 0x168C00) ≠ audio track 1 start offset (correct result 0x1012FA80 while offset where pop-fe put it is 0x1012FA77)

And from the other side, audio track 1 is located at 0x1012FA77 by pop-fe, size is reported as 0x168C00. This makes end of track at 0x10298677, next audio track is at 0x10298680. Emulator most likely expect them to be one after another for continuous playback.

This bug seems to affect only audio track 1. Two options from here. Align first offset where file is placed ((offset + 0x0F) & 0xFFFFFFF0), or place file one after another. First option is most likely more compatible for architectures like PPC/MIPS. On side note. I'm not 100% sure if that will resolve issue, but it's something that probably should be fixed anyway.

sahlberg commented 8 months ago

I see what you mean. Since the first track is not correctly aligned there will be a gap between it and the next trac so when playing the track, it reaches the gap and as the next data/gap/ is not a valid ATRAC3 frame it stops playing.

I have fixed the alignment for track one and there is no longer a gap. Sadly it did not fix the issue:-( It still stops playing after the first track ends.

Something strange though is that the very end of playing the first track, the very last second it plays seems to be a repetition of earlier audio from the song. This is not present in the WAV file/bin file nor in the ATRAC3 file before it is injected. (CTRL-C when creating the EBOOT and the files will be in pop-fe-work/ directory)

sahlberg commented 8 months ago

Ok, Thanks for the example good EBOOT I could compare with.

I have updated master and this should be good now. At least as far as I can tell the audio is good now. The issue seems to be the "file type?" field in the disk map table (https://www.psdevwiki.com/psp/PSISOIMG0000)

The difference was that in your good EBOOT the "file type?" is always 0, eventhough the psdevwiki suggests 1. I had it set to 1 in my bad EBOOT. I have now changed it to always set it to 0 when creating compressed PSP eboots but still leave it as 1 when creating uncompressed eboots for PS3.

This is great. Someone want to update the wiki and flag that this should be set to 0 for compressed psp blocks?

I wonder what this flag actually does. It can't really affect how it decompresses the data because if it did then the data track would no longer have running code. Maybe it is a flag that is only used when trying to read a cdda track?

Webardo commented 8 months ago

Indeed, it's all good now. :)

About the "file type?" flag, maybe it marks the difference between raw CDDA and ATRAC3?

sahlberg commented 8 months ago

Closing as this seems all resolved now. I tried to edit the wiki but it just gave some errors. If someone else can add a comment there about file type would be awesome.

Webardo commented 8 months ago

You mean this excerpt in the wiki? "File_type needs to be 0 for compressed blocks on PSP or else it will create an audible buzz when playing the CDDA tracks.".

Looks like it got properly edited already.

sahlberg commented 8 months ago

Oh, ok, it errored out when I tried to add it so I thought it was lost. Ok, all is good then. Thanks

Webardo commented 8 months ago

All thanks to you pal. ;)