+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  NES Music Hacking
Pages: [1] 2
Author Topic: NES Music Hacking  (Read 2 times)
Roth
Guest
« on: March 31, 2008, 06:16:04 am »

Man, this is hilarious! I'm working on a project right now, and being new to all of the ROM hacking stuff, I get really excited when I discover something.

After finding the palettes in the game, I decided I would check out the music. I grabbed the NSF and started fiddling around with it a bit. After I deciphered what some of it did, I noticed something. I can actually SEE the notes in the hex code O_o For instance, one of the tracks has a triplet feel to it, and there is a string of those right in a row that you can tell are the notes! I saw that portion and manipulated it a bit, and sure enough, it was! It's pretty crazy haha There is another track where the notes are staccato, and there is an extra byte in between them, but you can still look at it and know what is going on.

Anyway, I was just wondering if anyone else had a similar experience when they first tried something of this nature? It's like some sort of off the wall epiphany : )
DarknessSavior
Guest
« Reply #1 on: March 31, 2008, 07:50:48 am »

Never tried it myself. Care to post a screenshot of what you're talking about? It'd be kinda interesting if they wrote the code so it looks like whatever the musical passage actually is. =D

~DS
McKnight
Guest
« Reply #2 on: March 31, 2008, 09:16:31 am »

Now that you've figured out which bytes apply to which notes, try exporting them and see if you can play it on something like Windows Media Player. 

I'd like to manipulate (i.e. replace) the voice clips in some game, and if that method works, it might explain a relatively easy way to change *any* kind of audio data.

Tell me if it works, okay?
Silas
Guest
« Reply #3 on: March 31, 2008, 09:24:58 am »

I love the idea of new musics on hacks. Dr. Floppy said me that Music Hacking on NES is not much worked.
Specifically I would Like to put new musics to my SMB3 Hack, like for example Mario Land 2 musics.
BRPXQZME
Guest
« Reply #4 on: March 31, 2008, 09:30:46 am »

What Roth is saying here is that sometimes things are so simple, you know what they are just by looking, and that that’s neat (and don’t get me wrong, it’s good when you can see that kind of thing). It’s not about changing audio data so much as changing musical data. On a system like the NES where the music is usually synthesized note-for-note, this is possible to do. With voice clips, this is entirely different, unless said voice clips correspond to notes or something.

That being said, music has never been hacked much, no, but every NSF file there is is essentially the game’s music-playing code and its musical data with the rest of the ROM cut out, so if you want to hack the music in a game, you’d do well to check the/an NSF for that game, if one exists. (with other systems, it’s usually not so clean-cut, but you can surely change the music with enough investigation).
Roth
Guest
« Reply #5 on: March 31, 2008, 01:26:41 pm »

Quote from: DarknessSavior on March 31, 2008, 07:50:48 am
Never tried it myself. Care to post a screenshot of what you're talking about? It'd be kinda interesting if they wrote the code so it looks like whatever the musical passage actually is. =D

~DS

Sure, I could post a screenshot, but at this point I am running late for an appointment. I'm hoping it won't take too long though, so hopefully I can get that up soonly!
Hamtaro126
Guest
« Reply #6 on: March 31, 2008, 01:42:29 pm »

Quote from: Roth on March 31, 2008, 06:16:04 am
Man, this is hilarious! I'm working on a project right now, and being new to all of the ROM hacking stuff, I get really excited when I discover something.

After finding the palettes in the game, I decided I would check out the music. I grabbed the NSF and started fiddling around with it a bit. After I deciphered what some of it did, I noticed something. I can actually SEE the notes in the hex code O_o For instance, one of the tracks has a triplet feel to it, and there is a string of those right in a row that you can tell are the notes! I saw that portion and manipulated it a bit, and sure enough, it was! It's pretty crazy haha There is another track where the notes are staccato, and there is an extra byte in between them, but you can still look at it and know what is going on.

Anyway, I was just wondering if anyone else had a similar experience when they first tried something of this nature? It's like some sort of off the wall epiphany : )

Good Job, You are better than me in figuring out music.

