Skip to main content

Module scale

Module scale 

Source
Expand description

Scale lookup and the snap rule.

A note is in a scale when its offset above the root, modulo 12, is one of the scale’s offsets. The snap rule keeps a note in the scale and moves any other to the nearest scale pitch, a tie going to the lower.

use sound_to_patch::music::scale::{offsets, snap};

let major = offsets("scale.major")?;
assert_eq!(snap(60, 4, major), 59);
assert_eq!(snap(61, 4, major), 61);

Functions§

contains
Whether a pitch lies in the scale of offsets on root.
offsets
The offsets of a scale entry.
snap
The pitch moved into the scale: kept when it is in, else the nearest scale pitch below or above, a tie going to the lower. A scale with no offsets keeps every pitch.