Skip to main content

Module rhythm

Module rhythm 

Source
Expand description

Rhythm arithmetic: Euclidean patterns, swing and ticks.

A bar has 16 sixteenth slots, numbered 0 to 15. Ticks count 480 per quarter note, as in the MIDI files the tool writes.

use sound_to_patch::music::rhythm::{euclid, onsets, ticks_for_ms};

assert_eq!(onsets(&euclid(3, 8)), [0, 3, 6]);
assert_eq!(ticks_for_ms(5.0, 120.0), Some(5));

Enums§

Division
A note division and its length in ticks.
Pair
The two notes of a swung pair.

Functions§

euclid
The Euclidean pattern of k onsets over n steps.
onsets
The steps that hold an onset.
rotate
The pattern with every onset moved rotation steps later, wrapping around.
sixteenth_ms
The length of a sixteenth in ms: a quarter of the beat period of the stem’s beat grid.
slot_ticks
The ticks of one slot of a bar of grid slots: 12, 16 or 24 slots give 160, 120 or 80 ticks.
swing_delay
The delay of the second note of a swung pair, in sixteenths, for a pair percent pct (50 is straight) and a pair of sixteenths.
swing_pct
The pair percent of a long-to-short ratio.
swing_ratio
The long-to-short ratio of a pair percent.
swing_ticks
The delay of the second note of a swung pair in ticks.
tick_ms
The length of one tick in ms, 1000 / ticks per second, the tick the MIDI writer uses.
ticks_for_ms
The whole ticks that cover ms at a tempo, rounded up, so an overlap is never shorter than asked.