pub struct Pitch {
pub class: PitchClass,
pub octave: i16,
}Expand description
An octave-aware pitch: a PitchClass together with an octave number.
The octave follows the MIDI convention in which middle C (C4) is MIDI note
60, so Pitch::semitone returns a continuous semitone index across octaves.
Fields§
§class: PitchClassThe mod-12 pitch class.
octave: i16The octave number, with C4 (MIDI 60) in octave 4.
Implementations§
Source§impl Pitch
impl Pitch
Sourcepub fn semitone(self) -> i32
pub fn semitone(self) -> i32
Returns the absolute semitone index of this pitch, where MIDI 60 (C4) is 60.
Sourcepub fn from_semitone(semitone: i32) -> Pitch
pub fn from_semitone(semitone: i32) -> Pitch
Constructs a pitch from an absolute semitone index, the inverse of
Pitch::semitone.
Sourcepub fn to_midi(self) -> Option<u8>
pub fn to_midi(self) -> Option<u8>
Returns the MIDI note number for this pitch, or None if it falls outside
the playable range 0..=127.
Trait Implementations§
impl Copy for Pitch
impl Eq for Pitch
Source§impl Ord for Pitch
impl Ord for Pitch
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Pitch
impl PartialOrd for Pitch
impl StructuralPartialEq for Pitch
Auto Trait Implementations§
impl Freeze for Pitch
impl RefUnwindSafe for Pitch
impl Send for Pitch
impl Sync for Pitch
impl Unpin for Pitch
impl UnsafeUnpin for Pitch
impl UnwindSafe for Pitch
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
Mutably borrows from an owned value. Read more