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,974
Threads: 279
Thanks Received: 240
Thanks Given: 62
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: 3
Threads: 0
Thanks Received: 1
Thanks Given: 1
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.

Update 3 (Nov 2024): It came to my attention that the original .zip attachment was broken. I have added a new attachment with the just the powershell scripts mentioned above. They can be run by right clicking -> "Run with PowerShell" on most Windows PCs, given that powershell has permission to run. (They would also be very easy to convert for any other language / platform if need be)

I have also provided an alternative link for the original .zip in the reply below, along with contact information for anybody seeking assistance.


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

#4
Posts: 2
Threads: 0
Thanks Received: 1
Thanks Given: 1
Joined: Oct 2024
Reputation: 0
Status
None
I want to download akbextractor or replace, I'm working with a different game that has .akb files but I can't find anything on the web for them, and the download on the post above no longer works.
  Find
Quote  

#5
Posts: 3
Threads: 0
Thanks Received: 1
Thanks Given: 1
Joined: Feb 2022
Reputation: 0
Status
None
(10-11-2024, 09:37 AM)Hom Wrote: I want to download akbextractor or replace, I'm working with a different game that has .akb files but I can't find anything on the web for them, and the download on the post above no longer works.

Hi Hom, thanks for letting me know about this -- it just so happens that i'm working on another DQ (Mobile) title that uses the akb format and came back to this post to reference a couple notes when I saw your reply!

I'm going to re-attach it here. 

If you need to get ahold of me in the future, i'm usually active in the Yggdrasil DQ Modding Community and akbreplace is also available on the community Discord (under #dq4m-tools).

((You're also welcome to re-host akbreplace wherever you so wish. I would have tried archive.org myself, but it seems their services are degraded right now))


Best of luck with your project!

Edit: It looks like it's still borked for some reason, so i'm going to upload elsewhere and paste the link instead (sorry): https://mega.nz/file/CkJAVAqb#hRbGT8pjAD...7VRKmmjq-o
  Find
Quote  
[-] The following 1 user says Thank You to mike9k1 for this post:
  • Hom (11-05-2024)

#6
Posts: 2
Threads: 0
Thanks Received: 1
Thanks Given: 1
Joined: Oct 2024
Reputation: 0
Status
None
Ah that's great, thank you.

From my experience it seems the Kingdom Hearts games and most modern FF games use .akbs, and I wouldn't be surprised if other SQEX games do as well, this is incredibly useful, thank you.

So far I've just been using a hex editor to remove the .akb header and turn the files into .oggs manually, kinda hard when theres usually 1000+ sound effects in a game lol.

Also I tried the mega download, but it says virus detected, should I be worried about that?

Thanks again regardless!
  Find
Quote  
[-] The following 1 user says Thank You to Hom for this post:
  • mike9k1 (11-05-2024)

#7
Posts: 3
Threads: 0
Thanks Received: 1
Thanks Given: 1
Joined: Feb 2022
Reputation: 0
Status
None
(11-05-2024, 04:56 PM)Hom Wrote: Ah that's great, thank you.

From my experience it seems the Kingdom Hearts games and most modern FF games use .akbs, and I wouldn't be surprised if other SQEX games do as well, this is incredibly useful, thank you.

So far I've just been using a hex editor to remove the .akb header and turn the files into .oggs manually, kinda hard when theres usually 1000+ sound effects in a game lol.

Also I tried the mega download, but it says virus detected, should I be worried about that?

Thanks again regardless!


It probably has to do with the program that I used to convert the powershell scripts to a binary executable (ps2exe)

Despite being a completely benign tool, it created a lot of false positives once upon a time. 

---

In any event, if you're at all concerned, you can read the .ps1 scripts yourself to see exactly what it does and run those instead. [Edit: Attached]

(The binaries are mostly there for people who may not know how to run powershell scripts. They can simply copy those exe's to the directory of the obb/akb files and double-click)


Attached Files
.zip  akbreplace-powershell-scripts-only.zip (5.19 KB, 4 downloads)
  Find
Quote  



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite