Implementing Original Music for Nintendo & Sega Game Dev

Discuss NSF files, FamiTracker, MML tools, or anything else related to NES music.

Moderator: Moderators

User avatar
Kasumi
Posts: 1293
Joined: Wed Apr 02, 2008 2:09 pm

Re: Implementing Original Music for Nintendo & Sega Game Dev

Post by Kasumi »

So that means that I could essentially write a 20-minute prog rock magnum opus for the 2A03 while adhering technically to the limitations of FamiTone2, GGSound, or whatever format the dev requires for his game and I'll have no problems?
What that means is that it's impossible to answer generally. If you really, really, really want a general metric, whatever song you want after exporting to whatever format should probably be less than 8KB. The problem with this answer is that it's not strictly impossible to have a larger song. And most devs will probably not want a single song to be that large, but I don't have a number in my head of where a better line is. It depends how much the developer values music. The Super Bat Puncher music is very large for just a few songs if I recall correctly.

Note that this 8KB limitation I'm throwing out randomly only deals with a single song. All of the data for all of your songs could be like 256 KB, and that generally wouldn't be a problem for playback specifically, but it would be taking up a lot of space that the dev might want to use for other things.

Which... is again why this sort of thing is impossible to answer generally.
If the game is being created with the purpose of being played strictly on emulators, then that would mean I have free reign over the length and complexity
Okay, let me put it like this: You only get "free reign" through an emulator if you know how to program, because if nothing exists that gives you the space/features you need, you have to add it to the emulator yourself. Just like to get "free reign" on the hardware itself, you need to be able to design/build the PCB that will make it possible. As Tepples said, it's possible to get MP3 quality playback but at that level what's the point of going with NES? A lot feel the same about expansion audio. I don't think there's a commercial USA release that uses expansion audio. If there are, they don't make up more than 1% of the overall library.

But the only universal truth is that it's up to the dev. If they both know how to and want to support whatever, you can do whatever. If they can't or don't want to, you can't. So you must ask the dev. Yes. Every time. Unless you are already capable or are willing to learn to build music engines/whatever yourself to help them.
I wonder if this additional hardware is easy/cheap to manufacture for homebrews?
The answer is no. And honestly, I'm not even sure it's well emulated yet. If you care about your stuff being played on real hardware, you should expect not to use any expansion sounds.

Edit: Hmmm... infiniteneslives is at least working on some boards that supported expanded sound. So maybe you can get there at some point.
I assume that's where the "speed" of FamiTone, GGSound, etc. comes into play, right?
It's impossible to answer generally. Certain effects (if they're supported), certain instruments might be CPU intensive. The speed of the song itself could matter too, but... impossible to answer generally.
Is this not even possible (or realistic) on emulation-only homebrew dev?
If you only care about emulation, there's still another problem. As far as I know there doesn't really exist good freely available music engines for expansion sound. (Maybe the famitracker driver is one? But that's not particularly good for games.) I could be wrong on this point and there's something that's just as easy to use for them as Famitone2. But if there's not, what this means is that whoever you pair with has to build a thing just to support your music. And this also locks them into whatever mapper the expansion sound is paired with (which affects how programming will go for many things beyond the music.), unless they also want to build a custom thing that supports the music of the expansion sound and also other things they want.

I'd say it's not realistic to expect it for homebrew, no. Maybe for those MMC5 conversion hacks, I don't know enough about them.
I heard that NES data could be compressed from a Reddit post I made asking why there hasn't been a decent ROM hack of Metal Gear yet. There wasn't a lot of info spilt on NES compression, though.
There's really no such thing as NES specific compression. NES has a CPU like any other. It's limited by RAM and addressing space, but in theory it can do the same things as a modern computer could. Just very slowly. The issue with compression on NES that whatever you want to compress must be able to fit in RAM decompressed, and be able to be decompressed relatively quickly on the weak CPU.

What the reddit post could mean is that Metal Gear uses a lot a custom compression formats that haven't been reverse engineered yet.

Edit: But ROM hacking (outside of certain graphical things) isn't easy in general. You are editing code you did not write, with no documentation, after it has been assembled. The reason hacks are common for certain games is the hard work has already been done, usually due in part to extreme popularity. Super Mario Bros. has a full disassembly, which is like having documented source code. But... someone had to actually go and figure everything out for that to exist. Same for GUI level editors and things. That's the result of a person spending hours with debuggers trying to figure out what pieces of RAM represented. I would assume no one has done the hard work for Metal Gear yet.

Just as a random aside DPCM is not too much fun to support. Even though, yes, Famitone2 does support it, the data for it has to be in a specific place in memory on NES which makes certain things hard depending on what hardware setup a given game uses. My choice to support it is actually causing a lot of problems in a mini project I'm working on.

Say I gave you a famitone2 test package. You make your song, export it, double click a thing and you'll have a ROM that will play whatever music you gave (or give you errors if you didn't obey the limitations somehow). Is that interesting to you? This could at least give you an idea of how large certain songs would be in Famitone2.
Last edited by Kasumi on Sun Jan 31, 2016 11:36 am, edited 2 times in total.
zzo38
Posts: 1096
Joined: Mon Feb 07, 2011 12:46 pm

