Struct MidiPitch
pub struct MidiPitch(/* private fields */);Expand description
A MIDI note number from 0.0 to 127.0 inclusive. Fractional values carry a pitch between notes, such as a pitch track gives.
use sound_to_patch::units::MidiPitch;
let a4 = MidiPitch::new(69.0)?;
let bent = MidiPitch::new(69.25)?;
assert!(MidiPitch::new(127.5).is_err());Implementations§
Trait Implementations§
impl Copy for MidiPitch
§impl<'de> Deserialize<'de> for MidiPitch
impl<'de> Deserialize<'de> for MidiPitch
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<MidiPitch, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<MidiPitch, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl FromStr for MidiPitch
impl FromStr for MidiPitch
§type Err = ParseUnitError
type Err = ParseUnitError
The associated error which can be returned from parsing.
§impl PartialOrd for MidiPitch
impl PartialOrd for MidiPitch
§impl Serialize for MidiPitch
impl Serialize for MidiPitch
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Spread for MidiPitch
impl StructuralPartialEq for MidiPitch
§impl TryFrom<Hz> for MidiPitch
impl TryFrom<Hz> for MidiPitch
§fn try_from(frequency: Hz) -> Result<MidiPitch, RangeError>
fn try_from(frequency: Hz) -> Result<MidiPitch, RangeError>
Converts with equal temperament, A4 = 440 Hz:
m = 69 + 12 * log2(f / 440).
§Errors
Returns a RangeError for 0 Hz, which has no pitch, and for a
frequency outside MIDI notes 0 to 127.
§type Error = RangeError
type Error = RangeError
The type returned in the event of a conversion error.
§impl TryFrom<f64> for MidiPitch
impl TryFrom<f64> for MidiPitch
§type Error = RangeError
type Error = RangeError
The type returned in the event of a conversion error.
Auto Trait Implementations§
impl Freeze for MidiPitch
impl RefUnwindSafe for MidiPitch
impl Send for MidiPitch
impl Sync for MidiPitch
impl Unpin for MidiPitch
impl UnsafeUnpin for MidiPitch
impl UnwindSafe for MidiPitch
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> ClampCast for Twhere
T: PartialOrd + Copy + 'static,
impl<T> ClampCast for Twhere
T: PartialOrd + Copy + 'static,
fn clamp_cast<O>(self) -> O
impl<T> CloneAny for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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> ⓘ
Converts
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> ⓘ
Converts
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