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.

DS development > Calculate volume/volume shift properly?

#173777 - Ruben - Fri Apr 30, 2010 11:45 am

Hi.

So I was doing some work on my Midi music player [and yes, once I actually implement bank loads it'll be adjusted to work with libnds as well]... and decided that it's time to work with shifted volume [that is, using the hardware /2, /4, /16 values]. My first attempt was rather bad as it compared the limits of 3 possibilities. I know MaxMod uses a LUT, but is there a better way to calculate a volume + shift when one has a 25-bit accuracy, 7-bit integer value as volume?

#173785 - Miked0801 - Fri Apr 30, 2010 4:44 pm

Not quite sure what you are asking, could you post a snippet of sample code?

#173793 - Ruben - Sat May 01, 2010 6:22 am

Code:
40004x0h - NDS7 - SOUNDxCNT - Sound Channel X Control Register (R/W)

  Bit0-6    Volume Mul   (0..127=silent..loud)
  Bit7      Not used     (always zero)
  Bit8-9    Volume Div   (0=Normal, 1=Div2, 2=Div4, 3=Div16)

While I can just use a 0 division ['normal' mode], it seems more proper to use an actual scaling value [bits 8-9].

#173794 - Dwedit - Sat May 01, 2010 6:34 am

Volume division seems worthless, since you can just change the volume between 0 and 127 directly. I guess it's just for situations where you want to temporarily make the music quieter.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#173795 - Ruben - Sat May 01, 2010 7:03 am

Hm, so there's pretty much no point in keeping the sound volume accuracy? But then why do MaxMod and official games use the division?