Users browsing this thread: 1 Guest(s)
FF6 Music Overhaul

#1
Posts: 1
Threads: 1
Thanks Received: 0
Thanks Given: 0
Joined: Dec 2016
Reputation: 0
Status
None
Hi all,

I come seeking aid for a complete music overhaul project I'm working on. This is for the PC\Steam version of the game, but I hear that the game files are identical so it could be useful for other ff6 formats.

I cannot get the songs that I've included in the game (I've done them all) to loop properly.

What I did:
I took all the music .akb files using FFVIExplore, found orchestral music online, converted those to .obb, looped them by samples (LoopStart=  and LoopEnd=) in Audacity, created an .obb that has the same type of content in the file (looked at an .akb file and noticed it only had LoopStart= and LoopEnd= , no authors or comments, etc), took the akb header info for all the files and put them in the new.obb files, renamed file.obb to file.akb, and put them in the game.

The Result:

The result is that everything plays in the game, but the looping doesn't! It loops flawlessly in audacity, but the game doesn't seem to care where I put my LoopEnd=. 

Discoveries:
1): The game will only recognize new music up to the length of the original song. So if the original song goes for X samples, and my new song goes for Y>X samples, It won't recognize any loops or content beforehand.

2): All the loop information that the game uses is in the akb file. I tried making a song where all the loop information is within the original length of the song next. This resulted in the exact same looping behaviour in all previous attempts! It seems that the akb file contains not just the length of the song, but the entire loop content (despite the original ogg files containing loop data too).

If somebody can help me out with generating akb files from ogg files, that would be great!

TheMathKing
  Find
Quote  

#2
Posts: 3,966
Threads: 279
Thanks Received: 234
Thanks Given: 56
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
It seems the akb format has a 204 bytes header followed by the ogg: https://steamcommunity.com/app/312750/di...336049726/

It seems to be true, and there are 4 three-bytes values that always change in the header: 00000008-0000000A, 00000010-00000012, 00000014-00000016 and 00000018-0000001A. Your loop-start and loop-end values are probably there. My first bet would be 00000014-00000016 as loop start and 00000018-0000001A as loop end because 00000014-00000016 is always smaller than 00000018-0000001A and they do not exceed 00000010-00000012 which could be song total length / file length. Those 3 bytes values are probably inverted (read from right to left) and represent probably samples number. Well they have to otherwise my guessed logic falls apart.

Some testing will be required to confirm all this (or not) but I leave this to you. You'll have to change all the songs manually but some automation can be done after: https://steamcommunity.com/app/312750/di...3475986718

Edit: Once you know where the loop-start and loop-end values are in a ogg file and in the akb header, it is easy to write a program that loop in a folder and extract the header from the file, add the header to new ogg and change the header looping info (and maybe file length if necessary). I could help at that point.
  Find
Quote  
[-] The following 1 user says Thank You to madsiur for this post:
  • mike9k1 (02-14-2022)

#3
Posts: 1
Threads: 0
Thanks Received: 0
Thanks Given: 0
Joined: Feb 2022
Reputation: 0
Status
None
(12-07-2016, 10:50 PM)madsiur Wrote: It seems the akb format has a 204 bytes header followed by the ogg: https://steamcommunity.com/app/312750/di...336049726/

It seems to be true, and there are 4 three-bytes values that always change in the header: 00000008-0000000A,  00000010-00000012, 00000014-00000016 and 00000018-0000001A. Your loop-start and loop-end values are probably there. My first bet would be 00000014-00000016 as loop start and 00000018-0000001A as loop end because  00000014-00000016 is always smaller than 00000018-0000001A and they do not exceed 00000010-00000012 which could be song total length / file length. Those 3 bytes values are probably inverted (read from right to left) and represent probably samples number. Well they have to otherwise my guessed logic falls apart.

Some testing will be required to confirm all this (or not) but I leave this to you. You'll have to change all the songs manually but some automation can be done after: https://steamcommunity.com/app/312750/di...3475986718

Edit: Once you know where the loop-start and loop-end values are in a ogg file and in the akb header, it is easy to write a program that loop in a folder and extract the header from the file, add the header to new ogg and change the header looping info (and maybe file length if necessary). I could help at that point.

