Skip to main content

Music Insertion

(by forte and recordreader/thisisausername/icecream, with massive help from the VGM Resources community)

This is a hands-off guide to inserting custom music into the DS Pokémon games (or most .SDAT based DS games). As such, the purpose is not to tell you exactly what to do on every step, save for the process of actually inserting tracks. Rather, it is to present as many viable options as possible to help the end user understand the process and make their own decisions. These instructions up until the actual insertion are also exactly the same for GBA and 3DS; the only difference is that resolution for GBA stuff should be 24 and resolution for 3DS stuff should be 96.

Before we begin, here are some things to keep in mind:

  • The vast majority of these instructions will currently only really work on Windows. While Cubase works natively on OSX, and Logic Pro is landlocked to it, much of the software involved in actually putting this stuff in the game has support ranging from shaky to nonexistent on platforms other than Windows. Cross platform options (namely ndspy) exist, but they either are suboptimal or obtuse for the average person.
  • This guide runs under the assumption that you are in possession of the full versions of each piece of software used for this process. Some of the lesser versions of products function slightly differently, so do keep that in mind.
  • Perhaps most importantly, this does not go into great detail on how to actually write the music you want to insert, mostly since that topic is a lot more nuanced and overlaps with some more complicated topics. This guide focuses mainly on the often unintuitive procedure of getting sequence data from a DAW into a ROM. The rest will be saved for a dedicated composing guide.

Obtaining DS sound assets

This is not a compulsory part of making DS music, but it does help a lot for reference (especially if you are arranging a track). Nitro Studio 2 Deluxe is the currently best software for this for reasons I will explain in the composing guide. Also this goes without saying but this assumes you have the ROM image for the game you want to manipulate the music of.

First you will need the game's .SDAT. You may extract it from the ROM however you wish, but I recommend TinkeDSi (NOT og Tinke!!!) as it is the most versatile and least buggy (for putting the .SDAT back in, it is also the only option if you are not using SwissArmyKnife or CTRMap, as nothing else, not even ndspy, will preserve the DSi header in Gen 5 games). When you run the executable, it will ask you to open a ROM. Once you do, look for the .SDAT, then click "Extract". Save it to a location you can remember. The location and name of the .SDAT varies on the game:

  • In Diamond/Pearl, it is data/sound/sound_data.sdat.
  • In Platinum, it is data/sound/pl_sound_data.sdat.
  • In HeartGold/SoulSilver, it is data/sound/gs_sound_data.sdat.
  • In Black/White, it is on the root named wb_sound_data.sdat.
  • In Black/White 2, it is on the root named swan_sound_data.sdat.

Now open Nitro Studio 2 Deluxe and open your .SDAT file in it. When it loads, you should be able to collapse the various dropdowns on the right. The ones you'll probably be the most interested in are Sound Sequences and Instrument Banks. Right click and hit export on the ones you want to save as MIDI and DLS or SF2 respectively (DLS is used by Fruity LSD, SF2 is used by BASSMIDI, and you can use either for Awave Studio). Look to the left while a sequence is selected to see which bank it uses.

At some point you might notice that Nitro Studio 2 Deluxe actually lets you import MIDI files directly and convert them for you, so you'll ask "hang on, why the extra steps to insert?". When the tools get better I will actually recommend this, but I'll explain why I discourage this for the time being in the insertion section.

Composing

Obviously the actual composing process will differ greatly depending on your digital audio workstation (DAW) of choice, as it mostly is a reflection of each program's workflow.

Digital Audio Workstation (DAW) recommendations

However, as much as I do not want to start another DAW war, unfortunately most of them simply have really bad MIDI support and thus are not suitable for making DS music. As such, though it's unlikely I will fully convince you, there are a number of them I cannot recommend for this reason, even if they have other applications. Ironically enough, this includes most professional grade DAWs. FL Studio is an okay DAW for making new tracks but an utterly terrible one for editing existing ones, Studio One does not allow you to change MIDI channels or export program changes, Digital Performer is near impossible to use without an external MIDI device, Mixcraft is great for everything up until the point you need to actually render a MIDI, LMMS has had an open issue on its github to add full MIDI support since 2014 (sidenote: LMMS is pretty much the only DAW that will work on a Linux machine with impunity but...why are you doing music production on Linux instead of in a VM at the very least), and Pro Tools is, uh, yeah we don't talk about that one. Logic Pro is a good DAW with powerful functionalities, but it being Mac exclusive means that you can't use most of the other stuff you need to insert stuff into the game (this is, however, not much of a problem if you also have a Windows machine available). Despite everything I just mentioned, FL Studio is still a popular choice for DS hackers, although I will go into the mess that is trying to use it for such in its own section. If you are using it, most of what I am about to say until then will not apply.

