Modifying Music

Discussion in 'NDS - ROM Hacking and Translations' started by LightSamus, Sep 24, 2008.

Sep 24, 2008

Modifying Music by LightSamus at 2:16 AM (728 Views / 0 Likes) 1 replies

  1. LightSamus
    OP

    Newcomer LightSamus Newbie

    Joined:
    Sep 24, 2008
    Messages:
    9
    Country:
    United Kingdom
    Complete noob to hacking here and I was just wondering if it were possible to replace the in-game music with your own tunes? I'd be willing to do whatever it took if it is possible. Please let me know if I can! Thanks!
     
  2. FAST6191

    Reporter FAST6191 Techromancer

    pip
    Joined:
    Nov 21, 2005
    Messages:
    21,703
    Country:
    United Kingdom
    Yes, how hard it is depends on what the game uses although ironically it is usually the games that deviate from the standard that are easier to do.

    Copied and pasted from some of my upcoming docs although you may have seen similar before. It is early stage but it should help a bit and further discussion is more than possible:
    Audio:
    Sound appears in waves for those that recall science lessons. The most basic form of storing sound is to sample the waveform at intervals (hence sample-rate) and play back the amplitude of the wave at the intervals they were taken from. Do this well enough and you replicate the sound as far as people can detect (this is usually considered to be around 2 times the highest frequency someone can hear or around 44KHz for "transparent" quality. The DS tends to muddle around from around 11KHz (about telephone quality) to around 48000 Hz ("DVD" quality) and come in three main formats:
    instrument:
    a cymbal hit, a piano sequence.....
    "midi"
    an arrangement of instruments
    full blown wave format.
    whole songs or voice samples.

    44000 samples a second each with 16 bits as you can imagine takes a lot of space up in very short order but rather nicely most sounds do not alternate that much so you can then assume one millisecond is the same as the next (it gets far more complex than that of course) which means you can drop the size of the file. Now not being a waveform however you have to make it into one which takes CPU time and other resources.
    Most DS roms use the SDAT format
    http://gbatemp.net/index.php?showtopic=82825
    http://gbatemp.net/index.php?showtopic=84009

    SDAT/sound replacement: originally done to shrink roms (goldeneye has an especially small file) but these days is done mainly for undubbing games.
    The simple undub merely takes the Japanese sound files and replaces the ones from the Euro or US release and it works most of the time. Other times there are extra or fewer sounds or it is done in a different order (the DS can use name of a file or ordinal (numbers) to call a sound) leading either to odd sounds being played or to crashing. Here you have to alter the files to match with techniques detailed in the next paragraph.

    SDAT tweaking: various people have tweaked tetris to play different songs. I did it to play the classic tetris theme ( http://gbatemp.net/index.php?showtopic=36870 ) all the time and mufunyo removed the BG music entirely ( http://gbatemp.net/index.php?showtopic=69603 ).
    Other times this can be done to reduce loading times/increase stability. Various people did it for the Castlevania portrait of ruin to reduce/help with crashing.

    Full blown sound replacement: the first people to do this were messing around with electroplankton as it uses plain windows compatible wave files which brings me onto the next thing.
    What sound files are.

    The most common format is the SDAT format. Used in all but around 15 games (unfortunately those 15 games are somewhat noteworthy).
    Others use common formats (electroplankton) and not so common but common in games world (the world ends with you http://gbatemp.net/index.php?showtopic=86998 and N+ ). Such “new” formats are almost always another way to get a compressed wave file playing rather than a new take on midi.
    One or two use tweaks on a "common" format meaning you will likely have to make new tools/alter existing ones to do it (lower bitrate/only mono audio/lower sample frequency/lower bit depth.....) but this is fairly rare and most tools allow for this even if they were not intended to be used for it). Owing to the difficulty in creating a new format from scratch and the lack incentive to do it (it would be a lot of work for little, if any, gain) few companies ever make their own format here. Should they make a new format they will usually either patent it (if it is allowed) or publish it to try and spread it far and wide (a format nobody uses is doomed to failure and obscurity).

    SDAT format stuff is fairly easy to work with.
    Specs here
    http://loveemu.yh.land.to/page/NDS/SDAT.html
    http://kiwi.ds.googlepages.com/sdat.html
    Tahaxan forums have a early stage repacker but I find a hex editor and a spreadsheet nicer to work with.

    For the BG music tweaking the file system is normally tweaked to read a different file (or none at all, normally by "reading" outside the actual file).

    Next is simple replacement/swapping. I mentioned the repacker and it is easy enough to swap from rom to rom but the formats used within SDAT are not quite common PC formats which makes converting to the format a bit harder. The formats are detailed properly in the links I gave you above and kiwi.ds also made midi2sseq:
    http://kiwi.ds.googlepages.com/midi2sseq.exe

    You have simple sounds: drum hits, a gun shot in soundbite format (normally some form of PCM/IMA-ADPCM)
    You have midi type files (not actual midi but close enough for conversion to and from) with their instruments in distinct sections.
    Lastly you have full blown tracks (Tony Hawks games are the most common here). PCM or IMA-ADPCM (also detailed above) are the most common.

    See the rom ripping and enhancements link in my signature or I also added it to the rom hacking docs also in my signature (and stickied at the top of the forum) for methods of pulling roms apart.
    Threads you might find interesting:
    http://gbatemp.net/index.php?showtopic=88172
    http://gbatemp.net/index.php?showtopic=33647
    http://gbatemp.net/index.php?showtopic=82825
     

Share This Page