import { DeadOnClock } from './deadon'; /** * Unified note payload for Web Audio, Web MIDI, or UI callbacks. * - freq?: frequency in Hz (Web Audio) * - midiNote?: MIDI note number (Web MIDI) * - velocity?: MIDI velocity (0-127) * - durationMs?: how long the note lasts (default 100ms) * - uiCallback?: optional function to invoke for UI updates */ export interface NotePayload { freq?: number; midiNote?: number; velocity?: number; durationMs?: number; uiCallback?: () => void; } /** * A step action: any array of payloads scheduled across the zone from this step * to the next non-null step, subdivided into hits per step. */ export interface StepAction
{ payload: P[]; subdivs?: number; offsetTick?: number | null; offsetMs?: number | null; } /** * DeadOnSequencer * * Drives a fixed-length cycle (default 16 steps in 4/4) on top of DeadOnClock. * Each step may hold exactly one StepAction, and the entire schedule is * pre-calculated into a tick→payload map for O(1) lookups at runtime. */ export declare class DeadOnSequencer
{
private clock;
steps: number;
private sequence;
private schedule;
private effectiveBarTicks;
private ticksPerStep;
private secPerTick;
bpm: number;
ppqn: number;
speedFactor: number;
/** (deprecated) integer division factor; use speedFactor */
division: number;
/**
* @param clock DeadOnClock instance
* @param steps number of steps per bar (default: 16)
* @param ppqn pulses per quarter note (must match clock.ppqn)
* @param bpm tempo in BPM (must match clock.bpm)
*/
constructor(clock: DeadOnClock, steps?: number, ppqn?: number, bpm?: number);
/**
* Replace the entire step sequence at once.
* @param seq array of length `steps`, each entry a StepAction or null
*/
setSequence(seq: Array | null): void;
/** Clear all steps. */
clearSequence(): void;
/**
* Update PPQN in real time; rebuilds schedule.
*/
setPpqn(ppqn: number): void;
/**
* Update BPM in real time; rebuilds schedule.
*/
setBpm(bpm: number): void;
/**
* Change playback speed. Accepts any positive number:
* 1 = normal
* <1 = slower (e.g. 0.5 = half-speed)
* >1 = faster (e.g. 2 = double-speed)
*/
setSpeedFactor(factor: number): void;
/**
* Clear the action at a single step.
* @param step step index [0..steps-1]
*/
clearStep(step: number): void;
/**
* Get all payloads scheduled at a given global tick.
* @param tick DeadOn clock tick
*/
getPayloadsForTick(tick: number): P[];
/** Internal: rebuild the tick→payload map from `sequence`. */
private rebuildSchedule;
/** Internal helper to record a payload at a given tick index. */
private pushPayloadAt;
/**
* Schedule start/stop for a Web Audio oscillator.
* @param osc the OscillatorNode to schedule
* @param startTimeSec AudioContext time in seconds to start
* @param durationMs duration in milliseconds (default 100ms)
*/
static triggerAudio(osc: OscillatorNode | AudioBufferSourceNode, startTimeSec: number, durationMs?: number): void;
/**
* Schedule a Web MIDI note-on and note-off.
* @param midiOut MIDIOutput to send messages on
* @param note MIDI note number
* @param velocity MIDI velocity (0–127)
* @param startTimeMs DOMHighResTimeStamp timestamp to send note-on
* @param durationMs milliseconds until note-off (default 100ms)
*/
static triggerMidi(midiOut: MIDIOutput, note: number, velocity: number, startTimeMs: number, offTimestampMs?: number): void;
}