Re: AudioConverterConvertBuffer() and interleaved data
Re: AudioConverterConvertBuffer() and interleaved data
- Subject: Re: AudioConverterConvertBuffer() and interleaved data
- From: Doug Wyatt <email@hidden>
- Date: Thu, 22 Sep 2005 08:52:05 -0400
On Sep 22, 2005, at 3:08, Herbie Robinson wrote:
Also, for core audio, each channel has to be in it's own
buffer. [Right Bill?]
Consider the diagram earlier in this thread:
L L L R R R
For a moment I thought of replying that it might be more accurate to
show it like this:
L L L
R R R
indeed, to emphasize that the two channels' data had to be in
separate buffers, but -- what is a buffer but a pointer?
For example, one could allocate memory for a deinterleaved
AudioBufferList as follows, in a single allocation.
#include <CoreAudio/CoreAudioTypes.h>
#include <stdlib.h>
#include <stddef.h>
int i;
static const int kNumChannels = 2;
static const int kNumFrames = 512;
const int kBytesPerChannel = kNumFrames * sizeof(Float32);
char *buffer = malloc(kNumChannels * kBytesPerChannel);
AudioBufferList *abl = (AudioBufferList *)malloc(offsetof
(AudioBufferList, mBuffers[kNumChannels]));
abl->mNumberBuffers = kNumChannels;
for (i = 0; i < kNumChannels; ++i) {
abl->mBuffers[i].mNumberChannels = 1;
abl->mBuffers[i].mDataByteSize = kBytesPerChannel;
abl->mBuffers[i].mData = (Float32 *)(buffer + i * kBytesPerChannel);
}
That's the part that I always forget when dealing with the
converter. Don't know why exactly, I know that's the convention
for AUs, but it doesn't click when dealing with the file converter.
Non-interleaved data in a single buffer does exist, BTW (look at DV
files sometime).
OK, I haven't looked at DV, but can't you just point the buffer
pointers at the right places? AudioConverter makes no assumptions
about where the multiple arrays of deinterleaved samples sit in
memory and that seems like a good thing.
Doug
--
Doug Wyatt
Core Audio, Apple
_______________________________________________
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