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.

C/C++ > GBC sound channels

#6642 - nitro2k01 - Sat May 31, 2003 3:58 pm

I tried to kick the GBC sound channels going with this piece of code

Code:

    *(u16*)0x04000080 = 0xFF77;
    *(u16*)0x04000062 = 0xFFFF;
    *(u16*)0x04000064 = 0xFFFF;

but it's not working. What's wrong?

I'm using HAM if it makes any difference.[/code]

#6651 - tepples - Sun Jun 01, 2003 2:20 am

For one thing, you have to enable the GBC sound to both left and right speaker outputs and set its output volume with 0x04000080. You may also have to turn on the sound circuitry (0x04000084) as well; some shells turn it off.

Learn more: belogic.com
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#7017 - mpowell - Fri Jun 06, 2003 7:23 am

Has anyone done any quick and dirty mixing of sounds?

I haven't tried it yet, but I was going to just add samples together and divide by 2 to mix them, but I know that this isn't the best thing to do.

Does anyone know how crappy this "add and divide samples" method sounds?

Can you get away with adding four samples and dividing by 4?

#7020 - gb_feedback - Fri Jun 06, 2003 11:00 am

Quote:
I haven't tried it yet, but I was going to just add samples together and divide by 2 to mix them, but I know that this isn't the best thing to do.

Basically that's all there is to it. Of course if you do it for more and more channels the individual sounds are getting quieter and quieter, so it must be better to divide by less than the number of channels, and to then clamp the result of your (signed) addition to the max and min possible in an 8 bit signed number. In other words as you add two waveforms together, most of the time they don't add to larger values as they are cancelling each other.

8 bits is not a lot to play with in a mixer - too loud and it clips, too quiet and a) noone can hear it and b) quantisation noise becomes obtrusive.

So in my opinion trial and error plays a big part here.
_________________
http://www.bookreader.co.uk/