Zongzi.Score.Grid (zongzi v0.3.0)

Copy Markdown

Timeline grid and quantization utilities. Snaps a free tick to the nearest grid line.

This module is illustrative — grid logic typically belongs to the editor / UI layer.

Summary

Functions

Snaps raw_tick to the nearest position on the given grid_type.

Snaps a tick relative to an original position, preserving the note's snapped absolute length.

Returns the number of ticks spanned by a single grid step.

Types

grid_strategy()

@type grid_strategy() :: :nearest | :floor | :ceil

grid_type()

@type grid_type() ::
  :quarter | :eighth | :sixteenth | {:triplet, 4} | {:triplet, 8} | :none

Functions

snap_tick(raw_tick, grid_type, strategy \\ :nearest, tpqn \\ 480)

Snaps raw_tick to the nearest position on the given grid_type.

snap_tick_relative(raw_tick, original_tick, grid_type, tpqn \\ 480)

Snaps a tick relative to an original position, preserving the note's snapped absolute length.

ticks_per_step(arg1, tpqn)

@spec ticks_per_step(grid_type(), pos_integer()) :: pos_integer()

Returns the number of ticks spanned by a single grid step.