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".
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:
Sonic 4: Episode II Spoilers: Panty 4: Episode II (now with Stocking co-op!)
Questions? Comments? Criticisms? Rage-fueled ranting? Let me know below!