API reference
Every public class, method, and event in @codexo/exojs. Generated from source.
classAudioOutputClock
Converts between audio-context time and the `performance.now()` timeline, so that audio scheduled in one can be lined up with rendering, input or animation measured in the other. ```ts const clock = new AudioOutputClock(); const beatAt = clock.contextToPerformanceTime(nextBeatContextTime); ``` Where the environment offers `AudioContext.getOutputTimestamp()`, the correlation names the sample the output device is playing right now, so a context time converted through this class already accounts for the output path: a beat scheduled for `contextTime` maps to the `performance.now()` instant a listener hears it, with no latency arithmetic of your own. AudioOutputClockSnapshot.baseLatency and `outputLatency` are telemetry, not a correction to apply on top. Nothing here knows about display latency. Aligning a beat with the frame that shows it is the caller's decision, because only the caller knows how far ahead of the photons its render loop runs. Every reading is taken fresh, so long-lived instances track drift between the two clocks rather than accumulating it. Two conversions therefore need not use the identical correlation; where exactness matters more than currency, take one snapshot and do the arithmetic against it. The wall clock is never consulted - a user changing the system time cannot move an ExoJS audio correlation.
import { AudioOutputClock } from '@codexo/exojs'Converts between audio-context time and the `performance.now()` timeline, so that audio scheduled in one can be lined up with rendering, input or animation measured in the other.
```ts const clock = new AudioOutputClock(); const beatAt = clock.contextToPerformanceTime(nextBeatContextTime); ```
Where the environment offers `AudioContext.getOutputTimestamp()`, the correlation names the sample the output device is playing right now, so a context time converted through this class already accounts for the output path: a beat scheduled for `contextTime` maps to the `performance.now()` instant a listener hears it, with no latency arithmetic of your own. AudioOutputClockSnapshot.baseLatency and `outputLatency` are telemetry, not a correction to apply on top.
Nothing here knows about display latency. Aligning a beat with the frame that shows it is the caller's decision, because only the caller knows how far ahead of the photons its render loop runs.
Every reading is taken fresh, so long-lived instances track drift between the two clocks rather than accumulating it. Two conversions therefore need not use the identical correlation; where exactness matters more than currency, take one snapshot and do the arithmetic against it.
The wall clock is never consulted - a user changing the system time cannot move an ExoJS audio correlation.
new(context?: AudioContext): AudioOutputClockcontextToPerformanceTime(contextTime: number): numberperformanceToContextTime(performanceTime: number): numbercontext: AudioContext