Expand description
Snap an event tick to a musical grid, with optional strength.
quantize_tick(tick, grid_ticks, strength) rounds tick to the nearest
multiple of grid_ticks (the grid), then moves the event only a fraction of
the way there when strength < 1.0:
snapped = round(tick / grid) * grid
result = round(tick + strength * (snapped - tick))strength is clamped to [0, 1]: 1.0 snaps fully to the grid, 0.0
leaves the tick untouched, and intermediate values “humanize” by partially
pulling toward the grid. Pure and allocation-free.
Functions§
- quantize_
tick - Snap
ticktoward the nearest multiple ofgrid_ticksbystrength.