One major issue that a lot of DAWs have is with changing note resolution (it goes by many names depending on the program, such as note resolution, tick rate, and pulses per quarter note or PPQ). Where-ever it is, you will want to change this number to 48, which is the resolution that the DS uses. If you do not change this, then the converter will attempt to retime your sequence automatically which can have...less than stellar results. The issue that most DAWs have is that...they don't allow you to change it (usually it's some multiple of 48, but even that can cause problems). Mixcraft notably suffers since it uses the overt and borderline unusable resolution of 1000 (it's not even a multiple of 3, so say goodbye to your triplet notes).

Ultimately, the best and most efficient choices for DS music come down to the two with the best MIDI support: Cubase and REAPER, so this guide will largely assume you are using one or the other. Which one to choose is up to you: Cubase is overall the better program, but REAPER is much cheaper if you aren't using it for business purposes.

Generally the first thing you want to do before you even start composing is change the note resolution. If you are working with an existing MIDI with an idiosyncratic resolution, pray that the automatic retiming upon import works wonders. In REAPER, open your Preferences, and then under Media, hit MIDI. Ticks per quarter note for new MIDI items is the number you want to change.

Importing MIDIs

Importing a MIDI is a relatively simple task in most DAWs as they allow you to more or less drag them right in. In REAPER, you can use the Media Explorer (make sure all the options are checked!!!), and in Cubase you can select MIDI from File>Import (be sure to import as MIDI tracks, and check "Import Markers" and "Auto Dissolve Format 0"!). To load the soundfont you exported earlier, you can use anything that will load a soundfont as a MIDI out plugin, but the best and most cross-DAW viable option by far is the BASSMIDI VSTi.

Keep in mind that combining a sequence and a soundfont will not give you exactly how it will sound in game. The DS sound system is simply impossible to replicate with these two things alone (also be mindful that MIDI exports from NS2 are very slightly bugged, namely in how it interprets any pitchbend event that is -1200 cents as being +1200 cents). As a corollary to this, do not assess the mix of the track solely from how it sounds with the soundfont. It's just more trouble than it's worth.

Regardless of if you are arranging an old track or creating a new one, once you have your DAW set up, you can begin. Once again, specific instructions on how to actually write music will be saved for the composing guide; this guide assumes you already know the ins and outs of the system (and are already familiar with the nuances of your DAW of choice).

Loop markers

Once you have your piece in a state that you are satisfied with, you can now begin the final steps for preparing the sequence: that is, inserting the loop markers. To tell the converter to loop your track, you need to insert two markers labelled [ and ]: these define the loop start and loop end respectively, and are needed even if you are looping the track in its entirety. Of course, if you don't want the track to loop, you can just skip this step and export it as is. The precise steps for inserting markers are as follows:

  • In REAPER, select the position that you want to insert the marker in at the top and hit Shift+M (or right click that position and select Insert marker). When exporting your MIDI, make sure the box that says Export project markers as MIDI is checked, as is the circle marked markers.
  • In Cubase, you add markers by adding a Marker track. When exporting a MIDI, in the Export Options box, check Export markers (make sure Export resolution is also fixed!!!)

Now you can jump to the insertion section.

The FL Studio Section

The first tutorials for hacking DS music mention FL Studio, and it is for this reason that the vast, vast majority of people doing DS hacks continue to use it. Unfortunately, FL Studio is one of the worst DAWs for working with MIDI because there are several convoluted workarounds you need to perform just to be able to match the capabilities of other DAWs, not even just REAPER and Cubase. Two specific issues arise from using FL Studio MIDIs without any modification: the first is that you cannot embed markers into an exported MIDI (don't ask why you can import them but not export them; several users already have and came to the conclusion that Image-Line is dumb), and the second is that it partitions time signature changes and tempo changes into separate tracks, most unacceptably putting the time signature track first, even if you have none in your project. Both of these issues are bad enough together, but even on their own this means that you will need to post-process your FL Studio MIDIs or they will not convert correctly (the time signature track is especially unnecessary as the DS sound system has no concept of time signatures).

Unfortunately, the issues don't even end with MIDI export: MIDI import is also hilariously trash and a prime reason it's stagnated for so long. Simply put, FL Studio only imports a grand total of 12 continuous controllers, most of which you do not actually need for music production in general, much less for hacking DS music. By default, you will be losing a bunch of crucial data when you import a MIDI and the only way to get it back is manually dragging it back in, at least until someone sits down and finds a way to automate it. And this is just a general tip for using FL in general, but for people collaborating via FL Studio, do not share MIDIs: share project bones or FLP files.

All that being said, FL Studio is still a reasonably popular DAW with its own limited merits. FL does not suffer as much when it comes to changing note resolution - you can just open Project General Settings and change Timebase (PPQ), where 48 is one of the options available in the dropdown. Furthermore, it's one of the few DAWs that simultaneously supports high production stuff and DS stuff at the same time. Since FL Studio has a unique workflow, its users may have a hard time switching to another DAW to follow this tutorial. So rather than discourage FL’s use entirely, we’ll cover it below.

One major benefit to using FL Studio is having access to Fruity LSD, by far one of the simplest ways to apply a soundfont to a track (and the reason it's even relevant in the hacking scene). To add it, open the mixer and select one of the slots; click on it and, in the plugin list, select Fruity LSD. In the window that opens, you can select what port you want to feed the data to: all MIDI channels you want to use this instance for must use the same port. Click the grey folder icon (the one that says Open a new bank when your mouse is over it), and select the .DLS file of your choice. Importing a MIDI will also give you the option to load in an instance of Fruity LSD.

You can also use BASSMIDI if you so choose, especially because it has a few advantages over Fruity LSD (namely the ability to limit polyphony and interpret portamento commands), but, as before, it's just to get an idea: do not use it as an exact point of reference.

Post processing

As stated prior, FL Studio MIDIs require a post processing tool so they convert correctly, even if you don't plan on inserting loop markers. These are some of the tools that can be used to accomplish this:

  • Anvil Studio. By far the most common option by virtue of being the first one to be publicized, you add markers by scrolling to the points at which you want to add them and hitting insert MIDI event -> marker. However, it doesn't so much solve the problem as much as it does circumvent it. As stated prior, time signature changes and tempo changes are shunted to different tracks; however, Anvil Studio cannot open the first track of any MIDI, which in this case just so happens to be the one containing the time signature changes. Therefore, FL Studio MIDIs post processed in Anvil Studio must be exported as MIDI-0 so the tracks can be combined (funny enough, simply converting to and from MIDI-0 in any software also fixes this :p). It also adds some unnecessary junk to your MIDI just to let you know that it was processed in Anvil, so make of that what you will.
    Incidentally, you can just make your music entirely in Anvil and not have to worry about any of this, not even the MIDI-0 part. Unfortunately, good event editing like in other DAWs that doesn't involve placing them down one at a time requires their paid Pro-Mix addon so go figure. Plus changing resolution on a MIDI requires creating a new one and then merging in the old one which works but is a hassle.
  • Awave Studio. A powerful program with a multitude of capabilities, and the best software for this purpose with its ability to clean up MIDIs. When you open a MIDI exported straight from FL in Awave, you will see the time signature change track and the tempo change track labelled Track 01 and Track 02 respectively, and all you have to do is delete Track 01. Now, the tempo change track will be first (don't worry about the name 02; you can see inside the track that the names are assigned automatically), and you can insert your markers as you see fit. The only real drawback is that it will run you about 100 USD, but...get it if you can. It's such a good program, and the devs deserve all the support they can get.
    Since Awave Studio doesn't have a notation editor or a piano roll, you will have to insert markers by locating their exact tick count. You can do this mathematically (i.e. multiplying the number of beats by 48, the number of ticks in a beat, though you have to be mindful to add a specific number for tracks that are slightly off beat), or by locating the precise tick count of events you can find the exact timing of, such as the beginning/end of a note or a CC change. Either way, once you have your numbers, right click the tempo change track, select an event, and hit Insert. Set the tick count to what you need to, change event type to Meta, and Meta type to Marker, then insert the events as needed. Save the resulting MIDI by right clicking on it and hitting Save selected MIDI song as.
  • Sekaiju, probably the best freeware MIDI sequencer and best solution without a price tag. When you import any MIDI that arranges its data in an idiosyncratic fashion, Sekaiju is likely to give a warning (this is the main reason I haven't mentioned it until now). In the case of a MIDI exported straight from FL Studio, it will tell you something along the lines of "time signature changes or tempo changes were found in the second or later track, move these events to the first track?". You want to click Yes, since this is precisely why FL Studio MIDIs don't work right out of the gate. Once it is imported, delete the second track (by clicking in any of its columns and pressing Delete), and to insert the loop markers you right click above the measure counters and hit Insert marker, specifying the exact beats and the text as normal. It might be a little tricky if you have to specify it off the beat, but it will work; just remember that the last number will always be less than or equal to your resolution which should be 48. Afterwards, save your MIDI and you are done.
    Just like Anvil Studio, you can just make your music entirely within Sekaiju, and it outclasses Anvil in every way. Just be sure whenever you make a new MIDI or import one from elsewhere that you go into File>Property and change the resolution to 48, as well as the SMF Format to 1.
  • Cubase and REAPER (lmfao). I know, this seems insipid, but let me humor you for a quick second. Since these two have such good MIDI support, you can practically just drag an FL MIDI in them, delete the first track which will be empty (time signature changes and tempo changes will be embedded into the "header" so to speak), and do exactly what you do to prepare a sequence after composing in those DAWs.

Regardless, once it is processed, you are ready to convert it.

Adding Music to the ROM

Theoretically, once you have your sequence prepped, you should be ready to convert it. Keyword "theoretically", because unfortunately there is currently no manageable way to convert MIDI data to the SSEQ file format. This is the reason for the warning against converting MIDIs directly in Nitro Studio: it currently has its own converter but it's far from perfect. "But what about midi2sseq"? That program is old and was made long before most of the quirks of the DS' sound system were actually documented, and will lead to your MIDIs losing almost every command that isn't a note or a program/volume/panorama change. Efforts have been made to update the program's MIDI class (as well as porting it to Linux), but that will take some time. The python library ndspy is capable of flexibly modifying SSEQ files, but turning a MIDI into one is out of its scope and requires a second library to interpret MIDI commands and relate them to ndspy's SSEQ class (RoadrunnerWMC, the developer of ndspy and a key part of the Newer Super Mario Bros. project, had to make a bunch of miniature python scripts just to get what he needed. Yeah, imagine composing in python.). It also is not viable for batch production as python is locked to single thread performance. Nitro Studio 2 Deluxe has an SMFT editor which allows you to create and modify tracks in plaintext by changing commands one line at a time and yeah I don't think I need to explain why this is impractical and a colossal waste of time.

Currently, the only reliable way to get a MIDI file into an SSEQ file is to use software made by Nintendo. I'm not going to tell you how to get it, or how to use it to convert your sequences, or that you even should, because that depreciates the number of people that can work on a clean room replacement. But once you get an SSEQ sorted out, you're ready to add it to the game.

Open Nitro Studio 2 Deluxe and load in the .SDAT. For replacing an existing track (adding a new one is possible but the details will be with adding new banks and new wave archives which will be in the composing guide), select the sequence you want to replace, then right click so you can hit Replace, then select the .SSEQ file you created. Press File > Save, and your replaced track is now in the .SDAT!

If you are using SwissArmyKnife, CTRMap, or BluRose's file system builder, simply drop the modified .SDAT into your project directory and build your ROM. Otherwise, open your ROM in TinkeDSi, select the .SDAT file, press Change file, and select the .SDAT you just created. Hit Save ROM and give your modified ROM a name. And that's it! Load the modified ROM using a flashcart or TWLMenu to hear how it sounds (do not test on an emulator or within Nitro Studio; the output is inaccurate).

If the sequence does not play at all, you have overloaded the sound heap and need to reduce the size of whatever is in it. While this is usually the fault of the wave archive, an overly large sequence can also cause this to happen. Generally, an .SSEQ file should be around 8 to 18 kilobytes; the absolute maximum depends largely on the wave archive.