Re: Implementing Original Music for Nintendo & Sega Game Dev

Post by zzo38 »

tepples wrote:On emulation-only homebrew dev, you can in theory just use MP3 music, which simulates an MP3 player being soldered to a Famicom PCB. Heck, on emulation-only homebrew dev, you can make games at PS2 or higher graphical complexity, as Java, C#, and asm.js programs are "emulated" in a way.
In my opinion, that is a bit silly. I can describe my own opinions about emulation-only homebrew dev, in order to contrast.

One thing about making the .NES format is that you can then use it on many different emulators, including on different devices. Some might not support the mapper in use, although it may also be possible that future versions of that emulator will implement it. Most emulators do support expansion audio as far as I know.

Even if you never intend the game to be use outside of emulator, it should still be design to work on real hardware too. There are advantages of such: working better on future emulators, and that in case someone does want to use it on a real hardware, they can do that too (although if you need to, you can use a complicated mapper, which would make it more difficult to use on a real hardware but still possible). I like to think of it as, the program is written for "Famicom VM", and the different implementations of Famicom VM including software implementations (emulators) and hardware implementations (such as NES and Famicom hardware).

While you can use MP3 music, I do not really suggest it (although there are some work-in-progress specification to allow formats such as Vorbis to be provided as a purely optional alternative to 2A03 music on emulators that can support them; a similar work-in-progress specification exists for graphics too)

However, of course if you do not want to write your game for "Famicom VM", you are not even required to do so, as tepples has mentioned. You can use Java or .NET or whatever if that is what you want your game to be, although then you are not writing a NES/Famicom game.
Last edited by zzo38 on Sun Jan 31, 2016 12:52 pm, edited 1 time in total.
(Free Hero Mesh - FOSS puzzle game engine)
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Implementing Original Music for Nintendo & Sega Game Dev

Post by tepples »

Except the likes of Bananmos used to always drill in us that the Java or .NET VM will get the job done more easily than the Famicom VM.

Blast from the past: Threat of violence, hopefully in jest
User avatar
AlexE
Posts: 46
Joined: Fri Jan 29, 2016 3:16 pm
Location: York, PA
Contact:

Re: Implementing Original Music for Nintendo & Sega Game Dev

Post by AlexE »

tepples wrote:
AlexE wrote:So that means that I could essentially write a 20-minute prog rock magnum opus for the 2A03 while adhering technically to the limitations of FamiTone2, GGSound, or whatever format the dev requires for his game and I'll have no problems?

Yes, if there's enough space. But in practice, a 20-minute composition would probably need to be synchronized with the game action, and that more than likely would mean auto-scrolling and no "go back to save point when you die": either respawn in place or restart the whole thing. Unless, that is, the 20-minute composition itself has restart points.

