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.
Symbol | Meaning | Example |
---|---|---|
A-G | Note Name | "a", "C", "f" |
nat | Natural | "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
Interval
s 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.
Symbol | Meaning | Example |
---|---|---|
1-7 | Unison through Seventh | "m6", "A4" |
0 | Unison. Both 0 and 1 represent Unisons | "p0" |
U | Unison | "au", "pU" |
P | Perfect | "p4", "P5" |
A... | Augmented by one or more degrees | "A4", "aa6" |
D... | Diminished by one or more degrees | "D3", "dd2" |
M | Major | "M3", "M7" |
m | Minor | "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 | An Interval is a combination of an |
Note | A note is represented as a pairing of a |
PitchedNote | A pitched note represents a |
Enums
Accidental | An accidental represents the degree of chromatic alteration applied to a |
Error | General top-level error type for the module. |
IntervalError | Indicates that an |
IntervalQuality | Represents a chromatic alteration up or down that is applied to a pure |
IntervalSize | Represents the pure diatonic intervals with no chromatic alterations. |
NoteError | Indicates that a |
NoteName | The “white keys” of the piano; the seven note names used in western harmony. |