Re: AudioConverterConvertBuffer and AudioBufferList?
Re: AudioConverterConvertBuffer and AudioBufferList?
- Subject: Re: AudioConverterConvertBuffer and AudioBufferList?
- From: Robert Grant <email@hidden>
- Date: Tue, 2 Sep 2003 12:53:49 -0400
Hi Brooks,
You can't use AudioConverterConvertBuffer to convert between
interleaved and non-interleaved buffers. (Even though the converter
doesn't return an error, it won't work.) You need to use the
AudioConverterFillComplexBuffer instead.
Take a look at my "article" at the CoreAudio Swiki. It's doing a
non-interleaved->interleaved conversion using the AudioConverter which
is the opposite of what you're attempting but it should prove useful:
http://www.mat.ucsb.edu:8000/CoreAudio/90
You should probably have a look around there for other stuff that might
be useful :-) And when you get your code working please feel free to
supplement the AudioConverter examples there :-)
Hope that helps,
Robert.
On Tuesday, September 2, 2003, at 01:40 AM, Brooks Bell wrote:
I've got a mixer AU that is set up with an input callback. In the
callback
I'm passed an AudioBufferList to fill.
The data I've got is in an interleaved buffer as PCM Signed int. I
need to
ready it for the mixer which wants float32, big endian,
non-interleaved (I
think).
I've got what I think is the correct AudioConverter and would like to
pass
it the AudioBufferList as the destination. Ideally the AudioBufferList
would get each channel in a ioData->mBuffers[channel].mData, which
looks
like the format that the mixer expects.
Can I do this? Or do I have to allocate my own temp contiguous
buffers and
then divide it out into the various ioData->mBuffers[channel].mData?
Are
the ioData->mBuffers[channel].mData buffers already allocated when my
input
call back for the mixer is called?
Here's the code:
AudioBufferList *ioData <- Parameter from the mixer input callback
already allocated
AudioConverterRef audioConverter;
OSStatus err;
AudioStreamBasicDescription inForm;
inForm.mSampleRate = m_SampleRate;
inForm.mFormatID = kAudioFormatLinearPCM;
inForm.mFormatFlags = kAudioFormatFlagIsSignedInteger;
inForm.mBytesPerPacket = 4;
inForm.mFramesPerPacket = 1;
inForm.mBytesPerFrame = 4;
inForm.mChannelsPerFrame = 2;
inForm.mBitsPerChannel = 16;
AudioStreamBasicDescription outForm;
outForm.mSampleRate = m_SampleRate;
outForm.mFormatID = kAudioFormatLinearPCM;
outForm.mFormatFlags =
kLinearPCMFormatFlagIsNonInterleaved |
kLinearPCMFormatFlagIsFloat | kAudioFormatFlagIsBigEndian ;
outForm.mBytesPerPacket = 4;
outForm.mFramesPerPacket = 1;
outForm.mBytesPerFrame = 4;
outForm.mChannelsPerFrame = 1;
outForm.mBitsPerChannel = 32;
err = AudioConverterNew(&inForm, &outForm, &audioConverter);
snd_assert(err == 0);
UInt32 outputDataSize = totalSize;
// *** What should the last parameter be?
err = AudioConverterConvertBuffer( audioConverter, totalSize,
inGetDataBuffer.pData, &outputDataSize, ioData->mBuffers); //
???
snd_assert(err == 0);
err = AudioConverterDispose(audioConverter);
snd_assert(err == 0);
_______________________________________________
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.