Starting to work on a sound engine

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Starting to work on a sound engine
by on (#135611)
I'm going to start working on a sound engine so I need some help with it. Is it possible (and efficient) to make a sound engine that's songs are lists of patterns? The sound engine would read what pattern to play from the list. Once the pattern ends, it would return to the list and check the next pattern to play. Also, is it possible to make the sound engine read from FamiTracker's .nsf files?
Re: Starting to work on a sound engine
by on (#135618)
Yes, sound engines commonly represent music as lists of patterns in the way you describe. And yes, FamiTracker includes a "text export" command to convert FTM to a text format that your own translator can use.
Re: Starting to work on a sound engine
by on (#135658)
I just tried the text export, but the output doesn't really look like something that NESASM3 would understand if I added it to the program.
Re: Starting to work on a sound engine
by on (#135665)
You probably have to parse the output somehow to make it useful.
Re: Starting to work on a sound engine
by on (#135668)
FamiTracker's text output is intended for you to write a PC program to translate the output into sequence data suitable for your own music engine. You might write this in C++, C, Java, JavaScript, Python, or whatever. Do you know any PC programming languages?
Re: Starting to work on a sound engine
by on (#135670)
tepples wrote:
Do you know any PC programming languages?


Does Touhou Danmakufu and Game Maker count? Otherwise, no. I have some old version of FamiTracker that has .NSF export. Can't I use that?
Re: Starting to work on a sound engine
by on (#135671)
In theory you can use .incbin to include the body of FamiTracker's NSF export at the load address and play music through that.

In practice it's a lot harder for at least two reasons. One is that the NSF interface defines no way to play sound effects on top of the music. The other is that an NSF is allowed to use the machine's whole memory except for the top of the stack, which means you don't know in advance which memory your game is allowed to use.
Re: Starting to work on a sound engine
by on (#135675)
Tsutarja wrote:
I have some old version of FamiTracker that has .NSF export. Can't I use that?

If you include the whole NSF you'll be including more than the song data, since NSF files include the player code as well.

I imagine you could analyze the NSF and extract only the data from it, but if you use the exact same data format as FamiTracker you'll be essentially reimplementing the FamiTracker player, which is silly.

If you're implementing your own sound engine, you'll need to come up with your own data formats, and in order to handle custom file formats you absolutely need some programming experience.
Re: Starting to work on a sound engine
by on (#135686)
Or look into something like Famitone or Famitone2.
Re: Starting to work on a sound engine
by on (#135769)
Kasumi wrote:
Or look into something like Famitone or Famitone2.


I guess this would be the easiest way to get sound working. I'll try it when I have more time.