Custom Samples on Earthbound


What is a sample? A sample is a piece of sound that can be manipulated; the SNES was one of the first game systems that made use of this feature.
The snes uses a sample compresion system named BRR meaning Bit Rate Reduction, this is what we will be inserting to Earthbound.
Tools we will be needing are here, be sure to download them!
OpenMPT is here

Ripping samples

If you already know how to do this you can skip this part of the tutorial.
First of all, get a .SPC of the song where your sample is, then look for the source of the sample. Most SPC players should have this feature.
Sample SRC
Use Split700 with your .SPC, after you do this you will get alot of .BRR files named like this:
SRC is the Sample Slot or Sample Source. For example, if your sample was located on the slot 09, then you are looking for SPCName_09. Now keep that .BRR and then do the same thing but with the sample you want to replace
Now grab both samples to brr2wav.exe and the program will export a .WAV of your samples, then open both .WAV with OpenMPT

Adapting Samples

Your sample must be the same size as the sample you are replacing, if it isn't then tweak it until it is the same size.
A way is re-record it while making it play a really long note, then open the record you did with OpenMPT again. I believe windows has a program to record the sound of your computer, if it doesn't then a quick google could be enough. Also to make it play a long note click the musical note icon above.
(Skip this part if your sample is unlooped (A drum for example))Now for the tricky part, since you want your sample to be looped, you need to find a good sounding loop point that IS divisible by 16, so start playing with your sample until you get a fine sounding loop point that is divisible by 16. If your loop point is still kinda clicky then you can use this button above at the right side: OpenMPT Crossfade
Also before exporting, replace the first 14 sound waves (these can be named samples too) with silence. Below everything at the right side there is something named Cursor with some numbers on it, that marks at what sound wave your cursor is.
To do this click the pencil icon above your sample, this lets you draw waves, to draw silence just click on the middle of the wave, where the horizontal white line is.
The beginning of your sample now should look like this:
14 samples of silence
Now after you finished your sample export it using this floppy disk:
Floppy Disk
The above one doesn't exports your .WAV with its loop and also adds alot of silence at the end of it.

Inserting your sample

Now grab your .WAV and put it on the folder where you have snesbrr.exe, now make a copy of CMD and put it on the same folder too and then open it and write this:
Now open the .BRR exported with an hex editor and make sure the first 9 bytes are this:
02 00 00 00 00 00 00 00 00
If the 02 is instead a C0 or something else just change it to a 02 and you are ready to go. (If it is a unlooped sample it should be 00 00 00 00 00 00 00 00 00)
Now open with a hex editor the .BRR of the sample you want to replace, delete the first two bytes and then search for the remaining bytes on your Earthbound ROM. When you find the sample you want to replace on the ROM, replace it with your own sample and done.
But.... what about the loop? open your rom with EBMusEd, select the song where your sample is, go to the instruments tab and look for this:
Sample Pointers
Those are the sample pointers, for example if you replaced sample 1E then you might change its loop point which its pointer is B3B6
To find the pointers we need to search for those values, but not in a regular way. The SNES is a Little Endian system, so every pointer instead of being XXYY they are YYXX, so if we want to find A840 B3B6 we need to search it this way: 40A8 B6B3.
When you find it you will see something like this: 40 A8 B6 B3, we want to change B6 B3 (which would be B3 B6 in a normal way) but how? Grab a calculator and your sample loop point and use the next formula with it:
Then convert the result it gave to you to hexadecimal and then do this:
In the case of the sample I'm replacing it would be something like:
Now apply the Little Endian system to the value you got (XX YY -> YY XX) and then replace B6 B3 with your value and you are done!

Tutorial by Pinci (AKA Mrpinci19)
It is possible to insert samples with different sizes too, but you will need to change EVERY pointer data that comes after your sample and this is pretty impossible to do manually without a tool, so this could be a pretty nice feature for EBMusEd.
If you have any questions or you didn't understand something be sure to ask and I'll help you!