A timer based on frequency: cycles per unit of time. These timers return a number from 0..1 indicating position with a cycle.
In practice, timers are used to 'drive' something like an Oscillator.
By default it uses elapsed clock time as a basis for frequency. ie., cycles per second.
It returns a ModulationTimer, which allows for a modulation amount to be continually applied to the calculation of the 'position' within a cycle.
ModulationTimer
import { frequencyTimer } from "https://unpkg.com/ixfx/dist/flow.js"const t = frequencyTimer(0.5);setInterval(() => { console.log(t.elapsed);}, 1000); Copy
import { frequencyTimer } from "https://unpkg.com/ixfx/dist/flow.js"const t = frequencyTimer(0.5);setInterval(() => { console.log(t.elapsed);}, 1000);
Cycles
Options for timer
A timer based on frequency: cycles per unit of time. These timers return a number from 0..1 indicating position with a cycle.
In practice, timers are used to 'drive' something like an Oscillator.
By default it uses elapsed clock time as a basis for frequency. ie., cycles per second.
It returns a
ModulationTimer
, which allows for a modulation amount to be continually applied to the calculation of the 'position' within a cycle.Example: Prints around 0/0.5 each second, as timer is half a cycle per second