• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
AudioConverterConvertBuffer and AudioBufferList?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AudioConverterConvertBuffer and AudioBufferList?


  • Subject: AudioConverterConvertBuffer and AudioBufferList?
  • From: Brooks Bell <email@hidden>
  • Date: Tue, 02 Sep 2003 01:40:48 -0400

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.

  • Follow-Ups:
    • Re: AudioConverterConvertBuffer and AudioBufferList?
      • From: Robert Grant <email@hidden>
  • Prev by Date: Re: Getting the host
  • Next by Date: Sample player streaming from disk
  • Previous by thread: Re: Getting the host
  • Next by thread: Re: AudioConverterConvertBuffer and AudioBufferList?
  • Index(es):
    • Date
    • Thread