Re: Hosttime?
Re: Hosttime?
- Subject: Re: Hosttime?
- From: Kurt Revis <email@hidden>
- Date: Tue, 11 Feb 2003 12:37:19 -0800
On Tuesday, February 11, 2003, at 12:44 AM, Vigour Vigour wrote:
I wonder if I always must use 'AudioConvertHostTimeToNanos' to add for
example 1 sec (1000000000) to the hosttime? And after the adding use
'AudioConvertNanosToHostTime'. ?
Why can't I just add directly to the hosttime? I know that there must
be a reason fo this, but I don't really get it. Can someone explain
this please?
Here's how it works. The HostTime is a value that steadily increases
as the computer runs. The rate at which it increases is not directly
connected to any human notion of time... it's not in nanoseconds or
anything in particular. In current OS X software and hardware, the
length of a HostTime unit is related to the bus speed of the computer,
but it's not guaranteed that will always be the case.
You *are* guaranteed, however, that the length of one HostTime unit
will not change while the machine is running (and, by extension, while
your program is running).
So let's say you want to listen for MIDI input, and when you get a
note, send it back out over MIDI one second later. On the received
note, you get a timestamp in HostTime units. To make the new
(outgoing) timestamp, you could add one second's worth of HostTime
units to it:
newTimestamp = oldTimestamp +
AudioConvertNanosToHostTime(1000000000);
In other words, you do not always have to do math in terms of real time
(seconds or nanoseconds). You can add or subtract HostTime values
without any problems. You just need to make sure you convert from real
time to HostTime when appropriate.
Make sense?
--
Kurt Revis
email@hidden
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.
References: | |
| >Hosttime? (From: "Vigour Vigour" <email@hidden>) |