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

C

CSharp

D

DSharp

E

F

FSharp

G

GSharp

A

ASharp

B

Trait Implementations

Get the pitch class that is n semitones higher than the current pitch class.

The resulting type after applying the + operator.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Convert a pitch class into a note. For notes that can be sharp or flat use the sharp version.

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.

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

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.

The resulting type after applying the - operator.

Get the pitch class that is n semitones lower than the current pitch class.

The resulting type after applying the - operator.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.