Romhacking.net

Romhacking => Newcomer's Board => Topic started by: SorryIKnowNothing on April 24, 2021, 03:27:30 am

Title: PSP audio in .bin format
Post by: SorryIKnowNothing on April 24, 2021, 03:27:30 am
I opened up an iso of the game (Persona 2: Eternal Punishment on the PSP) and found that the voice clips are stored as a file with a .bin extension. (It’s not a disc image.) I used the Nova Extraction Tool to scan the files. Of the 212 files that came up there were 211 wav files and one txt file. The wav files all have headers starting with “RIFF• WAVEfmt 4”. All of the wav files opened up in WavePad but there were large gaps in the audio. I’ve found threads of people having issues extracting audio in a similar way but none of the solutions seem to apply here. Is there any way to extract the files without any gaps in the audio? Additionally, would it be possible to replace them with different audio and put it back into the same format? I’d appreciate any input you could give me.
Title: Re: PSP audio in .bin format
Post by: Jorpho on April 24, 2021, 09:58:21 am
I’ve found threads of people having issues extracting audio in a similar way but none of the solutions seem to apply here.
Maybe you could provide some links to those threads, before people start trying to tell you about inapplicable solutions?

I'm guessing that "one txt file" might provide important information about offsets.

Also, what exactly do you mean by "gaps in the audio" ?
Title: Re: PSP audio in .bin format
Post by: SorryIKnowNothing on April 24, 2021, 12:43:03 pm
Maybe you could provide some links to those threads, before people start trying to tell you about inapplicable solutions?

Here are the threads I found. I managed to convert the files to .aa3 but couldn’t do anything with them.
https://forum.xentax.com/viewtopic.php?t=12840
https://forum.xentax.com/viewtopic.php?t=6273

I'm guessing that "one txt file" might provide important information about offsets.

I opened it in a hex editor and here’s what I got:
                 0    1    2    3    4    5    Dump
00000000 7b  2b  54  41  70  41   {+TApA

Also, what exactly do you mean by "gaps in the audio" ?

All of the audio is present in the file but the waveform has a bunch of silence in the middle. Editing out the silence would produce the original clip. I just don’t want to edit 200 audio files.
Title: Re: PSP audio in .bin format
Post by: FAST6191 on April 24, 2021, 01:35:06 pm
All of the audio is present in the file but the waveform has a bunch of silence in the middle. Editing out the silence would produce the original clip. I just don’t want to edit 200 audio files.
Two choices here, maybe three

1) "Suck it up, buttercup". ROM hacking is not all glamorous sailing in there, realising someone does not know an obscure quirk of the hardware, saving the day and then off to repeat. Many times you are there with repetitive and tedious work that makes you yearn for something as mind expanding as data entry.

2) You got lucky here. Trimming silence from audio is actually a thing people often want to do for various reasons. To that end audacity and probably a few other audio editors will have filters that allow you to do things like "if volume of less than blah dB is more than ? seconds/samples get rid of it". Truncate silence ( https://manual.audacityteam.org/man/truncate_silence.html ) is audacity's.

3) Silence is probably used in the game code for some reason (easier to reach a segment if it is some kind of round number, space in case a line had to be redubbed, easier to grab whole chunks rather than deal with fiddly reads... many options but I don't much care). Anyway somewhere in the game's code will be what it grabs, where and something else too most likely. Find this out and you have the perfect treasure map. If you were editing text this would likely mean you get to figure out the game's pointer system, however as this is audio, seemingly mostly for ripping purposes and you have 1) and 2) then... eh it is a lot of work for little gain.

As far as overwriting or otherwise injecting new content.
You get to figure out the format it uses and recreate it. If it is indeed some basic variation on the theme of PCM-Wave type audio (common enough on game consoles as you don't have to pay patent fees -- https://madfileformatscience.garymcgath.com/2016/04/05/mp3patent/ ) then you might even find audacity spits out a nice raw file you could overwrite something with if you coax it to do so. I don't know the general way the PSP rolls in this area though (me mostly messing around with the occasional AT3 file and that is it). Whether these nice silence gaps are space for the would be editor to use or you get to play with pointers I don't know. If you can make it the same size/shorter and pad it out, or maybe overwrite with silence if that is what you want, then that might allow you to make sure the base export format you used from audacity or whatever was working OK.
Export formats for game consoles for things that are not basic PCM/wave/common audio formats/common patent free formats are not always available but the PSP had a few for some more exotic things so who knows. If you can find a decoder then they might even have enough data in the source code for it to turn around and write something.
Title: Re: PSP audio in .bin format
Post by: Jorpho on April 24, 2021, 02:44:43 pm
Here are the threads I found. I managed to convert the files to .aa3 but couldn’t do anything with them.
https://forum.xentax.com/viewtopic.php?t=12840
https://forum.xentax.com/viewtopic.php?t=6273
That second thread shows that there are numerous bytes before the word "RIFF".  Thus, it appears that there is other data in the .bin file that the game might use to determine where the samples are located within the .bin file.

I am reminded of the "SEZ" format used by Megaman X4, but that is completely different aside from the fact that it also used a bunch of .wav files packed in another file.
http://www.romhacking.net/forum/index.php?topic=18400.0
https://www.romhacking.net/forum/index.php?topic=20753.0