Re: My AUHAL Output Audio Unit
Re: My AUHAL Output Audio Unit
- Subject: Re: My AUHAL Output Audio Unit
- From: Daniel Todd Currie <email@hidden>
- Date: Fri, 25 Jun 2004 13:35:01 -0700
Then in the sample code, shouldn't this line:
UInt32 numOfChannels = DesiredFormat.mChannelsPerFrame; // 2 channels
read:
UInt32 numOfChannels = DeviceFormat.mChannelsPerFrame; // 4 channels
I'm pretty sure I have the channel map set up correctly now, but I'm
still getting buffers full of zeros.
Has anyone had this problem before? It seems like AudioUnitRender()
isn't writing any data to my AudioBufferList, but I have no idea why.
AudioUnitRender() is returning noErr, so could that even be the
problem?
I also think my inputProc is screwed, because I am having to use all
these arrows in my code -> that I don't see in anyone else's stuff in
the docs or the archives. Here's my inputProc callback:
OSStatus recordIOProc(void *inRefcon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumFrames,
AudioBufferList *ioData)
{
Recorder *client = (Recorder *)inRefcon;
OSStatus err = AudioUnitRender(client->inputAudioUnit,
ioActionFlags,
inTimeStamp,
inBusNumber,
inNumFrames,
client->inputBuffer);
if(err == noErr)
{
unsigned dataSize =
client->inputBuffer->mBuffers[0].mDataByteSize;
client->tempBuffer = client->inputBuffer->mBuffers[0].mData;
[client->aQueue
writeBytesWithoutBlockingFrom:client->tempBuffer length:dataSize];
return(noErr);
}
else return(err);
}
Rather than use render notifications etc., I elected to just pull the
buffer using an MTCircularQueue (from MTCoreAudio). This callback
worked when I was using a straight HAL implementation, but now I am
upgrading to AUHAL and need to do something a little different?
-- DTC
On 2004 Jun 25, at 12:51, Doug Wyatt wrote:
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.
_______________________________________________
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.