Ok, brief explanation on how to do it, but then you're on your own. Create a file that is a 1 bar loop. Convert it to 8 bit unsigned mono and 32768 samples long. Hint on the last part, making it exactly 1 second long and then converting it to 32678 Hz sample rate should at least get you close. You might need to manually trim or add a couple of samples with a hex editor. If you're adding samples, repeat the last sample value in the file or so. (Who ever said this was supposed to easy?)
Run the following Python script. It will convert the file you've created to the 4-bit format the Gameboy so much craves and create a new ROM with your sample.
def fourbit(x):
return ord(x) & 0xf0
def fatconv(fn):
f = open(fn + ".raw", "rb")
x = f.read()
f.close()
if len(x) != 32768:
print "File should be 32768 samples long, yo. 8-bit unsigned mono is where it's at, dawg. Raw with no header. (That's what bshe said.)"
return
g = open("amenizer.gb", "rb")
gb = g.read(16384)
g.close()
y=map(fourbit,x)
y=zip(y[0::2],y[1::2])
#f = open(fn + "-conv.bin", "wb")
g = open(fn + "-rom.gb", "wb")
g.write(gb)
for i in y:
#f.write(chr(i[0] | i[1]>>4))
g.write(chr(i[0] | i[1]>>4))
f.close()
fatconv("filenamehere")
However, the final version of this application, when it comes out, will surely blow your minds. Just a prediction.