pub enum PitchClass {
C,
CSharp,
D,
DSharp,
E,
F,
FSharp,
G,
GSharp,
A,
ASharp,
B,
}Expand description
A pitch class is “a set of all pitches that are a whole number of octaves apart, e.g., the pitch class C consists of the Cs in all octaves.” https://en.wikipedia.org/wiki/Pitch_class
Our 12 pitch classes are represented with integers from 0 to 11. Values > 11 will be used to model retrieval of the same pitch class in a higher octave. For example, pitch class 12 is the same as pitch class 0 and corresponds to the pitch class of C.
Variants§
Trait Implementations§
Source§impl Add<u8> for PitchClass
impl Add<u8> for PitchClass
Source§impl Clone for PitchClass
impl Clone for PitchClass
Source§fn clone(&self) -> PitchClass
fn clone(&self) -> PitchClass
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PitchClass
impl Debug for PitchClass
Source§impl From<PitchClass> for Note
impl From<PitchClass> for Note
Source§fn from(pitch_class: PitchClass) -> Self
fn from(pitch_class: PitchClass) -> Self
Convert a pitch class into a note. For notes that can be sharp or flat use the sharp version.
Source§impl From<u8> for PitchClass
impl From<u8> for PitchClass
Source§fn from(n: Semitones) -> Self
fn from(n: Semitones) -> Self
Convert an integer into a pitch class.
To model the fact that e.g. all instances of the note C in different
octaves belong to the same pitch class, each integer is placed in the
range of potential pitch classes (between 0 and 11).
For example, 12, 24, 36, etc. all correspond to pitch class 0.
Source§impl Ord for PitchClass
impl Ord for PitchClass
Source§fn cmp(&self, other: &PitchClass) -> Ordering
fn cmp(&self, other: &PitchClass) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for PitchClass
impl PartialEq for PitchClass
Source§impl PartialOrd for PitchClass
impl PartialOrd for PitchClass
Source§impl Sub<u8> for PitchClass
impl Sub<u8> for PitchClass
Source§impl Sub for PitchClass
impl Sub for PitchClass
Source§fn sub(self, other: Self) -> Semitones
fn sub(self, other: Self) -> Semitones
Get the difference between two pitch classes in number of frets or semitones.
self is assumed to always be higher as other with a difference
of at most one octave.
Examples:
- D - C: both pitch classes are assumed to be in the same octave, D being higher than C. The difference is 2.
- D - A: D is higher than A, the difference is 5.
impl Copy for PitchClass
impl Eq for PitchClass
impl StructuralPartialEq for PitchClass
Auto Trait Implementations§
impl Freeze for PitchClass
impl RefUnwindSafe for PitchClass
impl Send for PitchClass
impl Sync for PitchClass
impl Unpin for PitchClass
impl UnwindSafe for PitchClass
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more