Hey, I know this thread is suuuper old (6 years, wow), but I want to thank you for this. I've started modding Dragon Quest's mobile ports and it seems they use this same format (akb) for music files and sound effects.

Perhaps someone else may come across this in the event they encounter this same file type.

For now, I made a quick program that just strips the header info on any akb in the same folder and outputs the ogg (attached). Might be useful for ripping music from games that have like 50 akb's. 

I'm also going to try and start on a "replacer" program that will take the loop points and correct the header info in the AKB. If so, i'll try to edit my post. It looks like you are right on the nose about the offsets (or almost, they are actually 4 bytes instead of 3) -- 0x14-0x17 is the starting loop point, and it is stored as Little Endian. You can even convert this (https://www.scadacore.com/tools/programm...-converter) and compare it to the loop point stored in plaintext in the OGG header around offset 0x152 ("LoopStart=")

Update: I'm going to go ahead and add some stuff here.  I don't quite have looping working yet, but i'm getting closer (Edit: Looping does work, see my notes at the bottom). First, I thought I would mention that bytes 0x08 - 0x0B is the total size of the entire file in bytes (AKB header + OGG). Bytes 0x10 - 0x13 as well as 0xC4 - 0xC7 are still a mystery to me. I'm going to attach a sample akb with the info below in the possible event someone else manages to figure it out. I suspected 0x10 - 0x13 was perhaps linked to the total sample count of the OGG, but opening it up in Audacity...it doesn't seem to match. 0xC4 - 0xC7 also looks like it has some relation to the looping, as files that don't loop have that value zero'd out. 


Code:
BGM04.akb:
-Total File Size (0x08 - 0x0B)        575425
-Unknown 1 (0x10 - 0x13)             1322266
-Loop Start (0x14 - 0x17)              27530
-Loop End (0x18 - 0x0B)              1205793
-Unknown Float / Volume?? (0x20 - 0x23)     (usually ranges from 0.8 to 1.0)
-Unknown Int32 (0x24 - 0x27)     (usually ranges from 1 to 9)
-Unknown 2 (0xC4 - 0xC7)               17914


I've also attached an early version of AKBReplace, info below.

----
As for the program(s) I attached, just place AKBExtract.exe next to any/all akb's and double click. It should bring up a window saying "extracting audio files....done!" and prompt to exit

(I went ahead and bundled AKBExtract into the same zip as AKBReplace)

For AKBReplace, place it next to any/all original akb's as well as any replacement ogg's in the same directory. Name your replacement ogg's identically to the akb (ex: BGM01.akb and BGM01.ogg). This program will look for the "LoopStart" and "LoopEnd" metadata tags in your OGG (it specficially looks for this atm, so "LOOPSTART" or "LoopLength" won't work). It will convert them to hex (little endian), append the akb header info and edit it to reflect the new looping info --> it will output a new akb which you can use. 

Edit: I ended up testing by replacing with another BGM file extracted and the looping worked fine. It turns out that if the loop point is at the same sample count as the end of the file, it will not loop the akb. So in the event you run into this, subtract 1 from your "LoopEnd" value. 

I will still make some small revisions to AKBReplace (there are some small errors with the output and the handling of non-looped files, for example), but for now it seems to work. I will do some testing with it and update the attachment on this post.

Update 2: Added an updated version of AKBReplace with most loose ends tied up. For the most part it is testing well. One last oddity I will note (similar to the other one above) is that I've also found looping to fail if the loop start point is non-zero and too low. In at least one case when the start point was below 10000 samples- setting it to zero worked fine or setting it higher also worked. I wonder if this had anything to do with the value noted at 0xC4 previously, but I haven't the time to investigate it further.

Ofc looping hasn't worked yet in my testing (and I get that's...kinda important), but it's always possible someone could modify it to make it work in the event I don't get a chance to update it. (Ofc if I do, once again i'll just update this post) 

The "source code" is also included as a .ps1, and you can easily open it in notepad or run that with PowerShell if that's your preference.


Attached Files
.zip  akbreplace.zip (138.56 KB, 192 downloads)
.zip  BGM04.zip (539.5 KB, 158 downloads)
  Find
Quote  
[-] The following 1 user says Thank You to mike9k1 for this post:
  • madsiur (02-14-2022)



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite