Struct Pitch

Source
#[repr(transparent)]
pub struct Pitch(pub PitchTy);
Expand description

A pitch is a discrete tone with an individual frequency that may be classified as a pitch class.

Tuple Fields§

§0: PitchTy

Implementations§

Source§

impl Pitch

Source

pub const MOD: PitchTy = 12i8

Source

pub fn new(pitch: PitchTy) -> Self

Source

pub fn into_inner(self) -> PitchTy

Consumes the object, returning the assigned pitch value.

Source

pub const fn get(&self) -> &PitchTy

A functional accessor for the pitch value.

Source

pub fn get_mut(&mut self) -> &mut PitchTy

returns a mutable reference to the inner value of the pitch;

Source

pub fn set(&mut self, val: PitchTy)

A functional mutator for the pitch value.

Source§

impl Pitch

Source

pub fn class(&self) -> Pitches

Returns a new instance of the class representing the given pitch.

Source

pub fn into_class(self) -> Pitches

Consumes the pitch; returns a new instance of the class representing the given pitch.

Source

pub fn map<F>(self, f: F) -> Self
where F: Fn(PitchTy) -> PitchTy,

Source

pub fn map_mut<F>(&mut self, f: F)
where F: FnMut(&mut PitchTy),

Source

pub fn map_once<F>(self, f: F) -> Self
where F: FnOnce(PitchTy) -> PitchTy,

Consumes the current instance and applies the given function to the pitch value, returning a new instance of Pitch.

Source

pub fn abs(self) -> Self

Consumes the current instance and computes the absolute value of the pitch, returning a new instance of Pitch.

Source

pub fn absmod(self) -> Self

Returns the absolute value of the remainder of the pitch divided by the modulus.

Source

pub fn pymod(self) -> Self

The octmod method computes the modulus of the current pitch using Python’s modulo operator, %. This method is useful for pitch arithmetic due to its unique sign-handling behavior.

Source§

impl Pitch

Source

pub fn add_interval<T>(&self, rhs: T) -> Self
where i8: Add<T, Output = PitchTy>,

Source

pub fn div_interval<T>(&self, rhs: T) -> Self
where i8: Div<T, Output = PitchTy>,

Source

pub fn mul_interval<T>(&self, rhs: T) -> Self
where i8: Mul<T, Output = PitchTy>,

Source

pub fn rem_interval<T>(&self, rhs: T) -> Self
where i8: Rem<T, Output = PitchTy>,

Source

pub fn sub_interval<T>(&self, rhs: T) -> Self
where i8: Sub<T, Output = PitchTy>,

Methods from Deref<Target = PitchTy>§

1.43.0 · Source

pub const MIN: i8 = -128i8

1.43.0 · Source

pub const MAX: i8 = 127i8

1.53.0 · Source

pub const BITS: u32 = 8u32

Trait Implementations§

Source§

impl<'a> Add<&'a Pitch> for Pitch

Source§

type Output = Pitch

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'a Pitch) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a> Add<Pitch> for &'a Pitch

Source§

type Output = Pitch

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Pitch) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, T> Add<T> for &'a Pitch
where PitchTy: Add<T, Output = PitchTy>,

Source§

type Output = Pitch

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add<T> for Pitch
where PitchTy: Add<T, Output = PitchTy>,

Source§

type Output = Pitch

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a> Add for &'a Pitch

Source§

type Output = Pitch

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'a Pitch) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for Pitch

Source§

type Output = Pitch

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Pitch) -> Self::Output

Performs the + operation. Read more
Source§

impl AsMut<i8> for Pitch

Source§

fn as_mut(&mut self) -> &mut PitchTy

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<i8> for Pitch

Source§

fn as_ref(&self) -> &PitchTy

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Binary for Pitch

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Borrow<i8> for Pitch

Source§

fn borrow(&self) -> &PitchTy

Immutably borrows from an owned value. Read more
Source§

impl BorrowMut<i8> for Pitch

Source§

fn borrow_mut(&mut self) -> &mut PitchTy

Mutably borrows from an owned value. Read more
Source§

impl Clone for Pitch

Source§

fn clone(&self) -> Pitch

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Pitch

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Pitch

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl DerefMut for Pitch

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'de> Deserialize<'de> for Pitch

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Pitch

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Div<&'a Pitch> for Pitch

Source§

type Output = Pitch

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &'a Pitch) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<Pitch> for &'a Pitch

Source§

type Output = Pitch

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Pitch) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a, T> Div<T> for &'a Pitch
where PitchTy: Div<T, Output = PitchTy>,

Source§

type Output = Pitch

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
Source§

impl<T> Div<T> for Pitch
where PitchTy: Div<T, Output = PitchTy>,

Source§

type Output = Pitch

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div for &'a Pitch

Source§

type Output = Pitch

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &'a Pitch) -> Self::Output

Performs the / operation. Read more
Source§

impl Div for Pitch

Source§

type Output = Pitch

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Pitch) -> Self::Output

Performs the / operation. Read more
Source§

impl From<Flat> for Pitch

Source§

fn from(pitch: Flat) -> Pitch

Converts to this type from the input type.
Source§

impl From<Natural> for Pitch

Source§

fn from(pitch: Natural) -> Pitch

Converts to this type from the input type.
Source§

impl From<Note> for Pitch

Source§

fn from(note: Note) -> Self

Converts to this type from the input type.
Source§

impl From<Pitch> for Note

Source§

fn from(pitch: Pitch) -> Self

Converts to this type from the input type.
Source§

impl From<Pitch> for Pitches

Source§

fn from(pitch: Pitch) -> Self

Converts to this type from the input type.
Source§

impl From<Pitch> for PitchTy

Source§

