don't click here

Sonic Generations/Sonic 4 Music Modding Guide

Discussion in 'Engineering & Reverse Engineering' started by Guess Who, Apr 30, 2012.

  1. Guess Who

    Guess Who

    It's a miracle! Oldbie
    4,296
    63
    28
    Oregon
    lol
    Sonic Generations and Sonic 4 music mods are incredibly easy to make, but for whatever reason no one's put all the tools together in one place and explained how to do it. So, merry Christmas, Retro.

    This Is What U Need:

    - A PC copy of Sonic Generations, Sonic 4: Episode I, or Sonic 4: Episode II. The process should theoretically be similar for Unleashed, Colors, or console versions as well, but this guide only covers the three listed.
    - All the tools in this archive. I explain what each one does later.
    - An audio editor. I use Audacity, but anything similar will work.
    - Windows. Sorry, some of these tools are proprietary and only run under Windows. Maybe WINE? Haven't tested.
    - Not required, but highly recommended: a media player with a vgmstream plugin. Lets you open the AAX and ADX files used by the games in your media player.
    - Optional for Sonic Generations: Korama's CPKREDIR mod allows you to skip the final step of this guide.

    Notes On Each Tool:

    QuickBMS: You'll use this to extract the CPK files used by the games. CPK files are like archives that hold the music (or other game data) files, and QuickBMS unpacks them.

    ADX Encoder: A command line tool that converts WAV files to ADX files, a proprietary CRIWARE audio format used by the games. Being a shitty command line tool, ADX Encoder does not like file paths with spaces in them, so make sure to put it in a directory that doesn't have spaces in the name (I use C:\adx).

    SFIV Audio Manager: Originally made for Street Fighter IV, which also uses CRIWARE audio formats, but works for these games as well. Used to pack ADX audio files into AAX archives, but does some other nifty things as well.

    CRI Packed File Maker: When you're done making your music tracks, this tool rebuilds the CPK you unpacked with QuickBMS so you can put it back in the game.

    Let's Get This Thing Started:

    First: download the tools linked in the What U Need section above, and extract them somewhere. As noted above, the ADX Encoder is very particular about where it can work properly, so you may keep it in a separate folder.

    Next, find the CPK file containing the music you want to replace. If you purchased the games from Steam (of course you did), you can find the game files under C:\Program Files (x86)\Steam\steamapps\common. The CPKs containing the music you want to replace should be under a folder called "Sound". Here's a quick guide to what CPK you might be looking for.

    Sonic 4: Episode I and II
    Sonic 4 makes it easy for you. All the music for the game, in either episode, is stored in a file called "SONICDL_SNG01.cpk".

    Sonic Generations
    This one's a little trickier. Generations stores each stage and each boss's song in a different CPK. Here's a quick mapping of most CPKs to what they contain:

    SNG00_SYS - Title screen/menu music
    SNG01_GHZ - Green Hill
    SNG02_CPZ - Chemical Plant
    SNG03_SSZ - Sky Sanctuary
    SNG04_SPH - Speed Highway
    SNG05_CTE - City Escape
    SNG06_SSH - Seaside Hill
    SNG07_CSC - Crisis City
    SNG08_EUC - Rooftop Run
    SNG09_PLA - Planet Wisp
    SNG10_CNZ - Casino Night (DLC)
    SNG11_BMS - Metal Sonic
    SNG12_BSD - Shadow
    SNG13_BSL - Silver
    SNG14_BDE - Death Egg Robot
    SNG15_BPC - Perfect Chaos
    SNG16_BNE - Egg Dragoon
    SNG17_BLB - Time Eater
    SNG18_PAM - Hub world tracks (a pain in the ass to mod, don't bother)
    SNG19_JNG - Jingles (invincibility, round clear, game over, etc.)
    SNG20_MSN - Mission tracks (Super Sonic Racing, Balloon Park, S3D Title)
    SNG22_ADD - All the unlockable tracks. Super handy for modding!
    SNG23_PAM - Extra hub world songs (Skills Shop, Collection Room - more easily modified)

    Notes on Generations/Unleashed Music Modding:

    Boost tracks are a motherfucker. They have to be sampled at a lower frequency and they have to line up *perfectly* with the original track unless you want the game to crash. For Generations, I strongly recommend replacing an unlockable song and just selecting the song you replaced (you're not going to miss Race to Win, I assure you). These tracks don't require boost counterparts. However, if you have the original AAXes from another game like Unleashed, Generations, or Colors, you can directly replace the music with no problems (for instance, I replaced Planet Wisp Modern's music in Generations with music from Colors and it works flawlessly, boost and all).

    Unpacking the CPK:

    Once you've found the CPK you're going to use, make a backup of it. Next, navigate to where you extracted QuickBMS. Make a new folder in QuickBMS's directory, preferably named after the CPK you're extracting. Run QuickBMS, and at the first prompt (when it asks for a script to use), select "cpk.bms" (also in the same folder as QuickBMS). At the next prompt, select the CPK you want to extract. At the third and final prompt, navigate to the new folder you just created and hit Save. Your CPK is now extracted in that folder!

    Formatting a Song:

    Now you need to make the song you want to put in the game work properly in the game. Some notes on what the game expects:

    - Most songs are sampled at 48000Hz with very few exceptions (mostly a few tracks in the Generations ADD CPK - usually noted in the file name).
    - Most songs are composed of two tracks, an intro part that plays first and then a looping part which repeats forever afterwards. Some songs (like title screen music) are only one part, however - if you're replacing one of these, ignore all the stuff about making two sections.
    - Classic Sonic stages and most Sonic 4 tracks also require a Speed Shoes variant. These are also two parts - the sped-up section at the start and then a normal-speed looping section. Like boost variants, these are not needed in Generations if you replace an unlockable song (in which case it just plays the Sonic Adventure speed shoes music instead).
    - Generations and Unleashed songs generally go all the way up to max volume, but Sonic 4 tracks are usually around -3dB. Adjust your songs accordingly unless you want them to be too loud or quiet in the game.

    To format the song, I use Audacity. Make sure to set the Project Rate in the lower-left corner to 48000Hz (unless you're replacing a track that uses 44100 - probably not) and keep it there at all times. Split the song you want into two parts - an opening section and a looping section. You'll almost certainly have to modify the song to make a section loop properly - play around in Audacity until you think it transitions smoothly from the ending back to the beginning. Export each section to a separate WAV file. I recommend playing the tracks in your preferred media player to make sure that the intro file smoothly transitions into the looping section, and that the looping section repeats seamlessly.

    For Speed Shoes variants, you can reuse your looping section, but your intro section needs to be approximately fourteen seconds long and at a higher tempo than the original track. Audacity has a built-in effect to allow you to change tempo. I recommend finding a different, roughly twenty-second portion of the track to use for your Speed Shoes variant than just speeding up your original opening section - you may also need to make a new looping portion to match, however. Again, export both sections to separate 48000Hz WAV files when you're done.

    Converting Your WAV Files:

    Now that you have your song all nice and formatted for the game, we need to convert your WAV files into ADX files. Copy your WAV files into the same directory that you extracted the ADX Encoder into. Remember, that directory needs to have no spaces in the name (like "C:\adx" - "C:\ADX Encoder" won't work!). Likewise, your WAV files should also have no spaces in their names (I usually use something like "intro.wav" and "loop.wav"). After you've copied them over, simply drag each file - one at a time - onto adx.exe. The program will output .adx files with the same names as your WAVs into its folder.

    Next, you need to merge your ADX files into an AAX archive. Even if you're modding a track that only has one part, you still need to do this. Open the SFIV Audio Manager (again, from the archive linked above), go to Tools, and select "Combine multiple ADX files to one AAX archive". Use Ctrl+Select or use your mouse to select both the ADX files you got in the previous step and hit Open, then choose where you want to save your AAX file and continue. Congratulations, you now have one working AAX file! I recommend opening it in a media player with vgmstream and listening to it to make sure everything converted right. Double-check that you used the appropriate sampling rate (usually 48000Hz)!

    Putting Your Music in the Game:

    Remember when you extracted that CPK containing the song you want to replace a billion steps ago? Go to where you extracted it and find which AAX file you want to replace. Rename the AAX file you just made to the name of the song you want to replace, and copy your new AAX over the old one. Next, open CriPackedFileMaker.exe. At the top, where it says "Base Directory", hit the folder-shaped button next to the address bar and select the folder where you extracted your CPK. Do not select the folder named "Synth" - select the folder that CONTAINS the "Synth" folder! After that, you'll see the program fill with a list of all the files from that directory, which will be placed in the CPK you're about to build. So hit "Build CPK file..." and under CPK file path, select the CPK you want to replace in your game's "Sound" folder (make sure you made a backup, like I said). Next, hit Start to Build and cross your fingers. You'll see the program's progress in the status bar on the bottom left. It will tell you if it's done.

    Optional for Sonic Generations: CPKREDIR

    If you're modding Sonic Generations, you can use Korama's CPKREDIR modification to make the game load files from a standard folder rather than a CPK. All the other steps listed here still apply, but you don't have to pack a CPK every time you want to make a mod. Make sure to read the text file included with CPKREDIR to get it working!

    Once you've done all this, it's time to test it out in-game! Fire up whichever game you're modding and play through it to make sure your song was inserted properly! If not, well, try again and make sure to follow this guide very closely! Or maybe I wrote something down wrong? If so, let me know.

    Here's a few samples of what you can do with this:

    http://www.youtube.com/watch?v=EqasHokvabk
    http://www.youtube.com/watch?v=5HSS4wNwf6g
    Sonic 4: Episode II Spoilers: Panty 4: Episode II (now with Stocking co-op!)

    Questions? Comments? Criticisms? Rage-fueled ranting? Let me know below!
     
  2. JaxTH

    JaxTH

    Pudding Deity Oldbie
    10,355
    586
    93
    Los Angeles
    Jack shit.
    I love you.
     
  3. Bareirito

    Bareirito

    Member
    102
    0
    0
    Argentina
    Sonic - Mystery of the Chaos Emeralds
    My god! YOU'RE EVERYHING ON MY SAD LIFE!!! That's the thing I was looking yesterday! You made my dreams of a Sonic 4 with a proper soundtrack true! :'D Thank you so much sir! Trying this right NOW! :)
     
  4. Bareirito

    Bareirito

    Member
    102
    0
    0
    Argentina
    Sonic - Mystery of the Chaos Emeralds
    Sorry for double post, but I'm having a little problem. I don't understand how to convert the .aax files into wav. Maybe I did skip a step or I didn't understand that much. Forgive my ignorance.

    I did have success on replacing a one of the songs from Sonic 4 with the Modern Green Hill from Generations, so I did the other steps successfully and came out nicely. I'm having trouble only with that little thing.

    Your help is much appreciated! :)
     
  5. Knucklez

    Knucklez

    I love 2B 'n' ass. Member
    687
    21
    18
    This is beyond useful.. I can't wait to get my hands on Episode 2 and swap its dull tracks with legit remixes made by others in the community.

    The fact that it's that simple to customize the soundtrack to your own game is why I prefer PC/Steam over any other console.
     
  6. Guess Who

    Guess Who

    It's a miracle! Oldbie
    4,296
    63
    28
    Oregon
    lol
    For the purposes of this guide, you shouldn't need to convert AAX files into WAVs, just the other way around. Make sure to read the guide carefully - you export the WAV files from Audacity, then use the ADX Encoder to convert the WAVs to ADX, then use SFIV Audio Manager to convert from ADX to AAX.

    (But if you ever need to go from AAX->WAV, you can use the SFIV Audio Manager. Under tools, choose "Extract separate ADX audio data from AAX archive(s)", then use "Decode ADX files to WAV" on the ADX files you get.)
     
  7. Bareirito

    Bareirito

    Member
    102
    0
    0
    Argentina
    Sonic - Mystery of the Chaos Emeralds
    Yep, I realised an hour later, so ignore my post. :P By the way, thanks for your help! :)
     
  8. BrigadierBaz

    BrigadierBaz

    Member
    10
    0
    1
    Poole, Dorset, UK
    Generations Music Replacement and Editing
    Ah, the perfect way to get into the hacking scene. Got me to the point of XML editing. (Not that it's difficult)

    It's true about the trial member comment! Take me for example!

    PS: Never understood why the Egg Dragoon CPK is named "BNE", can't think of what it could stand for.

    EUC is easy since Rooftop Run is styled on Europe.
     
  9. Hey! Great guide!

    Had a quick try replacing Splash Hill 1 with the olympic games version. The speedup vers I made works fine but the normal track gets the intro and the looping section arse about face. The level starts, it plays the looping section as an intro then loops what's supposed to be the intro indefinitely. Tried a couple of times with same result. Any help very much appreciated.

    Also Windows 7 seems to need admin permission to get any changes to the S4 files to work, anyone else had trouble with this?

    Cheers
     
  10. Guess Who

    Guess Who

    It's a miracle! Oldbie
    4,296
    63
    28
    Oregon
    lol
    Ah, yes, this is a little quirk with SFIV Audio Manager I only recently noticed. The program combines the ADX files in alphabetical order, meaning whichever file name comes first alphabetically becomes the intro and the second one becomes the looping section. You can use filenames like "intro" and "loop" to solve this or "songname.0" and "songname.1" or whatever.

    Can't help you with the admin permission thing. I run with UAC off because I live on the edge.
     
  11. SonicHyuga

    SonicHyuga

    Member
    48
    0
    6
    Tennessee
    Sky Rail (Generations) and Aquarium Park (Generations)
    I've been placing Part1 and Part2 after each filename, and it has worked like a charm so far.

    Have you tried right click -> Run as administrator? I'm using SFIV on Windows 7, and it will save directly to C: without asking for admin permission.
     
  12. Plorpus

    Plorpus

    Hog Blue So What Member
    977
    261
    63
    BNE stands for (Boss) New Eggman. Egg Dragoon is referred to internally as New Eggman Robo for whatever reason.
     
  13. Jaseman

    Jaseman

    The programmer has a nap! Hold out! Programmer! Member
    954
    1
    18
    Uh, damn. This is what U I need. What about the iPhone version of eps1? It seems to have each song in different files. not in a CPK file, I think as CSB files. Whenever I try something as simple as switching two tracks around, the level has zero music :(.
     
  14. All working for me now. Cheers dude! :)

    & yes SonicHyuga, that's what I meant, it won't change anything unless I've right-clicked and hit "run as admin".

    But since the main part's working now it doesn't really bother me, was just curious if anyone else had similar issues.
     
  15. Guess Who

    Guess Who

    It's a miracle! Oldbie
    4,296
    63
    28
    Oregon
    lol
    Just did some investigation into Episode II on iOS. The songs are stored in an "AWB" file, which is apparently a slightly modified type of CPK with a different TOC. QuickBMS can't unpack it, but this tool will. It doesn't give you the file names, however (just stuff like 0043.bin). So, as of right now, there's no tool to rebuild an AWB or even read the TOC properly.

    The music files themselves appear to be 22050Hz ADX files (not AAX), probably to keep the file size low for iOS devices and the App Store.
     
  16. Korama

    Korama

    Tech Member
    272
    2
    0
    Sounds like an ITOC. It references files by arbitrary IDs instead of by names.
    That could come in handy as a test case for my CPK file reader, so thanks for the notice. I'll take a look at it when I can.
    Now if someone were to find a CPK with a GTOC, that would be great. (That's another TOC type that's not supported by any available tool I know of.)
     
  17. Guess Who

    Guess Who

    It's a miracle! Oldbie
    4,296
    63
    28
    Oregon
    lol
    Bingo. That tool I posted also includes the source, if you want to see how their unpacker works.
     
  18. Chris Highwind

    Chris Highwind

    Member
    2,100
    16
    18
    Statesville, NC
    Slacking
    Hmm...I've followed the instructions, but when I test the AAX, there seems to be a split-second pausing between going from the intro to the loop, and then at every loop point

    EDIT: Disregard, the loop had a 0.2-second pause right in the beginning of it, which, when playing it by itself, is practically unnoticeable, but when played right after the intro and/or on repeat, it's pretty noticeable. I removed the pause, and the AAX runs seamlessly, both in Winamp and in Generations.

    EDIT 2: Thanks to Guess_Who for helping me figure it out.
     
  19. plushifoxed

    plushifoxed

    that power is yet unknown Oldbie
    1,704
    49
    28
    jazzy nyc
    puella magi chroma magica
    Has any progress been made on repacking S4E2 iOS's music?
     
  20. Lyrica

    Lyrica

    (Formerly: Donnyku) Oldbie
    1,365
    36
    28
    Pennsylvania
    Wedding Planning
    Okay so I tried my hand at it, but when I go to convert the wavs to ADX they become nothing but static.

    http://donnyku.nothingforfree.com/SSZ.zip is the wavs I made. If anyone can find what I did wrong, please tell me.