Maybe a 2D sidescrolling Gradius-like game where it is just one very, very long level would work for something like that? That'd be pretty neat.
tepples wrote:
AlexE wrote:(I've heard of the MMC5 being used in The Legend of Zelda: Adventure of Link, a freakin' rad ROM hack of The Legend of Zelda. I tried using it on my Everdrive N8, but it would load because the cartridge hardware didn't have the right "mappers".)
If you mean Zelda II: The Adventure of Link, that's nowhere near MMC5. It's a garden-variety MMC1 according to NesCartDB.
Nah, I mean the ROM hack Legend of Link! Adventure of Link, Legend of Link, Link's Dink? It's all the same at this point. Legend of Link uses MMC5 because the game is far too huge to use regular hardware. It's a super great game, too. Infidelity, the creator of the hack, had a blog about it.
On emulation-only homebrew dev, you can in theory just use MP3 music, which simulates an MP3 player being soldered to a Famicom PCB. Heck, on emulation-only homebrew dev, you can make games at PS2 or higher graphical complexity, as Java, C#, and asm.js programs are "emulated" in a way.
WHAT. Are you telling me that a modded NES, even in an NES emulator, can play MP3s?? And that a NES emulator can play games that look like PS2 games for the NES emulator??? That's a little unreal.
AlexE wrote:I heard that NES data could be compressed from a Reddit post I made asking why there hasn't been a decent ROM hack of Metal Gear yet. There wasn't a lot of info spilt on NES compression, though.
It depends on what kind of compression. Some are better suited to the (relatively) small RAM of the NES than others. Methods that involve looking small things up in a static table to get big things, such as byte pair encoding or Huffman coding, work well on NES. So do run-length encoding (RLE), which assumes that the each byte is likely to be the same as the previous byte, and Markov RLE, which uses a table to predict the most common byte that follows each byte. I've used RLE and Markov RLE to compress graphical tile data and map data, and data formats built around Huffman coding or byte pair encoding work well for text. Still other forms of "compression" could be described as clever ways of structuring data to avoid internal fragmentation, such as a music engine whose sequence data combines 5-bit pitch and 3-bit duration of each note into a single byte.

But one popular family of general-purpose compression methods, called LZ77, is based on references to previous decompressed data in a circular buffer. That's not so easy on NES, which has only 2048 bytes of RAM randomly accessible to the CPU unless extra RAM is on the cartridge. LZ77 is easier on the Master System, which has 8K of main RAM; the Game Boy, which also has 8K of main RAM as well as random access to video RAM while rendering is turned off; and on Genesis and Super NES, which have 64K or more of main RAM.
I feel really out-of-place here because I'm having trouble keeping up with this tech jargon. :?
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: Implementing Original Music for Nintendo & Sega Game Dev

Post by Drew Sebastino »

AlexE wrote:I feel really out-of-place here because I'm having trouble keeping up with this tech jargon. :?
What don't you understand?

...Please tell me you at least know what a "byte" is, or "RAM"...
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Implementing Original Music for Nintendo & Sega Game Dev

Post by lidnariq »

AlexE wrote:WHAT. Are you telling me that a modded NES, even in an NES emulator, can play MP3s?
Because of how the Famicom was designed, there is a long tradition of extending its functionality by adding extra hardware in the cartridge.

Whether, as in the Famicom Disk System, that's just to provide a single channel of audio and a magnetic storage medium, or the MMC5 to add all sorts of extra video features.

So, pedantically, you could take an MP3-player-on-a-chip, put it inside the cartridge, and call it good enough. There were a number of Famicom games that are almost exactly this: they added a stored-speech IC to the cart. (And the only real difference here is "how many seconds of recorded audio can you store")
User avatar
AlexE
Posts: 46
Joined: Fri Jan 29, 2016 3:16 pm
Location: York, PA
Contact:

Re: Implementing Original Music for Nintendo & Sega Game Dev

Post by AlexE »

Espozo wrote:
AlexE wrote:I feel really out-of-place here because I'm having trouble keeping up with this tech jargon. :?
What don't you understand?

...Please tell me you at least know what a "byte" is, or "RAM"...
A byte is a unit of data and RAM stands for Random Access Memory (or Random Access Memories if you're a Daft Punk fan).
I understand some of the very basics of computing. I'm more of a musician than I am a programmer.
User avatar
Kasumi
Posts: 1293
Joined: Wed Apr 02, 2008 2:09 pm

Re: Implementing Original Music for Nintendo & Sega Game Dev

Post by Kasumi »

What lidnariq describes is exactly why it's so difficult to give general answers to your questions. Even if we limit our answers to things that were used in the era, it's still a very wide range of possibilities.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Implementing Original Music for Nintendo & Sega Game Dev

Post by dougeff »

Let's move past what CAN be done...

If you're interested in making 80s style chiptunes, for use on NES (etc), then restrict yourself to the commonly used sounds. Sure, you could Mod a cart to play an MP3, but where's the nostalgia in that? It won't feel like an NES game/song.
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
darryl.revok
Posts: 520
Joined: Sat Jul 25, 2015 1:22 pm

Re: Implementing Original Music for Nintendo & Sega Game Dev

Post by darryl.revok »

tepples and I were talking about this in IRC the other day. I offered him my outsider's opinion, and I'm curious to see what others would think.

I haven't truly delved into famitracker yet, but from what I've seen, the interface doesn't seem particularly musical to me. When I think of laying out music on a computer, I think of something like this:

Image
(I've chosen FLstudio as the example, because I actually like its interface the best for creating music directly on a computer.)

I realize what I'm saying goes against the whole worldwide chiptune scene, but I feel like those who aren't chiptune composers would be more comfortable with a piano roll, and a visual layout to position song segments. Then, any musician who's familiar with a DAW could compose pretty comfortably for your game project.
User avatar
Kasumi
Posts: 1293
Joined: Wed Apr 02, 2008 2:09 pm

Re: Implementing Original Music for Nintendo & Sega Game Dev

Post by Kasumi »

There's actually a Game Boy music editor called Bleep that's laid out a bit like that. As a contrast to LSDJ, I suppose.

Edit2: I guess while I'm editing I should say that version of bleep is Game Boy, not color.

To me the difference is mainly in the axis. One's vertical, one's horizontal. I think there are more problems than layout moving from a traditional musical background to chiptune. Like... you can't hit three notes at once for a chord on NES. Edit: At least not with the same instrument and without expansion sound.
Last edited by Kasumi on Sun Jan 31, 2016 6:12 pm, edited 2 times in total.
User avatar
AlexE
Posts: 46
Joined: Fri Jan 29, 2016 3:16 pm
Location: York, PA
Contact:

Re: Implementing Original Music for Nintendo & Sega Game Dev

Post by AlexE »

darryl.revok wrote:tepples and I were talking about this in IRC the other day. I offered him my outsider's opinion, and I'm curious to see what others would think.

I haven't truly delved into famitracker yet, but from what I've seen, the interface doesn't seem particularly musical to me. When I think of laying out music on a computer, I think of something like this:

Image
(I've chosen FLstudio as the example, because I actually like its interface the best for creating music directly on a computer.)

I realize what I'm saying goes against the whole worldwide chiptune scene, but I feel like those who aren't chiptune composers would be more comfortable with a piano roll, and a visual layout to position song segments. Then, any musician who's familiar with a DAW could compose pretty comfortably for your game project.
FamiTracker (and trackers in general) use the computer keyboard to simulate a piano roll pretty analogously, so it comes naturally from a pianist persepctive. The rest of it is using math to place out the rhythms of each note/sample. I also use programs like Reason and MuseScore to make music.
User avatar
AlexE
Posts: 46
Joined: Fri Jan 29, 2016 3:16 pm
Location: York, PA
Contact:

Re: Implementing Original Music for Nintendo & Sega Game Dev

Post by AlexE »

dougeff wrote:Let's move past what CAN be done...

If you're interested in making 80s style chiptunes, for use on NES (etc), then restrict yourself to the commonly used sounds. Sure, you could Mod a cart to play an MP3, but where's the nostalgia in that? It won't feel like an NES game/song.
My questions aren't so much as to what technological madness can be done on the NES, it's how to put music ON the NES game. Basically, the answer seems to be "You'll have to figure it out; here's some tools to help you figure it out."
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Implementing Original Music for Nintendo & Sega Game Dev

Post by tepples »

Once you have made the music, the player library will come with a subroutine that you call to start a song, a subroutine that you call to start a sound effect, and a subroutine that you call every frame to update the APU registers. A player library may offer additional subroutines to pause music, register a loop callback, and the like.
User avatar
Kasumi
Posts: 1293
Joined: Wed Apr 02, 2008 2:09 pm

Re: Implementing Original Music for Nintendo & Sega Game Dev

Post by Kasumi »

My questions aren't so much as to what technological madness can be done on the NES, it's how to put music ON the NES game. Basically, the answer seems to be "You'll have to figure it out; here's some tools to help you figure it out."
So I offered in one of my posts a thing that lets you try out your music using Famitone2's player. Do you want that? I'm not saying figure it out, I'm saying it's on a game by game basis. The questions you're asking simply can't be answered generally. We can help you with Famitone2 specific questions. We can help with GGSound questions. We can't help you make music guaranteed to work for any given game, because that's impossible.

So what is your goal? If you're looking to get your music in a game, you can simply post things you've made without expansion chips so people can decide if they like your sound. You may not get responses, but that's more that there simply aren't that many people doing this.

If you do get a response, whoever wants your music will definitely help you out with what their game needs. It's just hard to help you with general questions, when it's going to vary based on the project that needs the music. It's not like a modern game where you can just send an mp3 over which will work in whatever project.
Post Reply