[PS2] Questions about loop points in TXTH and GENH files - Ka 2: Lets Go Hawaii by JomSpoons at 4:31 PM EST on January 17, 2020
Hey there. So I'd like to ask a few questions about loop flags in TXTH / GENH files as I believe I'll have to set manual loops and I want to make sure I do it right.
So in short, I'm trying to rip the soundtrack to Ka 2: Lets Go Hawaii, which is the sequel to Ka (Mister Mosquito / Mr. Moskeeto). I re-ripped the soundtrack to Ka (which is in .INT format, a format I've not seen used in any other series) using TXTH files for playback in foobar2000 + vgmstream plugin, and also converting the soundtrack to GENH using VGMToolbox r1026. Here is the TXTH configuration that I used:
Now Ka 2 uses this same .INT format for it's music just like the first game, and this same configuration I used for the first game works here too. The only issue is that Ka 2, unlike it's predecessor, has custom loop points. In the first game it'd just start the song from the beginning every time it reached the end of a track. The auto loop flag detection seemingly isn't working here, so I assume I'll have to do it on my own.
What I'm currently planning to do is record each song in-game, then find the approximate beat on which it loops, measure the samples until that point, and then set the loop point based on that number. I want to make sure that this is an ok method for creating a soundtrack rip. Another thing I'd like to know is if I'm actually going about the auto loop flags wrong and there may still be a way for me to do so automatically. Either way, I'd appreciate any insight, I'd like to make sure I do this right. Thank you guys.
- Now create a file named ".names.txt". We'll put loop points there, so make an entry for any files that need to loop (you don't need to put non-looped files). # guessed loop points (sector-aligned) BTL_01: 1921024
I only did the first, you put BTL_02: xxxx and so on, where xxxx is the loop point.
- To find the approximate loop offset manually try this:
* open the file in Audacity, look how the wave ends and find a similar early part and note the sample loop point. For BTL_01.INT this seems around sample 1924000.
* Round the value with this formula: sample = sample / 1792 * 1792, and put the value in the .names.txt. For BTL_01, 1924000 / 1792 * 1792 = 1922816.
* Listen and see if your approximate loop start sounds ok. For BTL_01 it sounded a bit off, so add or sub 1792 until it sounds better, in this case 1922816 - 1792 = 1921024 was pretty good.
INT loop points are usually aligned to interleave (1792 samples) and not beat or stuff, so you don't need to be very exact. Doing this with Audacity it shouldn't take that long.
[PS2] Questions about loop points in TXTH and GENH files - Ka 2: Lets Go Hawaii by JomSpoons at 2:23 PM EST on January 18, 2020
This is a big help, thank you! I do want to ask though, where did you come up with the number 1792? I'd assume this number would vary from game to game so I'd like to know how you figured that out for future reference if I ever need to do this again for another game.
Edit: Also, I'm testing out different sample numbers for the track H_01 isn't perfectly aligning with the footage of the game I recorded. The loop flag would need to be somewhere between 150528 and 152320 samples, which would not be a multiple of 1792. Is it alright for me to do a sample number that isn't a multiple of 1792 or should I only stick to those?
1792 is the number of samples in an interleave block (0x400 or 1024 for this game), formula is: samples = block / 16 * 28 (16 being the size of a PSX ADPCM frame and 28 the number of samples in that frame), thus 1024 / 16 * 28 = 1792.
If this doesn't give exact loops adjust away, as this is just a guess (it's common that games are aligned like this, but not always), it gives you an starting point. Even if loops aren't aligned to interleaves they are very likely aligned to 28 samples (smallest unit for PS2's codec), so you can round like sample / 28 * 28 or fine tune your samples by starting from the above and add/sub-ing 28.