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.

Audio > Confused about gba sound

#12478 - shunyata - Sat Nov 15, 2003 6:46 pm

I have just turned my attention toward the musical aspects of gba-programming and there are a few things that really confuse me.

1) When composing a modfile (which i?ve never done) it seems you track wave samples. The gba soundchip -however- appears to generate sound via realtime synthesis and not sample-data (except for the two extra chanels). Then how can the gba make anything of a mod-file?

2) Many of the mixers available brag about 8 channel mixing, how is this possible on a soundchip with only 4 + 2 channels? Do the mixers resample multiple channels into one output-channel or what?

thanks, my head hurts

#12480 - DekuTree64 - Sat Nov 15, 2003 8:39 pm

Yeah, resample into one channel. All you have to do is multiply each sample by its channel's volume level, add them together and shift down so they fit into 8 bits. Since MOD volume levels are 0-64, that's generally done with a divide by 64, or bitshift right 6.
Then you have the problem of adding channels together can give you more than 127/less then -128, so you either have to divide by the max number of channels (say you have 4 channels, you can just bitshift right 8 to do the volume and overflow dividing at once), but then you have a lower final volume, or clip values greater than 127 to 127 and less then -128 to -128, which takes more procesor time, but then you can have as many channels as you want without cutting your volume way down.

When it comes down to it, writing a mixer is easy, but writing a fast mixer is a whole different story. Good luck beating AAS in speed, I've tried and failed every time. You can beat it in quality though, since it uses the volume reducing way of preventing overflow from mixing 4 channels per side, and a sneaky way of sacrificing a little bit of accuracy for a whole lot of speed.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#12481 - shunyata - Sat Nov 15, 2003 9:13 pm

allrightie, that makes sense. it must be way more economical to use the tone-generators for music though, using the sample-chanels for sfx. sure, you cant have disted guitars and stuff, but I dont really care, I?m very into oldschool videogame music (nes in particular, check out my band at www.powerplaymusic.net). is there any tools out there to sequence for the tone-generators?

#12488 - tepples - Sun Nov 16, 2003 12:20 am

You can use Boyscout to sequence for the tone generators. I have written my own music system that covers both the tone generators and the sample channel, but I haven't cleaned it up too much yet.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#12587 - shunyata - Tue Nov 18, 2003 8:14 pm

thanks, boyscout is one fenomenal little app! just one question remains unanswered; is it more economical to use them hardcore oscillators? clearly it saves storage memory, but how about performance?

#12588 - tepples - Tue Nov 18, 2003 9:40 pm

The GBA's tone generators are processed in parallel to the CPU and use no CPU power, except for the time spent parsing your music file.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.