Module persichetti::primitives[][src]

This module provides notes and intervals for use in more complex applications, as well as macros for quickly initializing them.

Note Shorthand

Notes can be represented compactly as strings. Note names are not case-sensitive, but flat symbols and double-sharps are.

SymbolMeaningExample
A-GNote Name"a", "C", "f"
natNatural"bnat", "Gnat"
b...One or more flats"Bb", "Abb"
#...One or more sharps"f#", "C##"
x...One or more double-sharps"gx", "Dxx"
#x..A triple+ sharp"C#x", "E#xx"

When initializing a PitchedNote, the octave number can be appended to the end of the note name. Negative numbers are supported

let b_flat_2 = PitchedNote::from_str("Bb2").unwrap();
let g_sharp_negative_one = PitchedNote::from_str("g#-1").unwrap();

Interval Shorthand

Intervals have a string representation as well. Capital and lowercase M’s are case-sensitive, but all other qualities are not. When an interval is doubly augmented or doubly diminished, it can be represented as "aa5" (doubly-augmented fifth) or `“dd3” (doubly-diminished third). This can be extended to an arbitrary number of augmentations or diminutions.

SymbolMeaningExample
1-7Unison through Seventh"m6", "A4"
0Unison. Both 0 and 1 represent Unisons"p0"
UUnison"au", "pU"
PPerfect"p4", "P5"
A...Augmented by one or more degrees"A4", "aa6"
D...Diminished by one or more degrees"D3", "dd2"
MMajor"M3", "M7"
mMinor"m2", "m6

When initializing a CompoundInterval, the octave number can be appended to the end of the interval with a +N for N octaves. Compound octaves must be zero or greater; a negative octave specifier is not allowed.

let perfect_fifth = CompoundInterval::from_str("P5+0").unwrap();
let major_tenth = CompoundInterval::from_str("M3+1").unwrap();

Structs

CompoundInterval

A compound interval represents an Interval that may span more than one octave.

Interval

An Interval is a combination of an IntervalSize and an IntervalQuality. It represents the relationship between two Notes.

Note

A note is represented as a pairing of a NoteName and an Accidental. These notes have no concept of absolute pitch or octave equivalence; if you need a note with octave information, use PitchedNote.

PitchedNote

A pitched note represents a Note in a definite octave. C4 is “middle C” and A0 is the lowest note on a standard piano

Enums

Accidental

An accidental represents the degree of chromatic alteration applied to a NoteName.

Error

General top-level error type for the module.

IntervalError

Indicates that an Interval could not be constructed.

IntervalQuality

Represents a chromatic alteration up or down that is applied to a pure IntervalSize.

IntervalSize

Represents the pure diatonic intervals with no chromatic alterations.

NoteError

Indicates that a Note could not be constructed.

NoteName

The “white keys” of the piano; the seven note names used in western harmony.