PortMidi timestamps are integers in millisecond units. It's a little
complicated because time can be provided via a function pointer,
allowing you to use, say, an audio stream as a time reference rather
than the system clock. (Audio DACs have their own crystal clock, so they
do not stay accurately synchronized to the system clock which is tied to
a different crystal in most systems.) So timestamps can be based on any
clock, but they still need to be milliseconds within a small tolerance
(< 0.1% is assumed). Note that these are not necessarily related to wall
time in any way, so if you want absolute time, you should provide your
own time reference and manage the mapping to absolute time yourself.
Here's some detail from the documentation for Pm_OpenInput:
time_proc is a pointer to a procedure that returns time in milliseconds.
It may be NULL, in which case a default millisecond timebase (PortTime)
is used. If the application wants to use PortTime, it should start the
timer (call Pt_Start) before calling Pm_OpenInput or Pm_OpenOutput. If
the application tries to start the timer *after* Pm_OpenInput or
Pm_OpenOutput, it may get a ptAlreadyStarted error from Pt_Start, and
the application's preferred time resolution and callback function will
be ignored. time_proc result values are appended to incoming MIDI data,
and time_proc times are used to schedule outgoing MIDI data (when
latency is non-zero).
time_info is a pointer passed to time_proc.
Example: If I provide a timestamp of 5000, latency is 1, and time_proc
returns 4990, then the desired output time will be when time_proc
returns timestamp+latency = 5001. This will be 5001-4990 = 11ms from now.
-Roger
On 7/11/11 4:11 AM, Tim Burgess wrote:
Could somebody please clarify what the time stamp values of PortMIDI
messages represent? I'm wanting to convert them to something
meaningful in hours, minutes, seconds, etc..
<http://lists.create.ucsb.edu/mailman/listinfo/media_api>
_______________________________________________
media_api mailing list
[email protected]
http://lists.create.ucsb.edu/mailman/listinfo/media_api