Re: Converting AudioTimeStamp between two devices
Re: Converting AudioTimeStamp between two devices
- Subject: Re: Converting AudioTimeStamp between two devices
- From: Andrew Kimpton <email@hidden>
- Date: Thu, 1 Jun 2006 23:31:07 -0400
On Jun 1, 2006, at 11:15 PM, Jeff Moore wrote:
Nope. In this case, you have two clocks to deal with. Each clock
can have it's own idea of where 0 was and they are running at
different rates, so the relationship between the clocks is more
complicated.
Ok - I think this answers a second question I was about to ask about
using the host time fields on their own to work out how far apart the
devices are. If I want to use the host time fields I have to account
for the device start time for each device before I attempt to
calculate the differences - correct ?
As you note, an aggregate device solves relating the clocks between
the devices and dealing with the synchronization issues so you
don't have to.
Yeah - and that would be the recommended solution, but we still have
to advise users to choose the aggregate device (even if we create it
for them) when recording.
So I'm attempting to convert the output timestamp to an input
timestamp using AudioDeviceTranslateTime() as follows :
AudioTimeStamp firstPlayTime = iFirstPlayTimeStamp;
AudioTimeStamp firstPlayTimeForInputDevice;
firstPlayTime.mFlags = kAudioTimeStampSampleHostTimeValid;
memset(&firstPlayTimeForInputDevice,0,sizeof
(firstPlayTimeForInputDevice));
firstPlayTimeForInputDevice.mFlags = kAudioTimeStampSampleTimeValid;
OSStatus osStatus = AudioDeviceTranslateTime
(iInputDeviceID,&firstPlayTime,&firstPlayTimeForInputDevice);
The problem with your code is that you are providing too much
information in the first time stamp. You are saying, in effect,
"here's a time stamp with both a valid sample time and a valid host
time, please give me the sample time". The HAL is happy to oblige.
What you really want to say is "here's a time stamp with a valid
host time, please translate that to a sample time." To do this, you
just need to set kAudioTimeStampHostTimeValid in the flags field of
firstPlayTime.
But I (think) I'm doing that - the code above has the line
firstPlayTime.mFlags = kAudioTimeStampSampleHostTimeValid;
Isn't that what you meant ? I don't bother to zero out the other
fields in firstPlayTime but is that required if I just indicate
that only the host time is valid ?
BTW, simply translating the time stamps is not going to be enough
to keep things in synch. That just allows you to get things to
start out in synch. Since the two devices are running at different
rates, you will also need to deal with the clock drift over time.
That's OK - I'm just concerned with ignoring those samples I've
acquired too early. Resampling etc during the rest of the recording
is a whole other issue 8-)
Andrew 8-)
_______________________________________________
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