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 > Audio Advance Formula...

#109264 - musicman3320 - Thu Nov 16, 2006 4:39 pm

Hello all,

Recently, I have been learning how to use GBA Sound Channels 1-4 (from The Audio Advance, of course). In the process, I have come to realize that one of the formulas is incorrect. In particular, it is the formula for the length of Sound Channel 3. The formula given is:

RegisterValue = (length in seconds) * 256

But, in reality, the formula is:

256 - RegisterValue = (length in seconds) * 256.

One of the things that made this hard to find was that Uze's demo for Channel 3 (although very complete), did not really test the sound length attribute. Since he is playing a series of notes and continually resetting the sound, the length never really came into play. The only time it did was when the length was VERY high (like withing 20 of 0xFF), but by his formula, it should be the other way around. So, I created a small demo to test my theory, and, after running it on the actual GBA, I realized that, in fact, the formula was incorrect.

The main reason I am posting this is that there does not seem to be any documentation on this mistake it in the forums (or anywhere else for that matter), and I think it is important for people learning to use the legacy GB sound part of the GBA to know the correct formula. If I am incorrect, please let me know, and if anyone wants to see the demo I created to test it for themselves, let me know and I will be happy to post it.

-Chris
_________________
-- Did you hear about the programmer that died in the shower? The directions on his shampoo said "Wash, Rinse, Repeat." He died of a stack overflow error.

#145867 - uze - Sat Nov 24, 2007 7:37 am

Hi Chris,

I'm the guy who actually wrote that stuff, well...ages ago! Glad you picked up a snag. I will be glad to correct it for the posterity... :) If you still have the example code (I know it been a year or so) please send it to me (uze at belogic com), and I will update the web page.

Oh, and btw, if anybody else reads this and is interested, I have lots of (somewhat old) GBA sound code lying around (S3M player, sound converter, full MIDI interface and so on). Let me know and I'll post it (as-is :)) on the site.

Cheers,

Uze

#146734 - Ruben - Sat Dec 08, 2007 6:14 am

hi uze... i'd be really interested in your S3M player 'cause my last attempt crashed my computer 7 times (XD! i'm not a very good physician or however you write it lol)... so it would be appreciated.

cheers