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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Pitch
impl<'de> Deserialize<'de> for Pitch
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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