My music engine

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
My music engine
by on (#115699)
I made a game-oriented music engine for one project and reused it for Thwaite and two other games in the bundle, as well as its menu. NovaYoshi has been using it for his own project. I wrote NSF and NES wrappers, as seen in my NSF of these games. Memory consumption is on the order of 36 bytes zero page and 80 bytes BSS.

Right now, music is coded as .byt statements, with symbols for phrase bytecode and macros for song commands. Perhaps I should polish it up and write a compiler for a proper input language inspired by MML but not compatible with any MCK.
Re: My music engine
by on (#115707)
Do you support other mappers including some which have expansion audio?
Re: My music engine
by on (#115727)
Mappers provide three services: bank switching, IRQs, and expansion audio. I tried to make the music data format small enough that a typical NES game soundtrack could fit in a single 16 KiB bank. (Look at the size of the NSF that I linked above.) I can see where IRQs would be used for $4011 writes (as in blargg's sawtooth wave hack) but not much else, and that hack not only doesn't work in NSFs but also can cause audible artifacts when an ongoing OAM DMA blocks IRQ handler execution, as Dwedit pointed out.

I chose not to support expansion audio for three reasons:
  • I don't own a Famicom and a T-cart to test on.
  • Using expansion audio in homebrew involves either an expensive PowerPak, donor carts, or an old PC with a parallel port capable of running DOS and the FDS loader, making it difficult to distribute a game that uses expansion audio.
  • It'd increase the RAM footprint, which might not be so bad because most of these include built-in PRG RAM decoding.
But I do plan to distribute it as free software so that you can write your own patch adding VRC6, MMC5 or 5B support.

As I get various parts of the compiler done, I'll start to give lessons on the syntax for some features that I'm working on, such as building drums out of sound effects, playing phrases with transpositions, and adding swing to a phrase.
Re: My music engine
by on (#115728)
Considering that Famitracker now has standartized text export, I guess it could be possible to make a converter for this format?

As we have quite many sound/music engines now, I think it would be useful to have a Wiki page that lists them all, along with their capabilities, assembler formats, licenses, etc, so people could actually know about them and use in their projects.
Re: My music engine
by on (#115729)
I could make a basic converter for FT text export, but it would mostly be a tool for quickly entering phrases, as it wouldn't sound the same. The envelope paradigm differs, and the player doesn't use the MOD tempo/speed paradigm, and phrases can be started at any time, not just on pattern boundaries, and phrases can be transposed, and phrases can be shared among the three tone generator channels (as demonstrated in "Leck mich im Arsch" in the demo), and one channel can play attacks on top of another channel. There's a bit of impedance mismatch between FT's data model and mine.

ROM footprint of player: about 1.3 KiB
Re: My music engine
by on (#212990)
It has a name: Pently.