@maruaudio/dsp/processors/division-clock is a port of the CHOMPI TEMPO firmware's clock manager. It drives two division lanes and a fixed eighth-note lane, either from a free-running 24 ppqn hardware timer (FREE) or from counted external MIDI clock bytes (SYNC), and estimates the sync tempo with an f32 moving average. The timer is integrated in whole microseconds, and edges are observed once per 48-frame block (1000 µs at 48 kHz), so step edges match the device whatever the host block size.
Parameters
| Setter | Range as coded | Default |
|---|---|---|
changeDivisionClockTempo(turns) | Relative, clamped 160 to 480 (tempo is 2 × BPM) | 320 |
setDivisionClockTempo(tempo) | Truncated, unclamped; the CC path sends 160 to 480 | 320 |
changeDivisionClockDiv(turns, lane) | Encoder count 0 to 60 over five 12-detent rows; FREE {24, 18, 12, 8, 6} ticks, SYNC {48, 24, 12, 6, 3} clocks | position 2, an eighth |
setDivisionClockDiv(lane, div) | Scene recall: FREE defers a position; SYNC writes the raw value as the clock count | none |
toggleDivisionClockMode | FREE ↔ SYNC | FREE |
divisionClockTap(nowMs, encoder) | Taps within 750 ms set tempo 120000 / interval, at most 480 | none |
Lifecycle
createDivisionClock allocates fixed typed arrays → per block divisionClockAdvance(1000), UI setters, divisionClockRealtime(status, transportIn) per MIDI realtime byte, divisionClockHead → read edges → resetDivisionClock (power-on state). Realtime bytes return START or STOP.
When to use it
Clocking @maru/processors-pattern-arpeggiator or another CHOMPI TEMPO port whose step timing must match the hardware, quirks included. Beat-based timing at any rate belongs to @maru/control-musical-clock.
Limits
- Fixed 1000 µs blocks, an emulated-timer exception to rate independence.
- Kept firmware behaviour: a period lowered below the running counter runs to 0xFFFF first; SYNC
setDivwrites a position as a clock count; the sync delay boost uses the overflowed 32-bit square; division by zero yields 0. Out-of-range positions read the last table row.