Re: My AUHAL Output Audio Unit
Re: My AUHAL Output Audio Unit
- Subject: Re: My AUHAL Output Audio Unit
- From: Doug Wyatt <email@hidden>
- Date: Fri, 25 Jun 2004 12:51:57 -0700
On Jun 24, 2004, at 23:29, Daniel Todd Currie wrote:
I've just finished implementing my AUHAL Output Audio Unit according
to the sample code and docs available here:
http://developer.apple.com/technotes/tn2002/tn2091.html
I run it and look at the buffer data that comes pouring into my app
and it is just a big long list of zeros. :(
I have no idea where to begin troubleshooting, as the AU setup sample
code seems pretty thorough and I have checked for all of the
ComponentResult errors in my AudioUnitSetProperty calls. I was a bit
perplexed by one of the listings in the link above, so I wonder if it
could be the problem. The block of code from that page:
SInt32 *channelMap =NULL;
UInt32 numOfChannels = DesiredFormat.mChannelsPerFrame; //2 channels
UInt32 mapSize = numOfChannels *sizeof(SInt32);
channelMap = (SInt32 *)malloc(size);
//for each channel of desired input, map the channel from
//the device's output channel.
for(UInt32 i=0;i<numOfChannels;i++)
{
channelMap[i]=-1;
}
//channelMap[desiredInputChannel] = deviceOutputChannel;
channelMap[0] = 2;
channelMap[1] = 3;
AudioUnitSetProperty(InputUnit, kAudioOutputUnitProperty_ChannelMap,
kAudioUnitScope_Output, 1, channelMap, size);
That's Listing 5 on the web page. It's titled "an example of 4->2
channel mapping." It maps the third and fourth channels (indices 2 and
3) of the source device to 2 channels being provided to the client as
input.
You might not need this code. If you don't have any code like this,
then you should just be getting the first two channels of the device.
If you have a UI to select 2 channels out of the possibly many device
channels, then you will need some code like this -- set channelMap[0]
and channelMap[1] to the device channels that you want to map to your
stereo pair.
Aside from what seems like a typo where "size" is used instead of
"mapSize", I don't understand why channelMap elements are set once in
the for loop, and then once again after the for loop.
It's just being paranoid by putting map elements into a default state
before putting them into the desired state.
I implemented the AU for my own needs as best I could from this
example, but it makes sense that if I were somehow mapping the
channels incorrectly I might get a bunch of silence. Can anyone shed
a little light on the snippet above?
Doug
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.