DSHack

Archive Generated December 23rd, 2018
[Tutorial] How to edit SBNK files
Author Posted on 2017/02/17
#2974
Kitty Remilya Ambiance What you're going to use:

MKDSCM 3 or EFE
Kiwi DS
HxD or any other Hex Editor
DS Sound Studio

Step 1: Load your ROM with MKDSCM or EFE, and extract your SDAT file.


Step 2: Extract your SDAT file to somewhere on your computer.


Step 3: Load your SDAT file with Kiwi DS and extract it. The extracted file should appear in the same directory as the SDAT file.


Step 4: Load your SBNK file in the hex editor:


Step 5: Edit the values accordingly to these:


INFO: Attack Rate ranges from 00 to 7F. The value 7F will make the instrument play instantly. The lower the value, the instrument will start quieter and then become the normal volume. Decay rate ranges from 00 to 7F. The value 7F will play the instrument continously with normal volume, and a lower value will make the instrument start playing normally then continue quieter. Sustain rate ranges from 00 to 7F. It's a lot similar to decay rate. Release rate ranges from 00 to 7F. The lower the value, the more the instrument will be echoed. The value 7F will have no echo. Pan ranges from 00 to 7F. Lower value plays the instrument on the left, 40 will play the instrument centered and 7F will make the instrument play on the right. After editing, you can preview how your custom instrument sounds like using DS Sound Studio.

Step 6: Load your SDAT file with DS Sound Studio:


Step 7: Right click on your SDAT file and replace it with the new one:


Step 8: Now save your SDAT file and use MKDSCM 3 or EFE to put your new SDAT file in your ROM:


While I used MKDSCM 3, EFE would be a better choice for games other than MKDS.
I applied this tutorial for MKDS but it should work in other games as well, and as I said before, use EFE for other games' SDAT files.

Hope this helps!

UPDATE - December 9, 2017

I've just found a way to add new instruments to SBNK. To do so, when you dumped the SBNK file with Kiwi DS and loaded the SBNK file with an hex editor, just follow this procedure:


This is for single SWAV files, For multiple SWAV files, you can replace the three bytes "01 XX XX" shown in the screenshot above, with "11 XX XX". And for adding the details, you can add it like that:

S1 S2 S3 S4 S5 S6 S7 S8 YY YY 01 02 03 04 05 06 07 08 09 10 XX XX

S1 to S8 are the SWAV IDs, you can use up to 8 SWAVs. YY YY is 01 00. 01 to 10 are the instrument info shown in the screenshot, and you can repeat them with a different info. XX's are always 00. For example:

40 7F 00 00 00 00 00 00 01 00 04 00 01 00 3C 7F 7F 7F 78 40 06 00 00 00 3C 7F 7F 7F 78 40 00 00

In the example above, 40 is the pitch where the SWAV changes. In pitches 0 to 40, the SWAV 04 from the SWAR 01 plays (italicized here). In the pitches above 40, the SWAV 06 from SWAR 00 plays (underlined here).

Here's a test video:

When looking at to MKDS Beta SSEQ files by converting them to MIDI first, I've found out that the N64 Moo Moo Farm music had an unused track. It's MIDI instrument was "Music Box", which is a synth bass used in the musics of Shroom Ridge, SEQ_CIRCUIT2, final Figure-8/Mario Circuit, etc. Likely a leftover from an earlier version of the music.

UPDATE - January 20, 2018

HOW TO ADD/REMOVE DRUMS TO THE DRUM KIT

The three bytes starting from 0x238 is usually the pointer that tells where the drum kit is. i.e. For SBNK 73, 0x238 to 0x23A (three bytes) is 10 50 02, which tells that the drum kit starts from 0x250. There the first two bytes is the region. It tells which key pitches will be used, any pitch outside these boundaries are slient. The rest are the drum instruments. You can get more info by dumping the SBNK file with Kiwi DS.

To add the missing drums, simply add the instruments (ex. 01 00 05 00 01 00 3C 7F 7F 7F 78 40, which makes 12 bytes), next to the last drum instrument before the next instrument pointer. After adding the new drums, change the second byte of the region (mentioned above) to a higher value, i.e. if it's "20 50", and you added two drums, change it to "20 52". Then, for the instrument pointers that are at the beginning of the file, since drums start from 0x250 (can be different for other SBNKs), anything after 0x250 also needs to be increased. For example, since we've added 2 instruments, one takes up 12 bytes, 12 is C in the hex, two instruments = 24 bytes, therefore being 18 in the hex, so if an instrument pointer is "11 12 05", it's going to be "11 2A 05". Apply the same to the filesize, too. Filesizes are two bytes in each: 0x8 and 0x14.

