Hardware How does GBA load audio files?

biolizardshadow

Well-Known Member
OP
Member
Joined
May 4, 2020
Messages
121
Trophies
0
Age
20
XP
262
Country
United States
The first question might kind sound of dumb, but can the 8bit DAC's on the GBA playback a 16bit audio file? How does the GBA load direct sound waveforms? I was able to get a 16 audio file that is 644kb to run in a GBA game! I assume at this point that samples are loaded directly from the cartridge instead of loading everything into ram as that would have made the game crash. I tested this because of how the DS seems like a step backwards in terms of how it has to load audio files into ram which causes a limit as to how long each sound can be.
 

biolizardshadow

Well-Known Member
OP
Member
Joined
May 4, 2020
Messages
121
Trophies
0
Age
20
XP
262
Country
United States
It really bothers me how horrid they made the GBA's sound system. Everything sounds scratchy, distorted, and low-quality.
The GBA by itself sound wise is really good! Developers had to decrease the sample rates of audio files because of how little space most GBA games had. The largest amount of cartridge space the GBA can read is 32 megabytes; with this in mind most game dev's had only 8MB of cartridge space to work which is why lots of games didn't sound the best.

What's interesting here is that the M4A/MP2K sound engine has an output sample rate option; however, with the games I've seen and worked with (Sonic Advance Trilogy, Pokemon Fire Red, Megaman Zero series, etc) have always had very high sample rates usually close to max.

In Sonic Advance 2 at rom address 0x0001800 you will find 4 bytes that display in this order 00 F5 93 00. Byte 3 (93) is the byte that controls the games output sample rate. I encourage you to use a hex editor to and change it to something like 01 and see the difference in sound quality! It's quite stunning!
 
Last edited by biolizardshadow,

Jayro

MediCat USB Dev
Developer
Joined
Jul 23, 2012
Messages
10,378
Trophies
3
Location
WA State
Website
ko-fi.com
XP
11,509
Country
United States
The GBA by itself sound wise is really good! Developers had to decrease the sample rates of audio files because of how little space most GBA games had. The largest amount of cartridge space the GBA can read is 32 megabytes; with this in mind most game dev's had only 8MB of cartridge space to work which is why lots of games didn't sound the best.

What's interesting here is that the M4A/MP2K sound engine has an output sample rate option; however, with the games I've seen and worked with (Sonic Advance Trilogy, Pokemon Fire Red, Megaman Zero series, etc) have always had very high sample rates usually close to max.

In Sonic Advance 2 at rom address 0x0001800 you will find 4 bytes that display in this order 00 F5 93 00. Byte 3 (93) is the byte that controls the games output sample rate. I encourage you to use a hex editor to and change it to something like 01 and see the difference in sound quality! It's quite stunning!
That's incredible! My GBA parts are ordered, and on their way, I just have to wait and build my new GBA, and then I will test this right away!

Does this hex hack work for most GBA games?
 

biolizardshadow

Well-Known Member
OP
Member
Joined
May 4, 2020
Messages
121
Trophies
0
Age
20
XP
262
Country
United States
Yes as long as it uses the M4A/MP2K sound engine. Keep in mind that depending on the game the bytes might look a little bit different and are located in a different part of the rom (usually somewhere near the start). For example in Pokemon fire red the bytes look like this 00 C5 94 00. The output sample rate byte is always located next to the direct sound limit byte, so if you can find that then you can find the output sample rate byte.

So are you building your own GBA?
 
Last edited by biolizardshadow,

Jayro

MediCat USB Dev
Developer
Joined
Jul 23, 2012
Messages
10,378
Trophies
3
Location
WA State
Website
ko-fi.com
XP
11,509
Country
United States
Yes as long as it uses the M4A/MP2K sound engine. Keep in mind that depending on the game the bytes might look a little bit different and are located in a different part of the rom (usually somewhere near the start). For example in Pokemon fire red the bytes look like this 00 C5 94 00. The output sample rate byte is always located next to the direct sound limit byte, so if you can find that then you can find the output sample rate byte.

So are you building your own GBA?
Yeah, I've been building DMGs and Colors, so now I'm doing an AGB-001 with IPS v2 mod, clean juice battery, and an EZ-Flash 4. New shell, buttons, and membranes. Bought a used and working GBA from a dude in California for just $60 off Mercari to be the donor motherboard. And after this, I'll be doing the same to my GBA SP. And much, much later down the pipeline, a metal Gameboy Macro. (That one might be a Summer project.) I really have no desire to build a GB Pocket though, as it was my least favorite Gameboy. (Terrible battery life, and basically a slimmer DMG.)
 
Last edited by Jayro,

biolizardshadow

Well-Known Member
OP
Member
Joined
May 4, 2020
Messages
121
Trophies
0
Age
20
XP
262
Country
United States
That's cool! I would like to do something like that, but school takes up too much time for me to try something like that. One thing I would like to do is fix the screen on my original Gameboy so it won't display dead pixels which is caused by faulty wiring.

I believe the first 4 channels on the GBA and Gameboy can be implanted on another computer/device. Getting everything to work I imagine would be a nightmare; however, the sound generators aren't limited to just their respective systems. I thought that was cool!
 
Last edited by biolizardshadow,

DanTheManMS

aka Ricochet Otter
Member
Joined
Jun 2, 2007
Messages
4,360
Trophies
0
Age
31
Location
Georgia
XP
483
Country
United States
In Sonic Advance 2 at rom address 0x0001800 you will find 4 bytes that display in this order 00 F5 93 00. Byte 3 (93) is the byte that controls the games output sample rate. I encourage you to use a hex editor to and change it to something like 01 and see the difference in sound quality! It's quite stunning!

I went ahead and tested this. Wow you're right, that does make a difference, but only for some certain audio tracks and sounds, not all. At least not in the intro scene and first level that I tested.

I modified byte 2 (F5) to "11" based on your later comment that the other byte involves the relative maximum volume, leaving byte 93 alone for the sample rate in this test, and the difference was more obvious. The "Sonic Advance 2!" shout in the intro was almost impossible to hear, as were most of the higher-pitched portions of the sound-track in Level 1. The bass-heavy parts must have been using a different sound system since they still came through lound-and-clear.
 
  • Like
Reactions: cearp

biolizardshadow

Well-Known Member
OP
Member
Joined
May 4, 2020
Messages
121
Trophies
0
Age
20
XP
262
Country
United States
Actually the byte F5 has two functions. The first bit (F) controls the directs sound master volume while the second bit (5) is the number of sounds that can be played at any given moment. When you changed to the byte to 11 you basically made it so direct sound is playing at the lowest volume. So if you change it back to F and leave the 1 there you will be able to hear it better.

Also, you are right when you said that only some tracks are effected. Sonic Advance 2 uses Gameboy sound channels which are unaffected by the change to the direct sound channels so those will keep playing in-spite of any changes unless you disable them.

Playing the game with only one direct sound playable means your not going to hear the music most of the time. The only thing you will hear on a consistent basis are the Gameboy sound channels doing there thing but that's about it as each sample is fighting amongst each other to play and the game constantly having to switch which sounds are being played. I honestly would not recommend playing the game this way, but it's fun to change the sound engines settings and seeing what happens and how the game responds.
 
Last edited by biolizardshadow,
General chit-chat
Help Users
    KennieDaMeanie @ KennieDaMeanie: https://brobible.com/culture/article/burt-reynolds-pontiac-firebird-for-sale/?fr=operanews