fn from(pitch: Pitch) -> Self

Converts to this type from the input type.
Source§

impl From<Pitches> for Pitch

Source§

fn from(pitch: Pitches) -> Self

Converts to this type from the input type.
Source§

impl From<Sharp> for Pitch

Source§

fn from(pitch: Sharp) -> Pitch

Converts to this type from the input type.
Source§

impl From<i8> for Pitch

Source§

fn from(pitch: PitchTy) -> Self

Converts to this type from the input type.
Source§

impl Hash for Pitch

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl LowerHex for Pitch

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Mul<&'a Pitch> for Pitch

Source§

type Output = Pitch

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'a Pitch) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<Pitch> for &'a Pitch

Source§

type Output = Pitch

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Pitch) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, T> Mul<T> for &'a Pitch
where PitchTy: Mul<T, Output = PitchTy>,

Source§

type Output = Pitch

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Self::Output

Performs the * operation. Read more
Source§

impl<T> Mul<T> for Pitch
where PitchTy: Mul<T, Output = PitchTy>,

Source§

type Output = Pitch

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> Mul for &'a Pitch

Source§

type Output = Pitch

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'a Pitch) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul for Pitch

Source§

type Output = Pitch

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Pitch) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> Neg for &'a Pitch

Source§

type Output = Pitch

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Neg for Pitch

Source§

type Output = Pitch

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<'a> Not for &'a Pitch

Source§

type Output = Pitch

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl Not for Pitch

Source§

type Output = Pitch

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl Notable for Pitch

Source§

fn pitch_class(&self) -> Pitches

Classify the pitch into a pitch class
Source§

fn pitch(&self) -> Pitch

Find the modular index of the given pitch
Source§

impl Num for Pitch

Source§

type FromStrRadixErr = <i8 as Num>::FromStrRadixErr

Source§

fn from_str_radix(s: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>

Convert from a string and radix (typically 2..=36). Read more
Source§

impl Octal for Pitch

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl One for Pitch

Source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
Source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Source§

fn is_one(&self) -> bool
where Self: PartialEq,

Returns true if self is equal to the multiplicative identity. Read more
Source§

impl Ord for Pitch

Source§

fn cmp(&self, other: &Pitch) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Pitch

Source§

fn eq(&self, other: &Pitch) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Pitch

Source§

fn partial_cmp(&self, other: &Pitch) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PitchMod for Pitch

Source§

type Output = Pitch

Source§

fn pitchmod(&self) -> Self::Output

Source§

const MOD: PitchTy = 12i8

Source§

impl<'a> Rem<&'a Pitch> for Pitch

Source§

type Output = Pitch

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &'a Pitch) -> Self::Output

Performs the % operation. Read more
Source§

impl<'a> Rem<Pitch> for &'a Pitch

Source§

type Output = Pitch

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Pitch) -> Self::Output

Performs the % operation. Read more
Source§

impl<'a, T> Rem<T> for &'a Pitch
where PitchTy: Rem<T, Output = PitchTy>,

Source§

type Output = Pitch

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: T) -> Self::Output

Performs the % operation. Read more
Source§

impl<T> Rem<T> for Pitch
where PitchTy: Rem<T, Output = PitchTy>,

Source§

type Output = Pitch

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: T) -> Self::Output

Performs the % operation. Read more
Source§

impl<'a> Rem for &'a Pitch

Source§

type Output = Pitch

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &'a Pitch) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem for Pitch

Source§

type Output = Pitch

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Pitch) -> Self::Output

Performs the % operation. Read more
Source§

impl Serialize for Pitch

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a> Sub<&'a Pitch> for Pitch

Source§

type Output = Pitch

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'a Pitch) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a> Sub<Pitch> for &'a Pitch

Source§

type Output = Pitch

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Pitch) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a, T> Sub<T> for &'a Pitch
where PitchTy: Sub<T, Output = PitchTy>,

Source§

type Output = Pitch

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> Sub<T> for Pitch
where PitchTy: Sub<T, Output = PitchTy>,

Source§

type Output = Pitch

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a> Sub for &'a Pitch

Source§

type Output = Pitch

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'a Pitch) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for Pitch

Source§

type Output = Pitch

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Pitch) -> Self::Output

Performs the - operation. Read more
Source§

impl TryFrom<Pitch> for Fifth

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(interval: Pitch) -> Result<Fifth, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Pitch> for Flat

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(p: Pitch) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Pitch> for Fourth

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(interval: Pitch) -> Result<Fourth, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Pitch> for Natural

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(p: Pitch) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Pitch> for Seventh

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(interval: Pitch) -> Result<Seventh, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Pitch> for Sharp

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(p: Pitch) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Pitch> for Third

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(interval: Pitch) -> Result<Third, Self::Error>

Performs the conversion.
Source§

impl UpperHex for Pitch

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Zero for Pitch

Source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
Source§

impl Deref for Pitch

Source§

type Target = i8

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Copy for Pitch

Source§

impl Eq for Pitch

Source§

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 UnwindSafe for Pitch

Blanket Implementations§

Source§

impl<A, B, C> AbsMod<B> for A
where A: Add<C, Output = C> + Copy + Rem<B, Output = C>, B: Copy, C: Add<B, Output = C> + Rem<B, Output = C> + Signed,

Source§

type Output = C

Source§

fn absmod(&self, rhs: B) -> <A as AbsMod<B>>::Output

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<I> IntoInterval for I
where I: Into<Intervals>,

Source§

impl<S> IntoPitch for S
where S: Into<Pitch>,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,

Source§

impl<T> NumRef for T
where T: Num + for<'r> NumOps<&'r T>,

Source§

impl<T, Base> RefNum<Base> for T
where T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>,