Removing is basically the same as adding, but in reverse.
Author Posted on 2017/02/17
#2975
SGC Yellow This is an excellently made tutorial, it's nice, and clean looking, and it has nice info, I'm impressed, excellent work!

Thank you for making this.
Author Posted on 2017/02/17
#2976
Rover Will this replace instruments to?
Author Posted on 2017/02/17
#2977
SGC Yellow No, it will only allow you to edit which instruments an SBNK uses.
Author Posted on 2017/12/10
#3653
Kitty Remilya Ambiance First post updated, now showing how to add new instruments to a SBNK file.
Author Posted on 2017/12/10
#3654
knms360 Can CrystalTile 2 also edit values?
Author Posted on 2017/12/10
#3655
Kitty Remilya Ambiance Yes. You can do it with any Hex Editor.
Author Posted on 2018/03/17
#3781
User 570 Hello, i like this tutorial, but when i edit the .SBNK file and insert them into the SDAT, then the instruments didn't work or it worked, but only a part from it. I don´t know what i have make wrong. I'm using the german version of Pokémon White 2 and i know so far, that all NDS games are using the same .SBNK structure (for example Mario Kart DS -> Pokémon White 2). Or is it wrong? Can someone help me again? Thanks! ;)
Best regards from Germany
Author Posted on 2018/03/18
#3784
Kitty Remilya Ambiance Did you edit the Attack/Decay/Sustain/Release rates as well as notes & pan? Or you might be pointing to the wrong instrument number (SWAR or SWAV IDs).

And yes all SBNKs are the same. Also, posting screenshots and/or videos related to the problem would be more helpful.
Author Posted on 2018/03/18
#3786
User 570 I will make this tomorrow again, because I've deleted the old files. But when it is wrong again, then I will make screenshots and send them in here!
Author Posted on 2018/03/19
#3788
User 570 Hey, it's me again...

So, i have a new question for you about the SBNKs. Can i edit the SBNK, so that the game use 4 SWARs, but only the instruments, that I'm using (for example: Instrument 96 (Pad 8) -> SWAV 26 in SWAR 2)? Because I'm not using all Instruments and I wouldn't create a new SWAR file, because when I'm making a new SWAR file, then the instruments weren't recognized by the game or the game is crashing, when the track appears.



I have all the instruments marked in grey, that I would using for a track in my game:





Author Posted on 2018/03/20
#3789
Kitty Remilya Ambiance You can do that in MKDS Course Modifier. Load your SDAT, click a SBNK file and on the right side, you can edit the SWAR values. Then save your SDAT.
And from the SBNK hex editing tutorial:

XX 00 YY 00

XX is the SWAV number and YY is the SWAR number. SWAR number ranges from 0-3, not 1-4.
Author Posted on 2018/03/20
#3790
User 570 Yeah, sorry, i meant that with SWAR 0-3, I've scribed this in one picture. But thanks for help! ^^
Author Posted on 2018/03/21
#3791
User 570 So, i have made a new SBNK file. This time it works, but only instrument 0-63 are present. Is there a limit up to 64 instruments? Because the instruments 0-63 are all working but the instruments 94 and 95 are missing. Overall, they are 66 instruments. Something known about this?
Author Posted on 2018/03/21
#3792
User 570 So, i found out, that there is a limit up to 64 instruments! The game can use (only) 64 Instruments per SBNK file, which means Instrument 0-63 and when the limit is reached, then the game don't show up the other above instrument 64. Maybe yout could put this additionally into your guide, @Kitty Ambiance!
Author Posted on 2018/03/22
#3793
Kitty Remilya Ambiance Probably the game doesn't support SBNKs above 64 instruments.
Author Posted on 2018/03/22
#3794
User 570 I have seen this in DS Sound Studio, MKDSCM and in the game, and nowhere was more than 64 instruments, so I think, it is a Nintendo DS limit, not only the game!
Author Posted on 2018/03/23
#3795
Kitty Remilya Ambiance But in MKDS SBNK 000 there was more than 64 instruments.
Author Posted on 2018/03/23
#3796
User 570 Then is it an error in the programs? I have seen this, because I have tested it, but there are only instrument 0-63 in the list, too! And when I open the SBNK in HxD, then there are more then 64 instruments. Then should it be an programm error or whatever....
Author Posted on 2018/03/24
#3797
Kitty Remilya Ambiance Probably an error in the SBNK. Dump your edited SBNK with Kiwi DS to check.
Author Posted on 2018/03/27
#3798
User 570 Nah, this isn't so important to me. The SBNK works for me in the Emulator and on my R4i, so I am happy. But I'm also happy, that you've maked this thread. THANKS!