pub struct Pitch { /* private fields */ }Expand description
A musical pitch with spelling, octave, accidental and optional microtone.
Implementations§
Source§impl Pitch
impl Pitch
Sourcepub fn from_options(options: PitchOptions) -> Result<Self>
pub fn from_options(options: PitchOptions) -> Result<Self>
Builds a pitch from PitchOptions.
Sourcepub fn builder() -> PitchOptions
pub fn builder() -> PitchOptions
Creates a PitchOptions builder.
Sourcepub fn from_name(name: impl Into<String>) -> Result<Self>
pub fn from_name(name: impl Into<String>) -> Result<Self>
Builds a pitch from a name such as "C#4" or "E-".
Sourcepub fn from_number(number: FloatType) -> Result<Self>
pub fn from_number(number: FloatType) -> Result<Self>
Builds a pitch from a pitch-space number.
Sourcepub fn from_name_and_octave(
name: impl Into<String>,
octave: IntegerType,
) -> Result<Self>
pub fn from_name_and_octave( name: impl Into<String>, octave: IntegerType, ) -> Result<Self>
Builds a pitch from a pitch name and explicit octave.
Sourcepub fn from_pitch_class(
pitch_class: impl Into<PitchClassSpecifier>,
) -> Result<Self>
pub fn from_pitch_class( pitch_class: impl Into<PitchClassSpecifier>, ) -> Result<Self>
Builds a pitch from a pitch class.
Sourcepub fn from_midi(midi: IntegerType) -> Result<Self>
pub fn from_midi(midi: IntegerType) -> Result<Self>
Builds a pitch from a MIDI note number.
Sourcepub fn from_pitch_space(ps: FloatType) -> Result<Self>
pub fn from_pitch_space(ps: FloatType) -> Result<Self>
Builds a pitch from a pitch-space value.
Sourcepub fn name_with_octave(&self) -> String
pub fn name_with_octave(&self) -> String
Returns the pitch name with the octave suffix when one is set.
Sourcepub fn accidental(&self) -> &Accidental
pub fn accidental(&self) -> &Accidental
Returns this pitch’s accidental object.
Unlike Python music21, this crate stores an explicit natural accidental for natural pitches.
Sourcepub fn microtone(&self) -> Option<&Microtone>
pub fn microtone(&self) -> Option<&Microtone>
Returns this pitch’s microtone adjustment, when present.
Sourcepub fn pitch_class(&self) -> PitchClass
pub fn pitch_class(&self) -> PitchClass
Returns this pitch’s normalized pitch class.
Sourcepub fn pitch_space(&self) -> FloatType
pub fn pitch_space(&self) -> FloatType
Returns the pitch-space value for this pitch.
Sourcepub fn midi(&self) -> IntegerType
pub fn midi(&self) -> IntegerType
Returns the nearest MIDI note number for this pitch.
Sourcepub fn frequency_hz(&self) -> FloatType
pub fn frequency_hz(&self) -> FloatType
Returns this pitch’s twelve-tone equal-temperament frequency in hertz.
Sourcepub fn frequency_hz_in(&self, tuning_system: TuningSystem) -> FloatType
pub fn frequency_hz_in(&self, tuning_system: TuningSystem) -> FloatType
Returns this pitch’s frequency in hertz for a supported tuning system.
The pitch-space value is used as the tuning-system degree index, so this is most musically meaningful for twelve-tone systems.
Sourcepub fn simplify_enharmonic(&self, most_common: bool) -> Result<Pitch>
pub fn simplify_enharmonic(&self, most_common: bool) -> Result<Pitch>
Returns a simpler enharmonic spelling of this pitch.
When most_common is true, common spellings such as E- are preferred
over less common equivalents such as D#, following music21’s
Pitch.simplifyEnharmonic behavior.
Sourcepub fn simplify_enharmonic_in_place(&mut self, most_common: bool) -> Result<()>
pub fn simplify_enharmonic_in_place(&mut self, most_common: bool) -> Result<()>
Simplifies this pitch’s enharmonic spelling in place.
Sourcepub fn get_higher_enharmonic(&self) -> Result<Pitch>
pub fn get_higher_enharmonic(&self) -> Result<Pitch>
Returns the next higher enharmonic spelling.
Sourcepub fn get_higher_enharmonic_in_place(&mut self) -> Result<()>
pub fn get_higher_enharmonic_in_place(&mut self) -> Result<()>
Replaces this pitch with its next higher enharmonic spelling.
Sourcepub fn get_lower_enharmonic(&self) -> Result<Pitch>
pub fn get_lower_enharmonic(&self) -> Result<Pitch>
Returns the next lower enharmonic spelling.
Sourcepub fn get_lower_enharmonic_in_place(&mut self) -> Result<()>
pub fn get_lower_enharmonic_in_place(&mut self) -> Result<()>
Replaces this pitch with its next lower enharmonic spelling.
Trait Implementations§
Source§impl IntoNote for &Pitch
impl IntoNote for &Pitch
Source§fn try_into_note(self) -> Result<Note>
fn try_into_note(self) -> Result<Note>
Source§const FROM_INTEGER_PITCH: bool = false
const FROM_INTEGER_PITCH: bool = false
Source§impl IntoNote for Pitch
impl IntoNote for Pitch
Source§fn try_into_note(self) -> Result<Note>
fn try_into_note(self) -> Result<Note>
Source§const FROM_INTEGER_PITCH: bool = false
const FROM_INTEGER_PITCH: bool = false
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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