gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Music in GBA games

#176701 - absence - Thu Sep 15, 2011 3:14 pm

Does anyone know if Nintendo provided an official music player that developers used, or did each developer invent their own formats and players?

#176702 - Dwedit - Thu Sep 15, 2011 5:23 pm

Almost all developers used the sound engine that Nintendo provided.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#176705 - Exophase - Thu Sep 15, 2011 8:57 pm

Dwedit wrote:
Almost all developers used the sound engine that Nintendo provided.


Interesting - do you have a source for this? Almost none of them used the audio functions available in the BIOS. But this could help explain why most GBA games had pretty lackluster audio coding..

One company that definitely rolled their own engines was Camelot; their audio engine employs extensive self modifying code in IWRAM (not that this doesn't apply to other parts of their game code too).. Golden Sun 2 actually generated audio at a rate of 64KHz, a good 3-4x higher than most GBA games.

#176706 - Miked0801 - Thu Sep 15, 2011 10:20 pm

Nintendo offered a MIDI player based on Musyx (which was a big hit on the GBC). All in all, it was pretty bleh - high overhead for a MIDI player with nothing really great in terms of its performance. We rolled our own MOD style player and went with that. Allowed much more control and better quality than the Nintendo stuff. Even in later (and later) handhelds, Nintendo still loves MIDI far too much.

As to the BIOS functions - those were written to conserve space, not to perform well. In addition, the overhead to get to the BIOS was pretty nasty if calling a quick function. There's a reason that div, mempy, and other stuff that lives in BIOS was almost universally redone by devs in code. About the only thing the BIOS was good for was for hackers to get into things they weren't supposed to :)

#176708 - Dwedit - Thu Sep 15, 2011 10:32 pm

There's a tool out there called SapTapper. It extracts music from GBA games, and you can play it in Winamp using a plugin. It only works on games which were built using Nintendo's sound libraries.

Throw a random game at SapTapper, and chances are it will rip successfully, so that indicates it uses Nintendo's sound library.

GSF Central's site lists 150 GBA soundtracks, and 75 of them are cited as being ripped with SapTapper. But that number excludes the rips of game which were done before the tool was finished, so far more than 75 of their listed 150 games were using Nintendo's library.

I can't confirm Golden Sun, since it failed to play back after I tested it in Saptapper, so Camelot might be using their own sound engine.

Really strange is that "Castlevania Circle of the Moon" and "Harmony of Dissonance" both use Nintendo's sound engine, but the second game has absolute crap for music.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#176713 - absence - Fri Sep 16, 2011 8:47 am

I was toying with the idea of writing a replacement replayer that uses sound data from the game, but with proper resampling and mixing done in native code, rather than emulating the game's replayer and GBA sound hardware. It would increase sound quality a lot. Not having to disassemble the music routine of every game makes it sort of practical at least. ;)

#176724 - Exophase - Tue Sep 20, 2011 8:12 pm

Dwedit wrote:
GSF Central's site lists 150 GBA soundtracks, and 75 of them are cited as being ripped with SapTapper. But that number excludes the rips of game which were done before the tool was finished, so far more than 75 of their listed 150 games were using Nintendo's library.

I can't confirm Golden Sun, since it failed to play back after I tested it in Saptapper, so Camelot might be using their own sound engine.

Really strange is that "Castlevania Circle of the Moon" and "Harmony of Dissonance" both use Nintendo's sound engine, but the second game has absolute crap for music.


This certainly shows that it was a common library, but this doesn't necessarily mean that almost all developers were using it. 150 games is a pretty small fraction of the total number of unique GBA games and there's a sampling bias given that games that can be ripped with this tool are more likely to be ripped in general. Probably a moot point if the more popular games tended to use it..

I'm guessing Konami made compromises with HoD's music in order to save resources - it uses way less CPU time than CotM. But maybe with a more efficient audio engine CotM would have used less time to begin with, not that I'm aware of this being a problem for the game.

absence wrote:
I was toying with the idea of writing a replacement replayer that uses sound data from the game, but with proper resampling and mixing done in native code, rather than emulating the game's replayer and GBA sound hardware. It would increase sound quality a lot. Not having to disassemble the music routine of every game makes it sort of practical at least. ;)


I thought about doing something like that too, before I knew that so many games were using Nintendo's sound engine, now it seems more attractive. Would be especially cool if it could be worked into an emulator via HLE.

#176756 - gladius - Wed Oct 05, 2011 12:55 am

I'm not sure about 'vast majority'. Custom sound libraries were pretty popular. The games I worked on all used a custom engine. Honestly can not remember what it was called. They did all the sfx/music as well for us.

#176960 - Bregalad - Mon Nov 07, 2011 11:30 pm

I can confirm many games uses the Nintendo sound engine, which I reverse-engineered its format for my Final Fantasy V and VI sound restauration hacks. I released a document describing some aspects of the engine on romhacking.net

I can also confirm this engine is probably not very efficient - it uses only a 8-bit sound buffer for mixing all channels so the quality is mediocre. Mixing in 16-bit then convert the result to 8-bit by scrapping the low bits would probably lead to better quality at the price of RAM and CPU time.

Also the engine becomes ridiculously slow when you use a lot of channels, which is why many games took the path to limit the number of channels and use PSG channels.

Castlevania : Circle of the Moon uses stereo sound, 10512 Hz sampling rate and 12 channels. I clearly remember the game lagging in an area where there was a lot of boxes by the way.

Castlevania : Harmony of Dissonance uses mono sound, 15768 Hz sampling rate and 5 channels. It uses mostly PSG channels for music, but the game is quite fast paced.

Golden Sun does uses the Nintendo engine, but a modified version of it, which is probably why it won't work with saptapper. It uses stereo, 8 channels and 21024 Hz, while Golden Sun : The lost Age uses 10 channels and 31536 Hz, which is has the higher sampling rate I've ever noticed (I haven't investigated the WHOLE collection though).

Because it uses a modified version Camelot *might* have made something that changes those parameters during gameplay and/or that makes mixing faster to make this "achievement" possible.