Expand description
Core pitch theory primitives for the SIM music libraries.
This crate defines the foundational pitch types shared across the sim-lib-pitch-*
constellation: the mod-12 PitchClass, the octave-aware Pitch, the
letter-plus-accidental SpelledPitch, and the Interval measured in
semitones. Higher-level crates (sets, scales, chords, namers) build on these
primitives rather than redefining their own pitch representations.
Pitch classes use the twelve-tone equal-tempered convention where C = 0 and
values increase by semitone up to B = 11. Octave-aware pitches use the MIDI
convention in which middle C (C4) is MIDI note 60.
Structs§
- Interval
- A pitch interval measured in semitones.
- Octave
Space - A positive modular division count for octave-like pitch spaces.
- Pitch
- An octave-aware pitch: a
PitchClasstogether with an octave number. - Pitch
Class - A mod-12 pitch class, where
C = 0and values increase by semitone toB = 11. - Spelled
Pitch - A spelled pitch: a diatonic
Letter, a chromatic accidental, and an octave.
Enums§
- Letter
- A diatonic letter name, independent of accidental.
- Pitch
Error - Error returned when a pitch, pitch class, or interval cannot be constructed or parsed.
- TieDirection
- Direction used when a folded distance has two equally short paths.
Statics§
- RECIPES
- Cookbook recipes for this lib, embedded at build time.
Functions§
- fold
- Folds an integer value into
0..space.len()using floor modulus. - folded_
distance - Returns the signed shortest circular distance from
atobinspace. - folded_
unsigned_ distance - Returns the unsigned shortest circular distance between two values in
space. - parse_
interval - Parses one of the recognized interval tokens (
"P5","m3","M7","TT") into anInterval. - parse_
pitch - Parses a pitch spelling such as
"C4","Eb5", or"Cs4"into aPitch. - split_
floor - Splits an integer value into a floor octave and folded class for
space.