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 > Current volume of the DS mic?

#115446 - nolen - Tue Jan 16, 2007 4:03 am

I'm trying to wean myself from PAlib, so currently I'm stuck figuring out how to get the current volume of the mic without using said wrapper.

PAlib has something like PA_MicGetVolume() or whatever, but how do I accomplish the same thing without using PAlib?

#115447 - Lick - Tue Jan 16, 2007 4:08 am

I guess it's something PALib handles internally. It could be a factor to which the incoming data is multiplied.

final_sound = raw_sound * PALib_mic_factor; //where the factor is 0.00 to 1.00

You can implement such a calculation yourself.
[edit] BTW, don't use floats. Use fixed point math.
_________________
http://licklick.wordpress.com

#115454 - nolen - Tue Jan 16, 2007 5:13 am

Lick wrote:
I guess it's something PALib handles internally. It could be a factor to which the incoming data is multiplied.

final_sound = raw_sound * PALib_mic_factor; //where the factor is 0.00 to 1.00

You can implement such a calculation yourself.
[edit] BTW, don't use floats. Use fixed point math.



It's probably because it's late here and I need rest, but doesn't your example still require me to use PAlib? I'm a bit confused :(

#115485 - Lick - Tue Jan 16, 2007 3:40 pm

The thing is, you can have your own volume-factor!
Imagine that all the sound you receive from the mic equals 100% volume. Now if your application wants 50%, you just divide each soundsample by 2 (or multiply by 0.5).

In an example with floats:
Code:
float my_own_factor = 1.0f;

void getSound()
{
   //in a loop:
   sndBuffer[i] = MIC_DATA[i]  *  my_own_factor;
}

void setVolume(int vol)
{
   my_own_factor = vol / 100.0f;
}

_________________
http://licklick.wordpress.com