Downsampling ADX files
by TuxTheWise
Why would I want to do that?
- Reduce size of your game, so it can fit on a CD-R.
- Reduce total data streaming.
1. Introduction
If you followed "Extracting data from GD dump files" (included on this pack), you could extract files of a GD dump with success. Then, you followed "Making GDI files bootable on real Dreamcast with perfection" (also included on this pack) you are able to make a perfect CD-R bootable version. But, when you tried it, you realized that the game is too big and won't fit on a CD-R. Somehow, you need to reduce the size of the game. If the game has .ADX files, then you can downsample it and get the space you need.
ADX files are sound files. They're usually used with music, because they can have loop markers, making the sound go back to a determined area when it reaches the end. In this guide, you'll learn how to downsample these music and reconstruct loop markers. I've seen some releases on internet where people didn't pay attention on loop markers, and they were just removed on downsampling process. It made music stop all of a sudden, what is pretty annoying.
Maybe you're wondering how much space you can make downsampling ADX files, and how bad quality will be after the process. About the space, you can save a lot. That's because ADX files have stereo channels encoded separately, not joint as (most) MP3 files. So, if you make music mono, you'll reduce size to half. Another point about space is that ADX files have constant bitrate, not variable. It means that you can determine space reduction easily with enough precision. Here is a little table with bitrates of most common ADX encoding:
- 44khz, stereo: 396 kbits/s
- 44khz, mono: 198 kbits/s
- 22khz, stereo: 198 kbits/s
- 22khz, mono: 99 kbits/s
Most ADX files are encoded in 44khz stereo, so 44khz mono is the best option when downsampling then. You'll reduce size per half and quality loss will be very small. Some people prefer to use 22khz stereo, the effect in size will be the same, so it's up to you to choose an appropriated format. I personally think that 44khz mono is the best option. Any lower quality will make sound quality too bad.
A game you may want to try is Jet Grind Radio. It's too big to fit on a CD-R, but if you mono the ADX files (downsample to 44khz mono) it will fit easily.
There are cases where monoizing the ADX won't be enough to save the space you need. Of course you can try lower quality, but as I said, quality will be too bad. Instead of doing that, I recommend you try other strategies, like downsampling .SFD movie files (there is another tutorial included on this pack). Downsampling movies can save much more space than audio with less quality loss. A typical case where monoizing the sound is not enough to make game fit on a CD-R is Sonic Adventure.
ADX is used mostly on Dreamcast games, but there are games of other consoles that use them (usually Dreamcast ports). This method probably will work on them too, but I haven't tested.
To finish, be aware that method explained here were learn after months of experience. It will provide the best quality possible in downsampling process, and it's the fastest way to do it.
So, it's time to start. Make a folder c:\adx and move all the ADX files you want to downsample there.
2. Decoding files
First step to downsample the files is converting them to WAV. It seems to be the simplest part, but it's not. There are a lot of "adx2wav" converters, but some of them are very bad. Some converters messes the volume of tracks, mainly on not 44khz sounds. Others just output distorced sound. The best decoder I've ever found was the one bundled on Foobar 2000. It works very good on any .ADX I've tested, and doesn't mess with the volume, so let's use it.
Open Foobar. If it's not the first time you use it, delete any file that is on the playlist. Go File, Add Files... and select all the ADX files of c:\adx, they will be added on the playlist. Have all the songs of playlist selected. Right-click one of them, Convert, Convert to Same Folder. On Encoding Preset, have WAV selected. All other options must be disabled. Click "More Setting". In field Single tracks, replace the text there for "%title%" (without quotes). It will make foobar2000 use the same name of input for the converted file, instead of putting a number before it. Click Close. Then click OK and foobar2000 will convert files to .wav, it will take a while.
Don't delete the original .ADX files yet, we still need them for loop markers data.
NOTE: I heard that the "ADX_Converter.exe" is a good decoder too, but I haven't tested it too much. If you want to try it, don't forget to mark "0" on Fadeout field. I personally think foobar2000 is better.
3. Downsampling sounds
When we encode the sound in ADX again, the encoder will use source file as information about encoding configurations. For example, if source file is mono, it will encode a mono ADX, if it's 44khz, it will encode in 44 khz, and so on. We'll use our just converted WAV as source, so any change we want to make in ADX we will make in the WAV now. For that, we'll use GoldWave. There are a lot of programs that can make it, so fell free to use your favorite. I like
GoldWave because it has Batch Conversion feature that let us encode everything at once.
Open GoldWave. Click File, Batch Processing. Then click Add Files and select all the WAV that you converted before using foobar2000. At the Convert tab, keep "Convert files to this format" marked. In "Save as type" select "Wave (*.wav)". In Attributes, select "PCM signed 16 bit, mono" if you want to mono the sound (if you're converting to 44 khz, you'll use that option) or "PCM signed 16 bit, stereo" if you want to keep sound stereo. Your sound is probably 44 khz (check it opening an ADX on foobar2000). If you want to downsample it to 22 khz (not recommended), you can mark "Rate (Hz)" and select 22050. If you want to keep 44 khz (unchanged), just let this box unmarked. In "Process" tab, be sure no effect is added. In Folder tab, keep "Store all files in their original folders" marked and "Overwrite existing files" too, so it will replace the original sound for your downsampled ones. Click "Begin" and it will convert the files. It may take a while.
4. Encoding the files
Darkfalz has made a very useful tool for batch encoding ADX files with loop, let's use it. Open ADXLoopCalculator.exe (included somewhere else in this pack). Select the directory c:\adx. You can keep "Delete ADX" marked, so it will automatically delete ADX after using them to determine loop markers. Click Calculate. The program will scan for loop markers in ADX files, and create a BAT file containing the correct command line for encoding ADX with them. Don't worry, if the ADX file has no loop markers, the correct command line will be used. After program is done, a file called "encode.bat" will be created on c:\adx. Before executing it, move/copy the file "adxencd.exe" to c:\adx. Now execute encode.bat and it will start encoding the files, it may take a while. After done, your job is ready. The re-encoded ADX will be in c:\adx, they will be smaller than original ones and you can use them instead in your game.
5. Final comments
Downsampled ADX files worked fine with me most of the times, except two times. One was in Jet Grind Radio, when I tried to monoized some songs and let others stereo. Original music worked fine of course, and when I monoized all the ADX it worked fine too. But if I kept some stereo and some mono, in transition of the songs (for example, when it was playing a stereo song and started a mono) game crashed. Other problem I had was in Fatal Fury. Song was stereo, but after I monoized it, music played only on right channel. Well, if something like that happened to you (I doubt it will happen, but anyway...), look for alternatives. In my case, for example, I kept all songs mono in Jet Grind Radio and used 22 khz stereo in Fatal Fury.
6. Thanks
- The nice guys who created the programs used here.
- Darkfalz for the random information let in forums in the past.
- This wonderful site tutorials (http://www.dreamwell.pwp.blueyonder.co.uk/dcselfboot/index.htm) for my first contact with downsampling process.
- All people that rip and distribute GDI.