Because I can never figure out how the notes are made, I know the Kemco NSF format (used in Kid Klown/Mickey 3, Crazy castle 1 and 2 NES/GB and Others) But cannot figure out the notes. I only know the pointers and how it was implemented (in NSF code, Could not find the JSR in the 2a03 code. like in SMB2.)

Maybe you could teach me once you have the time, Maybe you used a (Music) MODule tracker (Such as Modplug) to do this stuff.
Roth
Guest
« Reply #7 on: March 31, 2008, 03:32:19 pm »

@Hamtaro126
Your username looks VERY familiar. Have I seen you around some other NES discussion forums by chance?

Anyway, with this I have just used a process of elimination. I can't remember which doc I had read before, but there was something that said to throw some 00's in a spot, see what's affected, and go from there. I tried that, and eventually found a few interesting things. The process is VERY slow at first, but once I figured out one thing, it has been like an avalanche of everything starting to come together.

Here is what I was talking about with the triplet feel square track that I found:



Now, the highlighted area there is the 1 + a 2 + a 3 + a 4 + a (how you count triplets). The lower nybble of each of those represents the note. The upper nybble depicts what the octave is. If you notice, right before that highlighted string is a 02. This states for that section to loop twice. I'm still figuring out what the f4 before that, and the f5 after that is, but I have a feeling it is: f=tempo, 4=note length/type. I haven't tested on that part yet, but I am thinking that because of something else I discovered:



The b5 in the highlighted area does just that. b=tempo, 5=note(s) length/type. Once again, the 24s and 23s are set up in octave/note. Now, 7c is a rest for the duration of what the 24s and 23s are. Right now, that 5 (in b5) means for a quarter note pulse. So the track is going to be quiet for that duration where 7c is placed. Which means there is a great deal of flexibility for making the tune different there, as I can set it to b1 giving it a staccato 16th note pulse, even with the rests in between. If I add octave/note information in place of the 7c, it will give me a 32nd note pulse, but of course taking out the staccato since the rests aren't there anymore. It's really pretty awesome!

The last thing that I have figured out so far is where a song starts:



I'm still trying to figure out the in-between stuff, but 00 denotes a square, 01 is the other square, 02 is the triangle, and 03 is the noise channel.

There's still alot of things I have to uncover to figure out the entire music engine in this game, but as I said, there's a snowball effect happening right now where I am figuring things out rather quickly after the first couple of initial discoveries : )

Anyway, that is just some food for thought for people that might be at the point I am at in ROM hacking (read: newbie) I hope all of that makes sense. I know music engines vary, but this one seems pretty simple so far. I plan on making a doc of this when I am done, because, well, why not? haha Anyway, yeah, the music side of this project is going to be hella fun to mess with!
DarknessSavior
Guest
« Reply #8 on: March 31, 2008, 03:49:42 pm »

That is quite interesting.

And for a newbie, you certainly did find out an awful lot. I'm quite impressed. Especially since I'm a musician.  :thumbsup:

~DS
Hamtaro126
Guest
« Reply #9 on: March 31, 2008, 05:00:45 pm »

Quote from: Roth on March 31, 2008, 03:32:19 pm
@Hamtaro126
Your username looks VERY familiar. Have I seen you around some other NES discussion forums by chance?

Anyway, with this I have just used a process of elimination. I can't remember which doc I had read before, but there was something that said to throw some 00's in a spot, see what's affected, and go from there. I tried that, and eventually found a few interesting things. The process is VERY slow at first, but once I figured out one thing, it has been like an avalanche of everything starting to come together.

Here is what I was talking about with the triplet feel square track that I found:



Now, the highlighted area there is the 1 + a 2 + a 3 + a 4 + a (how you count triplets). The lower nybble of each of those represents the note. The upper nybble depicts what the octave is. If you notice, right before that highlighted string is a 02. This states for that section to loop twice. I'm still figuring out what the f4 before that, and the f5 after that is, but I have a feeling it is: f=tempo, 4=note length/type. I haven't tested on that part yet, but I am thinking that because of something else I discovered:



The b5 in the highlighted area does just that. b=tempo, 5=note(s) length/type. Once again, the 24s and 23s are set up in octave/note. Now, 7c is a rest for the duration of what the 24s and 23s are. Right now, that 5 (in b5) means for a quarter note pulse. So the track is going to be quiet for that duration where 7c is placed. Which means there is a great deal of flexibility for making the tune different there, as I can set it to b1 giving it a staccato 16th note pulse, even with the rests in between. If I add octave/note information in place of the 7c, it will give me a 32nd note pulse, but of course taking out the staccato since the rests aren't there anymore. It's really pretty awesome!

The last thing that I have figured out so far is where a song starts:



I'm still trying to figure out the in-between stuff, but 00 denotes a square, 01 is the other square, 02 is the triangle, and 03 is the noise channel.

There's still alot of things I have to uncover to figure out the entire music engine in this game, but as I said, there's a snowball effect happening right now where I am figuring things out rather quickly after the first couple of initial discoveries : )

Anyway, that is just some food for thought for people that might be at the point I am at in ROM hacking (read: newbie) I hope all of that makes sense. I know music engines vary, but this one seems pretty simple so far. I plan on making a doc of this when I am done, because, well, why not? haha Anyway, yeah, the music side of this project is going to be hella fun to mess with!

@Roth - Yes, I am in NESDEV, Acmlm Board 2 (Acmlm.Kafuka.org) and also in atariage under the alias ''AtariHacker''

And About the NSF: What game did the engine came from? I am looking on hacking it too!
Sliver X
Guest
« Reply #10 on: March 31, 2008, 05:02:25 pm »

I think I have a little bit of experience to speak from on this subject...

Quote from: Roth on March 31, 2008, 06:16:04 am
Man, this is hilarious! I'm working on a project right now, and being new to all of the ROM hacking stuff, I get really excited when I discover something.

After finding the palettes in the game, I decided I would check out the music. I grabbed the NSF and started fiddling around with it a bit. After I deciphered what some of it did, I noticed something. I can actually SEE the notes in the hex code O_o For instance, one of the tracks has a triplet feel to it, and there is a string of those right in a row that you can tell are the notes! I saw that portion and manipulated it a bit, and sure enough, it was! It's pretty crazy haha There is another track where the notes are staccato, and there is an extra byte in between them, but you can still look at it and know what is going on.

Anyway, I was just wondering if anyone else had a similar experience when they first tried something of this nature? It's like some sort of off the wall epiphany : )

Yes, this is possible if the game uses a straightforward data schema. However, many games are not so nice to work with (e.g. SMB, Lolo). It all depends on how the driver is written. Hell, some of the early games like Donkey Kong are set up to where a full octave isn't even available if certain notes are never used in the songs.

Quote from: McKnight on March 31, 2008, 09:16:31 am
Now that you've figured out which bytes apply to which notes, try exporting them and see if you can play it on something like Windows Media Player. 

I'd like to manipulate (i.e. replace) the voice clips in some game, and if that method works, it might explain a relatively easy way to change *any* kind of audio data.

Tell me if it works, okay?

You have no idea what you're talking about, and this doesn't surprise me in the least after your PC-FX threads. The music data, is just that, the DATA, and is set up in basically an arbitrary form. There is also the actual engine/driver itself that reads all that and actually makes sounds with it.

Also note that the NES uses PSG for almost everything (Except DPCM samples), so this is totally unrelated to crap like voice clips. There are more ways for music to be stored and played on the old consoles than you can imagine: It's all dependent on how the coders wrote the driver for it.

You could, I guess, dump an NSF with NSF2MID to see what the note values/durations are, but this will amount to precisely dick in understanding how the music is stored/read in ROM.

Quote from: Hamtaro126 on March 31, 2008, 01:42:29 pm
Good Job, You are better than me in figuring out music.

Because I can never figure out how the notes are made, I know the Kemco NSF format (used in Kid Klown/Mickey 3, Crazy castle 1 and 2 NES/GB and Others) But cannot figure out the notes. I only know the pointers and how it was implemented (in NSF code, Could not find the JSR in the 2a03 code. like in SMB2.)

Maybe you could teach me once you have the time, Maybe you used a (Music) MODule tracker (Such as Modplug) to do this stuff.

