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 > Question about volume, multiplication and shifts...

#163951 - Ruben - Thu Oct 16, 2008 3:18 pm

Hi all~

So I was trying to optimize my mixer yet again, and saw this:

Code:
v = 127 (max is 127)
s = 7 (pow(2,7) = 128 which is ~127)
 
(15*v)+(85*v) = 12700
             /= pow(2,(s+2))
             ~= 25
 
v = 16 (max is 16)
s = 4 (pow(2,4) = 16)
 
(15*v)+(85*v) = 1600
             /= pow(2,(s+2))
             ~= 25


So... is that true? If so, why do people allow stuff like 0-127 volume ranges (GBA BIOS Synth) and what's the difference it makes?

*highly confused*

#163954 - eKid - Thu Oct 16, 2008 5:32 pm

Larger volume ranges give a better sound when doing volume slides.

Example:

127 * 16 / 16 = 127
127 * 15 / 16 = 119
127 * 14 / 16 = 111
etc...

Notice the ~8 sample resolution there,

With 0->64 volume, you get a much better resolution:
127 * 63 / 64 = 125
127 * 62 / 64 = 123
...

Also, if you're going to shift the data during the mixing loop, may as well use 0->255.

#163980 - Ruben - Fri Oct 17, 2008 11:42 am

OK, I seem to get it but I don't think I explained myself properly.

What I meant was that since a few mixers shift before storing (citation needed. :P), what would be the point of allowing so much accuracy, if it'll get shifted anyway?

IE:
My latest mixer uses 32 channels, so that's a 5 bit shift, meaning that there's only 2 bits of accuracy. Not much at all. Therefore, why is that allowed instead of just cutting down the volume?