Re: Getting available sample rates and bit depths (nominal vs. physical vs. Audio MIDI Setup)
Re: Getting available sample rates and bit depths (nominal vs. physical vs. Audio MIDI Setup)
- Subject: Re: Getting available sample rates and bit depths (nominal vs. physical vs. Audio MIDI Setup)
- From: Jeff Moore <email@hidden>
- Date: Mon, 15 Oct 2007 18:25:56 -0700
On Oct 5, 2007, at 1:10 PM, Gunnar Proppe wrote:
I'm attempting to provide the user with pop-up menus for setting the
sample rate and bit depth along with the audio output device
selection pop-up in a preference panel. I've tried a few approaches
and I'm confused by the varying results. Here's some output from my
test code:
FireOne (0007)
-- Physical rates: --
192000 24
176400 24
96000 24
88200 24
-- Virtual rates: --
192000 32
176400 32
96000 32
88200 32
-- Nominal rates: --
44100
48000
88200
96000
176400
192000
Built-in Output
-- Physical rates: --
96000 16
48000 16
44100 16
96000 20
48000 20
44100 20
-- Virtual rates: --
96000 32
48000 32
-- Nominal rates: --
44100
48000
96000
I used AudioDeviceGetProperty(...) with
kAudioStreamPropertyAvailablePhysicalFormats ,
kAudioStreamPropertyAvailableVirtualFormats,
kAudioDevicePropertyAvailableNominalSampleRates to obtain these
results.
This isn't what you should be doing. Sample format information (as the
name of the properties indicate) are stream properties. It is easiest
to think of the sample format of an Audio Device as an array of
AudioStreamBasicDescriptions with an element for each stream. Thus, to
get the full format of the device, you have to get the list of streams
and then get the format of each stream.
As you can see, the FireOne reports only rates higher than 48000 Hz
for physical rates. I get a similar result with another device, a
TASCAM US-428 reports only 48000 Hz, not 44000.
Audio MIDI Setup also shows different results: it adds 24 bits to
the Built-in Output's bit depth pop-up.
Yup. That's because AMS does things properly and sees the full format
info.
I was hoping to use the results of
kAudioStreamPropertyAvailablePhysicalFormats because it pairs the
bit depths and sample rates (I'm guessing there are devices that
don't offer all sample rates at all bit depths). This is also the
only way I've found to get the native bit depths (there's no such
thing as kAudioDevicePropertyAvailableBitDepths, right?). Could our
devices be responding incorrectly to these requests (the FireOne is
using the built-in OS firewire driver)?
Nope. Your code is wrong.
It's quite possible I'm doing something boneheaded in my code. If
none of this rings a bell I'll provide an excerpt.
That's OK. You're experiencing what is a fairly common misconception
about how formats work with the HAL.
What are the definitions of physical, virtual and nominal in this
context?
The physical sample format is what the particular stream on the device
is transmitting it's data in.
The virtual sample format is the format in which your IOProc sends and
receives data.
By nominal, I assume you are referring to
kAudioDevicePropertyAvailableNominalSampleRates. In which case this is
the rate at which the device is set to run at. It is called nominal
because normally the device is really running faster or slower than
this rate.
In short, how do I provide the same choices in my GUI as are shown
in Audio MIDI Setup?
Check out the HALLab sample app in /Developer/Examples/CoreAudio/HAL.
It implements such pop-ups. IMHO, you probably want to display and
manipulate the physical formats with your pop-up.
--
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