Manipulating PCM in Audio Queue Callback
Manipulating PCM in Audio Queue Callback
- Subject: Manipulating PCM in Audio Queue Callback
- From: Joey Green <email@hidden>
- Date: Wed, 7 Jul 2010 07:01:04 -0500
I'm trying to do some expensive PCM processing in "think" Audio Queue's would be the answer since it's not real-time. Well here is what I'm doing:
void AQRecorder::MyInputBufferHandler( void * inUserData,
AudioQueueRef inAQ,
AudioQueueBufferRef inBuffer,
const AudioTimeStamp * inStartTime,
UInt32 inNumPackets,
const AudioStreamPacketDescription* inPacketDesc)
{
AQRecorder *aqr = (AQRecorder *)inUserData;
float sineFrequency = aqr->mSineFrequency;
try {
if (inNumPackets > 0) {
SInt16 *pData = (SInt16*)inBuffer->mAudioData;
for(int nSamples = inBuffer->mAudioDataByteSize / sizeof(SInt16);nSamples-- > 0;pData++)
{
*pData = *pData / 16;
}
XThrowIfError(AudioFileWritePackets(aqr->mRecordFile, FALSE, inBuffer->mAudioDataByteSize,
inPacketDesc, aqr->mRecordPacket, &inNumPackets, pData),
"AudioFileWritePackets failed");
If I don't process pData in that for loop everything saids perfect normal during playback so I'm certain I'm accessing the rad data correctly. When I process this for loop, still too slow. Apparently my buffers are being filled quicker then how long my processng + writing the buffers out is taking.
What might one do to manipulate Audio Queue PCM with expensive algorithms and it WORK? Right now I plan on trying to copy to a new buffer and maybe processing that buffer on a new thread. Thats the only ideas I have.
Thanks to all that reply
_______________________________________________
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