Skip to main content

Module rhythm

Module rhythm 

Source
Expand description

Euclidean rhythm generator (Bjorklund-style) + step-grid helpers.

Distributes hits events as evenly as possible across steps and rotates by rotation. Encodes the result as a u32 bitmask where bit i is 1 if step i is an active hit. 16-step resolution (4 per beat, 4 beats per bar) is plenty for drum machines.

Constants§

STEPS

Functions§

euclidean_bits
Packed 16-step pattern as a u32 bitmask. Bit 0 = step 0.
step_is_active
Check if the pattern has a hit at (t * bpm / 60 * 4) mod 16.
step_position
Returns (global_step_index, phase_within_step) given time in seconds.