Re: Audio Queue metronome
Re: Audio Queue metronome
- Subject: Re: Audio Queue metronome
- From: William Stewart <email@hidden>
- Date: Wed, 30 Jun 2010 13:07:50 -0700
On Jun 30, 2010, at 12:26 PM, Evan Olcott wrote:
> Coming from experience, this is not the way to write a metronome.
>
> 1. AudioQueues have an inherent latency of a full buffer length - at least. You're not going to be able to sync with the UI.
The time stamp that you use with an audio queue is the time when the sample is submitted to the hardware (from AudioQueue Get Current Time). This gives you just as much idea of when the sample will be heard as from an audio unit. (You look at the host time of that time stamp, so you can then relate the time of when the sample is played to when you need to draw).
These time stamps are how video playback is synchronised, so if there is any inherent problem here like you describe, that would be a major problem for the system.
> 2. NSTimer is not guaranteed to be accurate enough for a metronome
> 3. Polling is too CPU-intensive for this task (in general polling is not good. "notifications" are better.)
>
> You want to use the AUGraph system along with the hardware sample rate to decide where to put your click sounds in the render buffers. That's the most accurate way to do it. Also be aware of thread decoupling when you want drawing to "sync up" with your audio.
Yes, but this is because you aren't using time stamps, but you are just counting samples. Basically, this is more complicated than you need to do for this task, and if you use the time stamps from audio queue, it does all of this work for you.
>
> Ev
> Senior Software Architect
> Audiofile Engineering
>
> http://www.audiofile-engineering.com/
>
>
>
>
>
>
>
>
> _______________________________________________
> 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
_______________________________________________
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