Re: Speaker setup + possible typo in CoreAudioTypes.h label value?
Re: Speaker setup + possible typo in CoreAudioTypes.h label value?
- Subject: Re: Speaker setup + possible typo in CoreAudioTypes.h label value?
- From: Derk-Jan Hartman <email@hidden>
- Date: Thu, 24 Mar 2005 21:52:53 +0100
Incorrect. It does not handle up/downmixing of channels
I'm not interested in channel redirection. I'm interested in channel up
and down mixing.
channel redirection is another thing. VLC can do 5.1 -> 4.0 mixing for
instance. I just need to know which format my device will understand
before I send it the audio.
Not that it will work in my setup, because I just discovered that the
m-audio sonica in for instance 4.0 setup reports back as a L R C LFE
device. But that's an issue with m-audio's drivers.
Another approach would be to implement 3d mixing in
coreaudio/audiotoolbox, but I'm saving that for another day.
DJ
On 24 mrt 2005, at 21:22, William Stewart wrote:
However, the general approach you describe below is doing alot more
work than you need to.
AU Hal will do channel redirection itself as long as you tell it what
channel order you are providing to it as input.
So, it really is as simple as the following:
(1) Construct an AudioChannelLayout that describes the order of the
channels you are using.
// Lets say that you are providing 6 channels that can be
represented by the layout tag:
kAudioChannelLayoutTag_DVD_12 =
kAudioChannelLayoutTag_MPEG_5_1_A, // L R C LFE Ls Rs
This can be as simple as:
AudioChannelLayout layout;
memset (&layout, 0, sizeof(layout));
layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_12;
(We can use a basic layout because we are not providing channel
descriptions)
(2) AUHAL has a render input callback with a stream description that
says we will provide 6 channels - the number of channels you specify
in the input stream format and the number of channels in the layout
MUST match. You set the layout after setting the format.
(3) Tell AUHAL what the order of the channels we are providing is:
AudioUnitSetProperty (myHALAU,
kAudioUnitProperty_AudioChannelLayout,
kAudioUnitScope_Input, 0,
&layout, sizeof(layout));
Note: We set this on the Input scope and elementID (== 0) that we are
using
That's it - it does everything you are doing below for you (well,
actually more because you haven't described what you then have to do
to get the audio out to those speakers)...
Bill
ps Some comments on your code below.
On 23/03/2005, at 7:42 PM, Derk-Jan Hartman wrote:
On 23 mrt 2005, at 22:00, Derk-Jan Hartman wrote:
On 23 mrt 2005, at 21:19, James McCartney wrote:
On Mar 23, 2005, at 11:40 AM, William Stewart wrote:
On 23/03/2005, at 8:51 AM, Derk-Jan Hartman wrote:
But to me it's sheer impossible to find out what channels should
be downmixed to. I mean how am i supposed to know what channel is
LFE, what channel is the Center speaker.
Well, that's all clearly specified either:
(1) In the bitmap
(2) In the channel descriptions
(3) Implied in the layout tag
[...]
Aaaaah, this looks like it's more what I was looking for. Thank you
for this. I knew there had to be a way under 350 lines of switch
case statements.
For ppl who didn't follow this thread. This queries the current
speakersetup for the device, it does NOT *set* a channel layout for
the data provided to the AUHAL.
So for anyone else who ever wants to do this, you'll be looking for
something like this:
/* Get the channel layout */
AudioChannelLayout layout;
This is a variable length structure...
This should be a pointer
/* Notice that this query is on the output scope of the AU and
asks for a Device property.
This was the only way i could get this working */
verify_noerr( AudioUnitGetPropertyInfo( p_sys->au_unit,
kAudioDevicePropertyPreferredChannelLayout,
kAudioUnitScope_Output,
0,
&i_param_size,
NULL ));
layout = (AudioChannelLayout*)malloc (i_param_size);
verify_noerr( AudioUnitGetProperty( p_sys->au_unit,
kAudioDevicePropertyPreferredChannelLayout,
kAudioUnitScope_Output,
0,
&layout,
&i_param_size ));
/* Lets fill out the ChannelLayout */
if( layout.mChannelLayoutTag ==
kAudioChannelLayoutTag_UseChannelBitmap)
{
msg_Dbg( p_aout, "bitmap defined channellayout" );
verify_noerr( AudioFormatGetProperty(
kAudioFormatProperty_ChannelLayoutForBitmap,
sizeof( UInt32),
&layout.mChannelBitmap,
&i_param_size,
&layout ));
}
else if( layout.mChannelLayoutTag !=
kAudioChannelLayoutTag_UseChannelDescriptions )
{
msg_Dbg( p_aout, "layouttags defined channellayout" );
verify_noerr( AudioFormatGetProperty(
kAudioFormatProperty_ChannelLayoutForTag,
sizeof( AudioChannelLayoutTag ),
&layout.mChannelLayoutTag,
&i_param_size,
&layout ));
}
msg_Dbg( p_aout, "Layout of AUHAL has %d channels" ,
layout.mNumberChannelDescriptions );
p_aout->output.output.i_physical_channels = 0;
for( i = 0; i < layout.mNumberChannelDescriptions; i++ )
{
switch( layout.mChannelDescriptions[i].mChannelLabel )
{
case kAudioChannelLabel_Left:
p_aout->output.output.i_physical_channels |=
AOUT_CHAN_LEFT;
continue;
case kAudioChannelLabel_Right:
p_aout->output.output.i_physical_channels |=
AOUT_CHAN_RIGHT;
continue;
case kAudioChannelLabel_Center:
p_aout->output.output.i_physical_channels |=
AOUT_CHAN_CENTER;
continue;
case kAudioChannelLabel_LFEScreen:
p_aout->output.output.i_physical_channels |=
AOUT_CHAN_LFE;
continue;
case kAudioChannelLabel_LeftSurround:
p_aout->output.output.i_physical_channels |=
AOUT_CHAN_REARLEFT;
continue;
case kAudioChannelLabel_RightSurround:
p_aout->output.output.i_physical_channels |=
AOUT_CHAN_REARRIGHT;
continue;
case kAudioChannelLabel_LeftCenter:
p_aout->output.output.i_physical_channels |=
AOUT_CHAN_MIDDLELEFT;
continue;
case kAudioChannelLabel_RightCenter:
p_aout->output.output.i_physical_channels |=
AOUT_CHAN_MIDDLERIGHT;
continue;
case kAudioChannelLabel_CenterSurround:
p_aout->output.output.i_physical_channels |=
AOUT_CHAN_REARCENTER;
continue;
default:
msg_Warn( p_aout, "Unrecognized channel form provided
by driver: %d", layout.mChannelDescriptions[i].mChannelLabel );
}
}
---
Universiteit Twente
Derk-Jan Hartman (d.hartman at student.utwente dot nl)
http://home.student.utwente.nl/d.hartman
_______________________________________________
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
-- mailto:email@hidden
tel: +1 408 974 4056
_______________________________________________________________________
___
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
_______________________________________________________________________
___
---
Universiteit Twente
Derk-Jan Hartman (d.hartman at student.utwente dot nl)
http://home.student.utwente.nl/d.hartman
_______________________________________________
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