Hi,
Thanks for your reply. I needed to sync audio time with motion sensor time, so couldn't use mSampleTime.
I actually figured out what I needed from audioTimeStamp. If anyone needs, here it is:
I wanted to get audio time in "number of seconds since the device booted", because that's the unit core motion's timestamp from CMLogItem gives.
So I took the mHostTime, which from my understanding is in number of ticks since device booted, and converted into number of seconds since device booted using the mach time base info.
#include <mach/mach_time.h>
// evaluate the timeStamp in secods static mach_timebase_info_data_t timeBaseInfo; if (timeBaseInfo.denom == 0) { (void) mach_timebase_info(&timeBaseInfo); } double time2nsFactor = (double) timeBaseInfo.numer / timeBaseInfo.denom; double timeStamp = (audioTimeStamp->mHostTime * time2nsFactor)/pow(10,9); //because origin mHostTime*factor gives in nanoseconds
Regards,
Tusi
On Jan 7, 2014, at 9:08 AM, Robert Carroll < email@hidden> wrote: My impression is that normally the mSampleTime is the timing information you should need, unless you have a specific reason to convert to mach_absolute_time. The timebase using information from the machine that the code is running on, ie. the clock frequency etc.
There is some older sample code from Doug Wyatt that covers this. Take a look at CAHostTimebase.h, & cpp in Core Audio/Public Utilities.
Others on this list can probably be more helpful.
regards,
Robert Carroll RSM Records Toronto
Hi,
I am confused about how to extract current audio data timestamp from audioTimeStamp struct.
I want the current audio data buffer’s data timestamps handed to me from core audio input unit through callback function.
the audioTimeStamp struct include following:
mHostTime The host machine's time base, mach_absolute_time.
what is the “base”?
How do I use this to get the audio sample timestamp in mach_absolute_time?
Thanks for the help.
|