PortMidi
Cross-platform MIDI IO library
PortTime: Millisecond Timer

Typedefs

typedef int32_t PtTimestamp
 real time or time offset in milliseconds.
 
typedef void() PtCallback(PtTimestamp timestamp, void *userData)
 a function that gets a current time
 

Enumerations

enum  PtError {
  ptNoError = 0 , ptHostError = -10000 , ptAlreadyStarted , ptAlreadyStopped ,
  ptInsufficientMemory
}
 PortTime error code; a common return type. More...
 

Functions

PMEXPORT PtError Pt_Start (int resolution, PtCallback *callback, void *userData)
 start a real-time clock service. More...
 
PMEXPORT PtError Pt_Stop (void)
 stop the timer. More...
 
PMEXPORT int Pt_Started (void)
 test if the timer is running. More...
 
PMEXPORT PtTimestamp Pt_Time (void)
 get the current time in ms. More...
 
PMEXPORT void Pt_Sleep (int32_t duration)
 pauses the current thread, allowing other threads to run. More...
 

Detailed Description

Enumeration Type Documentation

◆ PtError

enum PtError

PortTime error code; a common return type.

No error is indicated by zero; errors are indicated by < 0.

Function Documentation

◆ Pt_Sleep()

PMEXPORT void Pt_Sleep ( int32_t  duration)

pauses the current thread, allowing other threads to run.

Parameters
durationthe length of the pause in ms. The true duration of the pause may be rounded to the nearest or next clock tick as determined by resolution in Pt_Start().

◆ Pt_Start()

PMEXPORT PtError Pt_Start ( int  resolution,
PtCallback callback,
void *  userData 
)

start a real-time clock service.

Parameters
resolutionthe timer resolution in ms. The time will advance every resolution ms.
callbacka function pointer to be called every resolution ms.
userDatais passed to callback as a parameter.
Returns
#ptNoError on success. See PtError for other values.

◆ Pt_Started()

PMEXPORT int Pt_Started ( void  )

test if the timer is running.

Returns
TRUE or FALSE

◆ Pt_Stop()

PMEXPORT PtError Pt_Stop ( void  )

stop the timer.

Returns
#ptNoError on success. See PtError for other values.

◆ Pt_Time()

PMEXPORT PtTimestamp Pt_Time ( void  )

get the current time in ms.

Returns
the current time