class NatML.Recorders.Clocks.FixedIntervalClock : IClock

This clock provides timestamps that advance in fixed intervals. This is useful for controlling the output frame rate for some recorders, and in offline recording.

Creating the Clock

/// <summary>
/// Create a fixed interval clock for a given framerate.
/// </summary>
/// <param name="frameRate">Desired framerate for clock's timestamps.</param>
/// <param name="autoTick">Optional. If true, the clock will tick when its `timestamp` is accessed.</param>
FixedIntervalClock (float frameRate, bool autoTick = ...);

The frameRate parameter determines the frame rate which the generated timestamps should generate. The autoTick parameter determines whether the clock should automatically advance its timestamp when the timestamp property is accessed. In most use cases, this is best left as true.

The Time Interval

/// <summary>
/// Interval between consecutive timestamps generated by the clock in seconds.
/// </summary>
double interval { get; }

The interval is the amount of time between consecutive timestamps in seconds. For some recorders, this property determines the true frame rate of the video.

Generating Timestamps

/// <summary>
/// Current timestamp in nanoseconds.
/// </summary>
long timestamp { get; }

Refer to the Generating Timestamps section of the IClock interface for more information.

Advancing the Timestamp

When the clock is not set to autoTick, you must call Tick to advance its timestamp.

/// <summary>
/// Advance the clock by its time interval.
/// </summary>
void Tick ();

Last updated