Re: Calculating precise time in audio apps
Re: Calculating precise time in audio apps
- Subject: Re: Calculating precise time in audio apps
- From: "T.J. Usiyan" <email@hidden>
- Date: Mon, 05 Nov 2012 07:08:52 -0500
Hello,
I think mach_absolute_time() is going to be your best bet. You will
have to convert from host ticks to seconds/samples.
This is how I did that before (I am somewhat new to all of this, so
maybe I am doing it incorrectly.)
` kern_return_t lError;
mach_timebase_info_data_t lTimeInfo;
lError = mach_timebase_info(&lTimeInfo);
if (lError != KERN_SUCCESS) {
NSLog(@"Error getting mach_timebase_info");
return;
}
mHostToNanoseconds = (double)lTimeInfo.numer / lTimeInfo.denom;
mNanoToHostTicks = (double)lTimeInfo.denom / lTimeInfo.numer;
NSLog(@"mToNanoseconds %f", mHostToNanoseconds);
NSLog(@"mToHostTicks %f", mNanoToHostTicks
`
On Sun, Nov 4, 2012 at 10:37 PM, Pier <email@hidden> wrote:
>
> Hi all,
>
> I'm doing an audio app where I need to manipulate audio buffers in real time for different sounds. I need a asynchronous clock running in the background that i can pull the time in various callbacks good to the millisecond for various audio manipulation purposes like the stop and start times of my audio playback, and when it records and stops recording.
>
> I need it to be so such that the precision allows me to determine latency caused by the various processes and compensate for it in my code.
>
> Any suggestions how one would implement such a clock in iOS? I have a feeling NSTimer won't cut it.
>
> Thank you.
>
> Pier.
>
>
> _______________________________________________
> 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