Re: Selecting audio output devices
Re: Selecting audio output devices
- Subject: Re: Selecting audio output devices
- From: Andy Robinson <email@hidden>
- Date: Thu, 02 Aug 2012 09:53:53 +0100
- Organization: Seventh String Software
Thanks for this.
I've now found a very good book which I'm looking at, I think it only
just came out earlier this year:
"Learning Core Audio: A Hands-On Guide to Audio Programming for Mac and
iOS" by Chris Adamson & Kevin Avila.
I've also discovered the answer for selecting outputs (I think, though I
haven't actually tried it yet) for devices such as the Duet which has 2
independent stereo outputs: it only shows up as a device once, but when
you get its stream configuration (aopa.mSelector =
kAudioDevicePropertyStreamConfiguration) it reports 1 output stream,
having 4 channels. This is not ideal - I'd rather it reported 2 streams
each having 2 channels. But it should be possible to do something with that.
Regards,
Andy Robinson, Seventh String Software, www.seventhstring.com
On 22/07/12 13:47, Thomas Hass wrote:
I recently had to figure this out myself. You'll want to become very
familiar with everything in AudioHardware.h in the CoreAudio framework.
Those are all the functions and properties that you will use to get
information about each device.
These are the steps I took:
1) Build a list of audio device objects where each object contains a
device's AudioDeviceID, number of input channels, number of output
channels, available sample rates, and a human readable name that you can
present to the user. You will use AudioHardware.h for this. You start
by getting an array of AudioDeviceIDs from the system like so:
AudioObjectPropertyAddress devicesProperty = {
kAudioHardwarePropertyDevices,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
}
UInt32 dataSize = 0;
AudioObjectGetPropertyDataSize(kAudioObjectSystemObject,
&devicesProperty, 0 , NULL, &dataSize);
UInt32 numDevices = dataSize/sizeof(AudioDeviceID);
AudioDeviceID allDeviceIDs[numDevices];
AudioObjectGetPropertyData(kAudioObjectSystemObject, &devicesProperty,
0, NULL, &dataSize, allDeviceIDs);
// Each AudioDeviceID in this array now represents an audio device on
your system. You can now use this id
// to get attributes about each device via the properties in
AudioHardware.h.
2) Present the human-readabable names to the user.
3) Once the user has picked one. Setup an AUHAL output unit and set its
current device property to the AudioDeviceID that corresponds to the
user-selected device. Also note that you can use the
kAudioDevicePropertyStreamConfiguration property to know what the buffer
list in the IOProc will look like for a device.
Unfortunately, CAPlayThrough was the only example code I could find when
I was learning this stuff as well. This definitely requires a lot more
code than on iOS. My advice would be to do your best, and then ask
specific questions as you get stuck.
-Thomas Hass
On Sun, Jul 22, 2012 at 5:01 AM, Andy Robinson <email@hidden
<mailto:email@hidden>> wrote:
Yes, thanks. The only thing is, it says "Runtime Requirements: Mac
OS X v10.7 or later".
However I will take a look at it, to see if the parts I want might
run on 10.6.
I've also been recommended to look at
https://github.com/liscio/__CAPlayThrough
<https://github.com/liscio/CAPlayThrough>
Regards,
Andy Robinson
On 21/07/12 22:19, Jason Perkins wrote:
Try the CAPlay example:
http://developer.apple.com/__library/mac/#samplecode/__CAPlayThrough/Introduction/__Intro.html#//apple_ref/doc/__uid/DTS10004443
<http://developer.apple.com/library/mac/#samplecode/CAPlayThrough/Introduction/Intro.html#//apple_ref/doc/uid/DTS10004443>
On Jul 20, 2012, at 6:22 AM, Andy Robinson wrote:
Hello, is there any sample code showing how to select and
use different audio output devices?
For OS 10.6 and later.
_________________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden
<mailto:email@hidden>__)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/__mailman/options/coreaudio-api/email@hidden
This email sent to email@hidden <mailto:email@hidden>
_______________________________________________
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