Function tickModulator

Creates an modulator based on ticks.

tickModulator allows you to reset and check for completion. Alternatively, use ticks which is a simple function that just returns a value.

import { tickModulator } from "https://unpkg.com/ixfx/dist/modulation.js";
const fn = (t) => {
// 't' will be values 0..1 based on completion
return Math.random() * t;
}
const t = tickModulator(fn, 1000); // Will take 1000 ticks to complete
t.compute(); // Each call to `compute` progresses the tick count
t.reset(); // Reset to 0
t.isDone; // _True_ if finished
  • Parameters

    • fn: Modulate

      Modulate function that returns 0..1

    • durationTicks: number

      Duration in ticks

    Returns ModulatorTimed

    ModulatorTimed