Take 2: Combining AUHAL input and an AudioConverter
Take 2: Combining AUHAL input and an AudioConverter
- Subject: Take 2: Combining AUHAL input and an AudioConverter
- From: Heath Raftery <email@hidden>
- Date: Wed, 18 May 2005 03:01:23 +1000
Thanks for the help so far. I've made some significant progress on my
own, but in the great scheme of things, I really haven't got far. I'll
keep this email particular to the issue of using the AudioConverter
already discussed, and send another email specific to the issue I found
elsewhere.
To summarise the background info, I have an AUHAL input operating,
grabbing data from the default input device. Specifically it is of this
format:
AudioStreamBasicDescription: 2 ch, 44100 Hz, 'lpcm' (0x0000002B)
32-bit big-endian float, deinterleaved
I also have created an AudioConverter with the output format like this
(its in the QualCOMM format):
AudioStreamBasicDescription: 1 ch, 512 Hz, 'Qclp' (0x00000000) 0
bits/channel, 35 bytes/packet, 160 frames/packet, 0 bytes/frame
It now appears to be operating, collecting data and converting it into
an output buffer. I next want to be able to use the data in the output
buffer. Here's the relevant section of code (the audioArrived
callback):
<CODE>
AudioUnitRender(*fInputUnit, ioActionFlags, inTimeStamp, inBusNumber,
inNumberFrames, fBufferList);
int convertedFrames=0;
while(convertedFrames<inNumberFrames)
{
UInt32 framesRequested = inNumberFrames-convertedFrames;
AudioConverterFillComplexBuffer(fInputConverter,
supplyDataForConversionProc, self, &framesRequested,
fConvertedBufferList, NULL);
convertedFrames+=framesRequested;
}
</CODE>
My fConvertedBufferList certainly appears to be getting touched. But
how do I know how much data was written to it, and where. In other
words, how can I pull out the converted data? The mDataByteSize in
fConvertedBufferList appears to have been changed to 28000, which seems
a little excessive given it only claims to have converted 800 frames of
4bytes/frame, 44.1kHz lpcm data. Why indeed, did I allocate the data
buffer in my fConverterBufferList in the first place? Was this
unnecessary - will AudioConverterFillComplexBuffer allocate the out
buffer itself (as it appears to do anyway)?
I figured the last parameter of AudioConverterFillComplexBuffer,
outPacketDescription, would be a good place to get some of this info,
as the CA docs say that "outPacketDescription will contain the format
of the returned data". But try as I might, if I enter any value here
other than NULL, the app EXC_BAD_ACCESS's. How do I use this parameter?
FYI, my SupplyDataForConversion callback looks like this:
<CODE>
for(i=0; i<fBufferList->mNumberBuffers; ++i)
{
ioData->mBuffers[i].mNumberChannels =
fBufferList->mBuffers[i].mNumberChannels;
ioData->mBuffers[i].mData = fBufferList->mBuffers[i].mData;
ioData->mBuffers[i].mDataByteSize =
fBufferList->mBuffers[i].mDataByteSize;
}
*ioNumberDataPackets = ioData->mBuffers[0].mDataByteSize /
sizeof(Float32);
</CODE>
Regards,
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