Re: Notification of Audio Queue playback
Re: Notification of Audio Queue playback
- Subject: Re: Notification of Audio Queue playback
- From: Doug Wyatt <email@hidden>
- Date: Tue, 1 Dec 2009 18:41:43 -0800
A lot depends on whether you want to drive the audio from the video or vice versa. Usually it's better to let the audio be the master, since it's much harder to "bend" the audio timeline than to synchronize other events to the audio.
Enqueueing a timestamped buffer is the way to go when you want to make the audio queue the slave instead of the master.
Getting *back* a timestamp on the buffer from AudioQueueEnqueueBufferWithParameters can be useful.
In your situation, you might correlate the queue's current sample time with loop iterations if you know how long the loop is, in sample frames at the queue sample rate. Assuming you started the loop at the same you started the queue, then if the loop length is N, a new iteration begins at every queue current sample time that's a multiple of N.
Yes, polling feels a bit ugly, but consider an app doing something as simple as drawing a position indicator while music plays: it has to run a timer and update the indicator 20+ times a second.
Doug
On Dec 1, 2009, at 14:04 , Michael Becker wrote:
> Am 01.12.2009 um 22:24 schrieb Aaron B.:
>> I'm no expert, but I've been trying to do something similar, and it
>> sounds like what you need to do is use
>> AudioQueueEnqueueBufferWithParameters to enqueue the playback buffer.
>> Check it out in the online reference. It returns the exact time the
>> buffer will start playing.
>
> But I still don't know the actual *moment in real time* that my buffer starts playing. I merely know at which point it will start within the AudioQueue's timeline. Besides that, my app loops audio (meaning I do not want to delay audio playback) so AudioQueueEnqueueBufferWithParameters is not what I would use.
> In the end, I would like to synch visuals to the audio every time a new loop starts.
>
>> You can also request the buffer to play at
>> a specific time, although it is not guaranteed---presumably it will
>> play your buffer at the requested time or as soon as the previously
>> scheduled buffers have finished playing, whichever is later.
>>
>> - Aaron
>>
>> On Tue, Dec 1, 2009 at 4:12 PM, Michael Becker <email@hidden> wrote:
>>> Hi everyone,
>>> I am still trying to synch what people hear and what people see on the
>>> iPhone, and if I do not completely misunderstand the docs, AudioQueue is the
>>> way to go. The audio part of my app actually works nicely. But I am
>>> wondering, how to go about the "video synching". For starters, I would be
>>> happy if I could get *any* kind of synching, e.g. displaying images
>>> depending on what my AudioQueue does.
>>> So I have two questions:
>>> (1) Is there any way to know (code-wise) when an audio-buffer is being
>>> played? At the moment, I have the AudioQueue run in a separate thread in a
>>> loop, and the loop constantly polls the AudioQueue for its current playback
>>> position. Although it works, this seems kind of awkward to me from a
>>> technical point of view. Furthermore, I cannot see how this should be the
>>> promised "audio-video-synching" feature of the AudioQueue.
>>> (2) How else would one do this? I have asked this before (unfortunately
>>> without any reaction), but to quote the documentation: "You can use
>>> (AudioQueue) to synchronize (...) audio with video.". That's what I'd like
>>> to do, but I don't know how.
>>> Sorry for the rather long mail, but I am really lost here.
>>> Kind regards,
>>> Michael
_______________________________________________
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