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: Jeff Moore <email@hidden>
- Date: Tue, 22 May 2007 11:54:38 -0700
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 =)
Is my only option for adjusting the volume of the audio data in this
situation to track the volume level myself, and multiply each sample
by some fraction (e.g. by 0.7)?
If there isn't a volume control for you to use, than you are left with
doing it yourself
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.
Or is there a better way of implementing a "recording level" control?
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.
This can be a hard concept to explain to a user, so a lot of apps will
just refrain from providing the control in this case.
--
Jeff Moore
Core Audio
Apple
_______________________________________________
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