SSM Hacks
AUDIO HACKS : SSM FILES
Overview of Audio Format - SSM
SSM files hold audio clips, just like Pl****.dat files hold textures. They're like packages. SSMs hold a lot of sound files, each one approximately 1 second long. The format for the basic sound file system in the GameCube is called DSP (also called ADPCM). This is encoded audio that provides coefficients (special values) to allow the GameCube to decode it, like a decoder ring to decode a secret code. The coefficients are the decoder ring. Remember these "coefficients", they're very important.
A word about coefficients, since they're so important. First, why are they called coefficients? The word "coefficient" in math means "the number before the variable". So in the expression "3x+5", the coefficient of x is 3. But this doesn't help in the hacking sense. I have no clue why the magic numbers in Gamecube Audio are called coefficients, I just saw it called that in an explanation somewhere on the Internet (possibly YAGCD or Halley's Comet Software). They're just called coefficients, okay, it is what it is. The real question is, "What are coefficients"? Coefficients are 16-bit values that tell the Gamecube how to interpret the audio data in SSMs, DSPs, HPSs, and other audio files. They come in groups of 16, for a toal of 256 bits. That's 32 bytes, or 0x20 in hexadecimal. Since they tell the Gamecube how to read the data, coefficients are responsible for the quality and volume of the audio. I know, this is complicated, but just bear with me here.
The audio data itself comes in 8-byte portions, where the first byte calls a coefficient that tells the Gamecube how to decode the other 7. I'll repeat this as we go along.
The way DSP is structured is the data starts 0x60 bytes (that's 96 in decimal) into the file. Before that is header data, and the magic coefficient values (responsible for the quality and volume of the audio). The actual data comes in 8-byte clumps. The first byte calls one of the 16-bit coefficients to decode the next 7 bytes of audio. As I said, I'll repeat the info a bit, and say it in different ways to try and make it clear.
An SSM file is just a bunch of DSP files. Instead of placing each DSP one after the other, the SSM will split the DSPs and then place the different parts together. All the coefficients of the DSPs are clumped together at the beginning of the SSM, which takes up a few hundred bytes. After that the actual sound data begins. So here's an example to help. I have 5 DSP files, each one a different 1-second-long sound clip. I take the coefficients from DSP#1, 2, 3, 4, and 5, and I put them one after the other at the beginning of my new file (my SSM). Then I take the audio data that's left over from #1 and put it in my SSM. Then I take the audio data that's left over from #2 and put it in my SSM, after the audio data of #1. And so on, until I finished through #5. That's more or less it, but there's a little bit more to the coefficients, which I'll explain below.
NOTE: Most sound effects are mono (one channel of audio), but a few are stereo (two channels, L and R). You can find out whether the sound is mono or stereo with ssmex.exe. When a sound effect is stereo, there are a few changes to be made in the SSM. First of all, there are two DSPs that make up the sound - one L and one R. So in the SSM, there's twice the audio data for that sound. Second, since there are two DSPs, there are two sets of coefficients. Now, from the example above, if DSP#5 was a stereo sound effect (there would be two DSPs since it's stereo, lets just duplicate it for now to make L and R), I'd take the coefficients from DSP#5-L and place them after the coefficents from DSP#4. Then I'd take the coefficients from DSP#5-R and place them after those of DSP#5-L. When I'm placing the audio data, I'd put DSP#5-L's audio data after DSP#4's audio data. Then DSP#5-R audio data goes after that. Kinda confusing...sorry.
SSM Audio Hacking
What you need:
--SSBM ISO (you knew that by now)
--Hex editor
--an audio editor. I used Soundbooth, but Goldwave is good, too. I don't know about Audacity
--ssmex.exe (look up "hcs ssmex" on Google)
--cmd.exe (command prompt)
--Wii/GC SDK (specifically dspadpcm.exe and dsptool.dll...maybe soundfile.dll, too, perhaps)
--GC-Tool
What to do:
0. Before you start
Extract the audio SSM files from the ISO with GC-Tool. The ones you might be concerned with are under \audio\us for English version sounds, while those under \audio but not under \us are Japanese version sounds. Put all these SSM files into a directory, categorize them, whatever. Heck, you can do one at a time, it doesn't matter. As long as you know what's what. Make sure you have the Wii SDK tools in the same directory, as well as ssmex.exe and your trusty command prompt.
1.Extract DSPs from the SSM
Make sure that the SSM you want to extract from is under the same folder as ssmex.exe and cmd.exe..now run cmd.exe and type in this
filename.ssm should be replaced with the SSM file that you're extracting from.
You should see a bunch of lines of data. Very useful data. The program will tell you how many DSPs there are, whether they are stereo or mono, and where they are located in the SSM. And it will extract them. (If you have Visual C++, the DSP files may have the VC++ Project icon. Don't double click when you edit them. Just right click and open with a hex editor.)
2. Convert to WAV
The SDK program dspadpcm.exe not only converts WAV->DSP, but also DSP->WAV. Nifty. So run cmd.exe and type in
dspadpcm -d inputfile.dsp outputfile.wav
NOTE: "-d" means "decode". The outputfile parameter is optional; the program by default creates a WAV with the same name as your DSP. Also, if you want it to create an AIFF instead of a WAV, type "-f" at the end of the line, as another parameter. If you want info on your DSP dumped in a TXT file, type "-c" as a parameter, too.
This generates the WAV. Open it up in your favorite audio editor, and take a look at it. The important things to check are
a. sample rate (eg, 32 kHz)
b. bit depth (eg. 16 bits)
c. channels (eg. stereo or mono)
d. length (eg. 0.629 seconds)
e. volume (eg. max of "-1 dB", whatever that means)
If you can't find any of this info out, just play the file in iTunes, and right click it, go to Get Info->Summary. The Options tab has the exact length in seconds.
We need this info because we want to make our audio that we'll replace in the game as close to the original as possible. So we'll make its settings as close as possible.
3. Using your own audio
Now, when using your audio, you have to realize it's going to be short. The clip can't be much longer than a second, really. It's just sound effects. But, there are a whole lot of possiblities, nonetheless.
-Take your audio clip, open it with the audio editor, and, if it's stereo, export the channels individually to get R and L mono channels. Pick one of them to be your in-game sound.
-Adjust the length of the clip to match the length of the original
exactly. Down to the thousandth of a second.
-Adjust the volume, a lot. It should be fairly loud, louder than all the other sounds on your computer. When you save your clip, make sure the settings match those of the original.
4. WAV->DSP
Now that your audio is formatted correctly, we're going to run dspadpcm.exe again. Run cmd.exe and type
dspadpcm -e inputfile.wav outputfile.dsp
NOTE: "-e" means "encode". The outputfile parameter is optional; the program by default creates a DSP with the same name as the WAV. If you want info on your DSP dumped in a TXT file, type "-c" as a parameter, too.
Now we have our DSP!
5. Manual hexing...
Open up your hex editor of choice. Open the original SSM, the original DSP, and the new DSP. Go back to the ssmex.exe program, and drag the SSM file over the icon. This will launch the program, but it won't extract the DSPs (I don't know why, but I don't mind). Instead it will just give the info on each file. Don't close this.
Hex time.
-Compare the original DSP to your new DSP. They should be very similar in length. Best case scenario, they're exactly the same. Absloute worst, your new one is a lot longer.
-In the new DSP, copy the data from 0x60 on. This might be in the middle of a bunch of 00's, but it's correct. Open the cmd.exe window and look for the original filename. The offset data will be right by it. So, go to the SSM, and paste the copied data at the specified offset. Double check to make sure you didn't make a mistake.
-At the end of the data, if there's still a little room before it goes to the next DSP, just insert 00's or FF's until it ends. If you think you went over the limit, you're in a little trouble. Ctrl-Z undo, mate. You need to find the length of the data from the cmd window, which has the beginning and end offsets for each DSP. Copy that amount only, and paste that. **I only
think that the longer ones will still work. I haven't tested, though**
-Back in the new DSP, copy the funky looking data from 0x1C to 0x3C. This is the coefficient data responsible for correctly decoding the DSP audio. What we have to do is paste it in the correct spot in the beginning of the SSM. Either count from the beginning of the SSM (every 0x48 bytes is the end of a block of coefficient data for mono files....stereo files are a bit longer since each channel needs coefficient decoders. Just count out two mono coefficient blocks for stereo) to find it, or match the original DSP data from 0x1C to 0x3C in the SSM to find it. When you find where it starts (remember the coefficient data is always 0x20, or 32, bytes long), paste your new DSP coefficient data over it. Good to go.
Save the SSM in a safe place.
6. GC-Tool it up
GC-Tool->File->Open GC-ISO->ssbm.gcm
Select the SSM from the list it makes, right click->Replace File->choose the SSM you edited
File->Close GC-ISO
Exit
And we're done! With SSM, at least.
EXAMPLE - Editing Roy's taunt (Testing )
NOTE: This is what I did exactly in order to get the "testing" SSM example that Steelia used in one of his youtube vids. I have notes explaining extra steps that I didn't take which would increase sound quality and volume.
0. I extracted emblem.ssm from the \audio\us folder, and put it in a folder with ssmex.exe, cmd.exe, dspadpcm.exe, and soundfile.dll
1. I run cmd.exe, and I type
which outputs a bunch of DSPs for me, named "emblem00, emblem01, emblem02...etc"
2. I press enter to quit the program, and then I type
which outputs a WAV called emblem0b.wav. I listened to it in iTunes, and found it was the "hiii-ya" for Roy. I decided to edit it.
Opening Soundbooth with emblem0b.wav revealed it was 0.629 seconds in length, at 32kHz, 16 bit depth, mono, and had a max volume of "-1 db". OK..
3. I took an old sound clip I made to test what Soundbooth could do when I first got it, and I opened it up. It just was me saying "testing" over and over. I exported it to two mono channels, since it was stereo. I chose the R channel to edit, and I cropped it to exactly 0.629 seconds. Save as Test01R.wav (32000 Hz, 16 bit depth, Mono).
NOTE: You can also manually increase the volume, which helps with hearing it in-game.
4. I run cmd.exe and type
which outputs my DSP called Test01R.dsp
5. Oh boy, hexing. I opened emblem.ssm, emblem0b.dsp, and Test01R.dsp with a hex editor (HexEdit, anyone? I happen to use that...).
-I run ssmex by dragging the emblem.ssm over the icon, and get the offset data that way.
-I copy the data from Test01R.dsp from 0x60 on, and paste it into 0xDF70, with about 17 bytes to spare, so I fill in the extra space with 00's.
NOTE: I didn't do this step the first time....>>> I copy the coefficient data from Test01R.dsp at line 0x1C, to emblem.ssm. Since emblem0b is the 12th DSP (they start at 00, not 01), I go to offset (72*12) = 864, or 0x360. That's the end of the coefficient data. So I paste the data from Test01R.dsp 16 bytes before 0x360 - at 0x340.
6. GC-Tool. You know how it goes.
And there we have it. SSM audio format, done. So go and make some sound effets/voices!!