Skip to main content

Crate sim_lib_pitch_core

Crate sim_lib_pitch_core 

Source
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.
OctaveSpace
A positive modular division count for octave-like pitch spaces.
Pitch
An octave-aware pitch: a PitchClass together with an octave number.
PitchClass
A mod-12 pitch class, where C = 0 and values increase by semitone to B = 11.
SpelledPitch
A spelled pitch: a diatonic Letter, a chromatic accidental, and an octave.

Enums§

Letter
A diatonic letter name, independent of accidental.
PitchError
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 a to b in space.
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 an Interval.
parse_pitch
Parses a pitch spelling such as "C4", "Eb5", or "Cs4" into a Pitch.
split_floor
Splits an integer value into a floor octave and folded class for space.