Re: Acquiring input Data
Re: Acquiring input Data
- Subject: Re: Acquiring input Data
- From: Heath Raftery <email@hidden>
- Date: Tue, 21 Jun 2005 09:45:28 +1000
On 21/06/2005, at 12:27 AM, Paul Barbot wrote:
On 6/17/05, Heath Raftery <email@hidden> wrote:
Looks far too small to me, which would cause the -50. I'd need to see
your InputUnit's AudioStreamBasicDescription to really know what your
theBufferList should look like,
I use the description of the technote :
I meant the content of the StreamBasicDescription. For example, after
your AudioUnit is set up, try the following:
CAStreamBasicDescription asbdClient;
UInt32 theSize = sizeof(asbdClient);
AudioUnitGetProperty(fInputUnit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output,
1,
&asbdClient,
&theSize);
printf("client format:\n");
asbdClient.Print();
And check the output log.
but here's a guess based on my
experience. All my input data has been 2 channel deinterleaved, so
for starters you need two buffers with one channel each.
I just need one channel (mono sound) for my project, do you know
how to
set in that way ?
There's a few ways, but in each case you actually need to collect the
stereo (or whatever the InputUnit is going to give) first and convert
to mono later. In my project I collect however many channels the
InputUnit says it has, and then only use the first channel. That
should work for you as well.
Easiest way
to do this is probably to have a pointer to theBufferList, instead of
allocating it statically. That way you can do this:
AudioBufferList *theBufferListPtr;
theBufferListPtr = malloc(sizeof(AudioBufferList) + sizeof
(AudioBuffer)); //enough room for two buffers
theBufferListPtr->mNumberBuffers = 2;
theBufferListPtr->mBuffers[0].mNumberChannels = 1;
theBufferListPtr->mBuffers[1].mNumberChannels = 1;
UInt32 bufferSizeBytes, bufferSizeFrames=0;
UInt32 theSize = sizeof(bufferSizeFrames);
err = AudioUnitGetProperty(InputUnit,
kAudioDevicePropertyUsesVariableBufferFrameSizes,
kAudioUnitScope_Global, 0, &bufferSizeFrames, &theSize);
if(err)
AudioUnitGetProperty(InputUnit,
kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Global, 0,
&bufferSizeFrames, &theSize);
bufferSizeBytes = bufferSizeFrames * sizeof(Float32);
Which checks to see if the device uses variable buffer sizes. If it
does, it gets the max value, otherwise it gets the normal buffer
size. Then all you have to do is this:
theBufferListPtr->mBuffers[0].mDataByteSize = bufferSizeBytes;
theBufferListPtr->mBuffers[0].mData = malloc
(bufferSizeBytes);
theBufferListPtr->mBuffers[1].mDataByteSize = bufferSizeBytes;
theBufferListPtr->mBuffers[1].mData = malloc
(bufferSizeBytes);
You'll see bufferSizeBytes is in the order of 2048 or 3200.
I have tried to do that but I have no more call of the callback
where I must put that allocation ??
That's odd! It wasn't supposed to affect the calling of your
callback. Just replace your allocation (your
"theBufferList.mNumberBuffers = 1;" etc.) with what I've posted.
Remember to declare the global variable "AudioBufferList
*theBufferListPtr;". As long as you allocate before your callback is
called, but after InputUnit has been connected to the
DefaultOutputUnit, you should be fine. If your callback is not being
called something else must have gone screwy - check to make sure your
"MyInputCallbackSetup()" and "InitAndStartAUHAL()" is working right.
Heath
_______________________________________________
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