If you "know" the Kemco data format, yet don't understand the notes, you don't understand the Kemco data format. Sorry. And no, this has nothing to do with MOD format whatsoever.

But yeah, nice work Roth: Very few people even attempt to hack music, so this is nice to see.




Hamtaro126
Guest
« Reply #11 on: March 31, 2008, 05:07:32 pm »

Quote from: Sliver X on March 31, 2008, 05:02:25 pm
If you "know" the Kemco data format, yet don't understand the notes, you don't understand the Kemco data format. Sorry. And no, this has nothing to do with MOD format whatsoever.

But yeah, nice work Roth: Very few people even attempt to hack music, so this is nice to see.

What I mean is I know how to switch Kid Klown's NSF engine into Mickey 3's engine, Just could not edit the notes, Because I do not know the MIDI/MOD note equivlents.
Sliver X
Guest
« Reply #12 on: March 31, 2008, 05:14:53 pm »

Quote from: Hamtaro126 on March 31, 2008, 05:07:32 pm
What I mean is I know how to switch Kid Klown's NSF engine into Mickey 3's engine, Just could not edit the notes, Because I do not know the MIDI/MOD note equivlents.

THE NES IS NOT MOD, MIDI OR ANY OTHER PC MUSIC FORMAT. Each game uses a unique format created by the person who made the music driver. There are very rare exceptions, where a company will recycle an engine for later games (Konami and Capcom did this a lot). However, even then there are usually differences.

For example, Gradius seems to use a first-gen Konami music driver. Castlevania's is built upon this, but adds support for Noise percussion. CV2 is further extrapolated by adding DPCM drum samples. There are also other slight differences between them, which makes it impossible to just cut and paste data from an earlier game into a later one without a lot of manual tweaking.

And please, explain to me what you mean by "I know how to switch Kid Klown's NSF engine into Mickey 3's engine".
Roth
Guest
« Reply #13 on: March 31, 2008, 05:23:10 pm »

Quote from: Hamtaro126 on March 31, 2008, 05:00:45 pm
@Roth - Yes, I am in NESDEV, Acmlm Board 2 (Acmlm.Kafuka.org) and also in atariage under the alias ''AtariHacker''

And About the NSF: What game did the engine came from? I am looking on hacking it too!

NESDev! That's it haha I knew I had seen your name before! Nice to see a familiar face : )

As for the game itself, it may sound selfish, but I'd really like to keep that under wraps right now. I don't believe it has been made into a hack before, though I may be wrong. Since I did that Castlevania Memoirs "hack", I really want to do something that involves getting into the ROM itself, and not just using an editor. So, it's like I want this hack to be something special for myself, since it is my first tried and true attempt I have ever made. Like I said though, I will release a doc about it when I am done ; ) Sorry if this leaves a bad taste in anyone's mouth.

Quote from: Sliver X on March 31, 2008, 05:02:25 pm
Yes, this is possible if the game uses a straightforward data schema. However, many games are not so nice to work with (e.g. SMB, Lolo). It all depends on how the driver is written. Hell, some of the early games like Donkey Kong are set up to where a full octave isn't even available if certain notes are never used in the songs.

Yeah, I definitely lucked out on this I think. There aren't that many tunes in the game either, so it really helps in that regard too. Though I'm very inexperienced with this kind of thing, I'd like to think I would be up to the task of figuring out more NES music engines that might be a tad more complex. I haven't looked at any of them yet, but I'd like to see how Tim Follin's engine worked in his games; namely Target: Renegade and Silver Surfer. I can't let myself be distracted from this project right now though! hehe

Thanks for all the cool comments from everyone, it's pretty motivational! : D
optomon
Guest
« Reply #14 on: March 31, 2008, 05:43:12 pm »

Friday the 13th.  :thumbsup:

Another important upgrade in the Konami engine from Gradius to Castlevania to Castlevania 2 is that of the use of dynamics. I don't even think Gradius uses dynamics, Castlevania used it mostly between motifs and phrases, and highly advanced dynamics in CV2 put it ahead of almost every NES soundtrack in terms of sound quality. Tim Follin is also up there in terms of quality, it would be interesting to see exactly what he does from a technical standpoint.
Pages: [1] 2  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC