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);