Discussion:
Setting Microphone Gain programmatically
(too old to reply)
sid
2008-07-24 12:02:42 UTC
Permalink
Hi

I am working on windows mobile application development using both
native C++ and embedded visual basic.

I was wondering if there is any way to set the microphone settings
like microphone gain, bass boost, trebble adjustment programmatically.

primarily i am interested in enabling/disabling microphone gain
settings and adjusting the manual gain to my desired figures of +3db,
+9db etc ..

I have read about the "mixerSetControlDetails" API. But it does not
give any straight-forward and convincing implementation routine for
setting the "microphone gain", whcih is basically what I am interested
in.

The documentation also says "The Real Time Communications automatic
gain control won’t work properly unless the driver (and hardware)
supports mixerSetControlDetails on the microphone input. Specifically,
the dwControlID field of the MIXERCONTROLDETAILS struct should be
equal to MIXERCONTROL_CONTROLTYPE_VOLUME."

Since I work on different PDA models (3 for now), is it really worth
putting in the effort to explore this API and its quite complex
structures in detail or there is some other work around for embedded
devices

Any advice will be of great help

Thanks
Sid
Bob Masta
2008-07-25 12:39:11 UTC
Permalink
Post by sid
Hi
I am working on windows mobile application development using both
native C++ and embedded visual basic.
I was wondering if there is any way to set the microphone settings
like microphone gain, bass boost, trebble adjustment programmatically.
primarily i am interested in enabling/disabling microphone gain
settings and adjusting the manual gain to my desired figures of +3db,
+9db etc ..
I have read about the "mixerSetControlDetails" API. But it does not
give any straight-forward and convincing implementation routine for
setting the "microphone gain", whcih is basically what I am interested
in.
The documentation also says "The Real Time Communications automatic
gain control won=92t work properly unless the driver (and hardware)
supports mixerSetControlDetails on the microphone input. Specifically,
the dwControlID field of the MIXERCONTROLDETAILS struct should be
equal to MIXERCONTROL_CONTROLTYPE_VOLUME."
Since I work on different PDA models (3 for now), is it really worth
putting in the effort to explore this API and its quite complex
structures in detail or there is some other work around for embedded
devices
Any advice will be of great help
Thanks
Sid
Well, the bad news is that the Mixer API knows nothing about dB.
So even if you slog through this nightmare of enumerating and filling
in forms, you won't find what you want at the bottom.

Also, the term "gain" can cause confusion. Sound cards typically have
a mic preamp that feeds a mixer attenuator ahead of the A/D. That's
what you are controlling with the normal recording sliders. Some
cards may also have a separate gain switch that adds additional gain,
maybe with a couple of gain positions. But that is not the norm, as
far as I can tell.

In either case, there is no way to get from the driver the amount of
dB per attenuator step (or switch position).

The attenuators are controlled by a value in the 0-65535 range. The
mixer API allows you to get a cSteps value that tells how many steps
this range is divided into. Windows, starting with XP (I think),
seems to have decreed that all cards will report 192 steps.

But wait, there's more! The card actually has nowhere near 192 steps,
so most of them are dummy positions. In other words, as you move the
slider, nothing happens for a few steps, then the attenuation changes.
The actual attenuator has maybe 16 or 32 physical attenuation steps,
which are mapped to certain places in the 192-step range... presumably
to give a nice audio control taper. But as far as I know it is
completely up to the card maker and/or driver creator. (There may be
guidelines for this... anybody know?)

The attenuator is best considered as having 0 dB gain at the top, and
going down from there. The bottom active step may be around -60 dB,
and below that may be "off". Near the top of the range, the active
steps may be as fine as 0.5 dB. Near the bottom they may be as coarse
as 6 dB. Note that I am only talking about active steps... there will
be an unknown number of "no change" steps between any two active
steps.

So you might need to reconsider your request as how to find 0 dB, -3
dB, -6 dB, -9 dB, etc. (You may or may not find steps that fall on
the dB values you want, depending on the physical attenuator design.)

Now, if you really want a specific dB, you'll need to calibrate your
specific card... they are all different. My Daqarta software includes
an Autocalibration option that can figure this out via a loopback
connection between the outputs and inputs... you are welcome to use
that. (30-day/30-session free trial should be more than enough to get
the info you want.)

But I suspect you were hoping (as I once did) that there is some
standard that will lead to dB. Sorry! I think this is an artifact of
the Windows sound API being designed only with entertainment in mind.

Best regards,



Bob Masta

DAQARTA v4.00
Data AcQuisition And Real-Time Analysis
www.daqarta.com
Scope, Spectrum, Spectrogram, Sound Level Meter
FREE Signal Generator
Science with your sound card!

Loading...