Zyklus a small (380 Byte) library to get an accurate Web Audio Clock without hassle.
npm i zyklus --save
import 'zyklus';
const clock = ctx
.createClock((time, duration, tick) => {
console.log(time, duration, tick);
}, 0.2)
.start();
callback((time, duration, tick) => void)
: called for each tick withtime
precise AudioContext time when the tick should happenduration
seconds between each ticktick
count of the current tick
duration
seconds between each tickinterval
(optional) seconds used for the interval. Change this to tune the latencyoverlap
(optional) seconds of overlap between intervals. Change this to tune the latency and resilience
Start the clock.
Stop the clock.
Stop the clock without resetting the tick.