Re: Acquiring input Data
Re: Acquiring input Data
- Subject: Re: Acquiring input Data
- From: Paul Barbot <email@hidden>
- Date: Mon, 20 Jun 2005 16:27:39 +0200
On 6/17/05, Heath Raftery <email@hidden> wrote:
hi ! thanks for your help
> 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 :
OSStatus SetInputFormat()
{
CAStreamBasicDescription DeviceFormat;
CAStreamBasicDescription DesiredFormat;
UInt32 size = sizeof(CAStreamBasicDescription);
//Get the input device format
AudioUnitGetProperty (InputUnit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input,
1,
&DeviceFormat,
&size);
//set the desired format to the device's sample rate
DesiredFormat.mSampleRate = DeviceFormat.mSampleRate;
//set format to output scope
return AudioUnitSetProperty(
InputUnit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output,
//1,
0,
&DesiredFormat,
sizeof(CAStreamBasicDescription));
}
> 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 ?
> 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 ??
--
Paul Barbot
_______________________________________________
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