Skip to content

SourceTimeline

Defined in: clock.ts:71

Maps timestamps from a clock with its own origin and rate onto the broadcast timeline: an AudioContext’s time (works in every browser), or Chromium’s MediaStreamTrackProcessor timestamps, which count from the system’s monotonic zero, not from performance.now()’s.

readonly anchorSourceUs: number | undefined;

Defined in: clock.ts:73

The source time of the current anchor; undefined until the first calibration or timestamp.


captureLatencyUs: number;

Defined in: clock.ts:79

How long the capture device holds a sample before the source sees it, in integer microseconds, subtracted from every timestamp so it stays the capture time. No browser API reports it: set it from a known device latency, and again when the device changes. It does not affect calibration.

calibrate(sourceUs, atUs?): boolean;

Defined in: clock.ts:86

Record that source time sourceUs happened at atUs on the broadcast clock’s own source (default: now), for example an AudioContext time and the performance.now() time it was rendered at, both in microseconds. The pair becomes the anchor when there is none, or when the current anchor predicts it more than toleranceUs off: the source drifted, or jumped, as an AudioContext does when it is replaced. Returns whether the anchor changed.

Parameter Type
sourceUs number
atUs? number

boolean


timestampUs(sourceUs): number;

Defined in: clock.ts:92

The broadcast time of this source timestamp: the anchor’s broadcast time plus the source’s own elapsed time, rounded to whole microseconds, less the capture latency. Without an anchor, the first call anchors this timestamp at the clock’s now().

Parameter Type
sourceUs number

number