Re: Using AudioQueueOfflineRender... (Daniel Staudigel)
Re: Using AudioQueueOfflineRender... (Daniel Staudigel)
- Subject: Re: Using AudioQueueOfflineRender... (Daniel Staudigel)
- From: "Roni Music" <email@hidden>
- Date: Tue, 6 Jan 2009 16:54:41 +0100
I'm a bit confused on how to use offline rendering of audio queues.
1) How many audio queues do you need?
I use 3 which works fine
never tested anything else
Most of the documentation is
about "playback queues", but it also references "render
callbacks" (which the docs say you define when you set up the offline
rendering), which I don't see referenced anywhere else. Does this
have to do with recording queues?
2) How do you prod it, I can get the first X samples out of a file,
but I can't loop it to get more than that, and when I try to, it never
calls my buffer enqueing callback.
If this is a console app, then I think you need to "fake" a run loop by
calling
CFRunLoopInMode() after each AudioQueueOfflineRender() call
also I think
time.mSampleTime += numSamples/format.mSampleRate;
is wrong, should be
time.mSampleTime += numSamples;
That works for me
The only problem I have is that the first 5120 audio frames contains
silence,
after that it works perfect.
I'm also priming the queue after AudioQueueStart(),
if priming before AudioQueueStart() the silence at start while be increased
by the same amount.
I've read on this list that there will be a technote comming soon to clarify
things
Rolf
Here's the code I've gotten to get the first X samples:
OSStatus res = AudioQueueSetOfflineRenderFormat(queueObject,
&format, &layout);
if(res) printosstatus(res);
AudioQueueBufferRef b;
while(!audioFile.doneWithFile && !!(b = [selfpopInactiveBuffer])) {
[self fillBufferRef:b];
}
NSFileHandle * outf = [NSFileHandle fileHandleForWritingAtPath:[@"~/
Documents/out.pcm" stringByExpandingTildeInPath]];
AudioQueueStart(self.queueObject, NULL);
while(self.isRunning) {
res = AudioQueueOfflineRender(queueObject, &time, buf, numSamples);
time.mSampleTime += numSamples/format.mSampleRate;
if(res) printosstatus(res);
short * temp = (short*)buf->mAudioData;
NSLog(@"Got %i bytes",buf->mAudioDataByteSize);
[outf writeData:[NSData dataWithBytesNoCopy:buf->mAudioData
length:buf->mAudioDataByteSize freeWhenDone:NO]];
}
[outf closeFile];
AudioQueueSetOfflineRenderFormat(queueObject,NULL,NULL);
Of note, fillBuffer: is the class-ified buffer enqueueing callback,
format is 16-bit signed packed, interleaved LPCM, and layout is stereo.
Thanks,
Daniel
_______________________________________________
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