Hello everyone!
I'm a game reverse-engineering and modding enthusiast focusing on games by Retro Studios (i.e. the Metroid Prime games and recent Donkey Kong titles). For some time, I've been wanting to insert custom music and SFX by implementing a DSPADPCM encoder (which many titles seem to use for audio compression).
Nintendo provides developers with DSPADPCM.EXE and dsptool.dll to perform the encoding. This tool and codec is available for GameCube, Wii and Wii U systems. The codec is based on an IEEE-defined ADPCM predictor combined with 8 coefficient-pairs selected via filtered discrete-fourier-transform. The result is 8-byte ADPCM frames with 1-byte header at 4 bits-per-sample. A mono 16-bit PCM stream ends up being ~28.5% the original size in DSPADPCM.
@delroth pointed me to this implementation in BrawlTools which appears to contain reverse-engineered versions of the original algorithms:
https://code.google.com/p/brawltools2/source/browse/trunk/BrawlLib/Wii/Audio/AudioConverter.cs
I spent much time trying to grok the algorithms, identifying the mathematical basis and transforming the reverse-engineered code into something more readable and optimized:
https://github.com/jackoalan/gc-dspadpcm-encode/blob/master/grok.c
I'm pleased with the results! Generated streams sound great when injected into actual game images. To make the encoding process easier, I've created a fork of Audacity to import/export .dsp files as well as .dsp derivatives used by Retro. Part of the .dsp format includes metadata for a loop-region as well; this is visualized as a label-track in Audacity. The encoder can easily be applied to layouts used by other games as well, so long as they derive from DSPADPCM:
Check it out here:
https://github.com/jackoalan/audacity/releases
I'm a game reverse-engineering and modding enthusiast focusing on games by Retro Studios (i.e. the Metroid Prime games and recent Donkey Kong titles). For some time, I've been wanting to insert custom music and SFX by implementing a DSPADPCM encoder (which many titles seem to use for audio compression).
Nintendo provides developers with DSPADPCM.EXE and dsptool.dll to perform the encoding. This tool and codec is available for GameCube, Wii and Wii U systems. The codec is based on an IEEE-defined ADPCM predictor combined with 8 coefficient-pairs selected via filtered discrete-fourier-transform. The result is 8-byte ADPCM frames with 1-byte header at 4 bits-per-sample. A mono 16-bit PCM stream ends up being ~28.5% the original size in DSPADPCM.
@delroth pointed me to this implementation in BrawlTools which appears to contain reverse-engineered versions of the original algorithms:
https://code.google.com/p/brawltools2/source/browse/trunk/BrawlLib/Wii/Audio/AudioConverter.cs
I spent much time trying to grok the algorithms, identifying the mathematical basis and transforming the reverse-engineered code into something more readable and optimized:
https://github.com/jackoalan/gc-dspadpcm-encode/blob/master/grok.c
I'm pleased with the results! Generated streams sound great when injected into actual game images. To make the encoding process easier, I've created a fork of Audacity to import/export .dsp files as well as .dsp derivatives used by Retro. Part of the .dsp format includes metadata for a loop-region as well; this is visualized as a label-track in Audacity. The encoder can easily be applied to layouts used by other games as well, so long as they derive from DSPADPCM:
Check it out here:
https://github.com/jackoalan/audacity/releases
Last edited by jackoalan,