Re: USB Mic Volume in 10.2.8
Re: USB Mic Volume in 10.2.8
- Subject: Re: USB Mic Volume in 10.2.8
- From: Doug Zwick <email@hidden>
- Date: Wed, 23 May 2007 09:36:33 -0600
Jeff Moore wrote:
On May 22, 2007, at 11:11 AM, Doug Zwick wrote:
I have some code that records audio data from a mic using Core Audio
(it is part of an internet conferencing application). It includes a
volume control, attached to a "recording level" slider in the
application's GUI. I am using AudioDeviceSetProperty on
kAudioDevicePropertyVolumeScalar to set the volume level it is
recording at. This works fine for every mic we've been able to find
under OS X 10.3.9 and 10.4.9. Unfortunately, under 10.2.8 some
devices return kAudioHardwareUnknownPropertyError. In looking
through the archives of this list, it seems to be a FAQ why this
doesn't work for every device, and the answer is because the device
does not have a volume control. I ran Audio MIDI Setup and verified
that the devices in question (all are USB headsets) do not show a
volume control under 10.2.8, but do show one under 10.3.9. I am
curious about the difference in behaviour between 10.2.8 and
10.3.9/10.4.8 -- was Core Audio enhanced to simulate a master volume
control for such devices?
No. There is no simulation of controls in the HAL or the IOAudio
family. Mostly likely, the difference comes from the upgraded USB
Audio driver in the later systems, but I have a hard time remembering
that far back =)
The CoreAudio code is replacing some old SoundManager code.
Interestingly, the SoundManager API will vary the signal strength
when changing the device volume of one of these "problem" devices. It
must be doing its own scaling in that case. We may simply choose to
keep using the old SoundManager code for 10.2 users.
I know that the desired multiplier value is not in a linear
relationship with the volume slider position, so I shouldn't just
multiply by the kAudioDevicePropertyVolumeScalar property value --
what is a good function to obtain a multiplier from the scalar value
(e.g. sqrt(v), log(v), etc.)?
Volume is perceived logarithmically. The equation to convert an
attenuation value in dB to a scalar value is 10 raised to the (dB/
20)th power.
So, in order to produce a function f(x) yielding the desired
multiplier, where x is the scalar volume (0.0..1.0), I'd need to
arbitrarily select a point for the identity multiplier (say f(0.8) =
1.0), and a conversion factor to dB (say 50.0, so dB = (x-0.8)*5.0,
giving a range of -40 to +10 dB) and get a function something like this:
f(x) = 10.0^((x-0.8)*50.0/20.0)
Assuming I've done the math right, that should yield multipliers in
the range 0.01 to 3.15 with an appropriate logarithmic scale. Scaling
the samples up will produce "rougher" wave forms, and sound distorted
(relative to signals generated by the hardware with the proper
amplitude), so strongly limiting the ability to scale the signal up
seems reasonable.
There is one big catch about using software volume control on the
input signal: if the signal is coming in too hot and is clipping, it
is too late to do anything about it after it is converted to the
digital domain. No matter what you multiply the signal by, the clipped
portion of the signal will remain clipped.
So far, the only devices we've seen that exhibit this issue are USB
headset mics. Given that in such devices the mic position is fixed
relative to the speaker's mouth, unless the speaker is exceptionally
loud of mouth, "hot" samples shouldn't be an issue.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden