pub struct PitchClass<P = CNote, K = <P as RawPitchClass>::Tag>where
P: RawPitchClass<Tag = K>,
K: Accidental,{ /* private fields */ }Expand description
The PitchClass implementations works to generically define the structure for a pitch
class. This is accomplished through the use of two type parameters: N, which defines the
note (e.g., C, D, E, etc.), and K, which defines the kind of pitch (e.g., sharp, flat,
natural, etc.).
Note: This struct isn’t designed to be used directly, rather through type aliases such
as C, DSharp, EFlat, etc.
Implementations§
Source§impl<P, K> PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: Accidental,
impl<P, K> PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: Accidental,
pub fn new() -> PitchClass<P, K>
pub fn from_class(class: P) -> PitchClass<P, K>
pub fn from_kind(kind: K) -> PitchClass<P, K>
Sourcepub const fn as_mut_ptr(&mut self) -> *mut P
pub const fn as_mut_ptr(&mut self) -> *mut P
returns a mutable pointer to the class
Sourcepub fn as_frequency<T>(&self) -> Frequency<T>
pub fn as_frequency<T>(&self) -> Frequency<T>
convert the pitch class into a Frequency based on the standard A4 tuning
Sourcepub fn is_natural(&self) -> boolwhere
K: 'static,
pub fn is_natural(&self) -> boolwhere
K: 'static,
returns true if the class is considered natural
Source§impl<N> PitchClass<N>where
N: RawPitchClass,
impl<N> PitchClass<N>where
N: RawPitchClass,
Sourcepub const fn natural(class: N) -> PitchClass<N, Natural>where
N: RawPitchClass<Tag = Natural>,
pub const fn natural(class: N) -> PitchClass<N, Natural>where
N: RawPitchClass<Tag = Natural>,
initialize a new, natural pitch class
Sourcepub const fn sharp(class: N) -> PitchClass<N, Sharp>where
N: RawPitchClass<Tag = Sharp>,
pub const fn sharp(class: N) -> PitchClass<N, Sharp>where
N: RawPitchClass<Tag = Sharp>,
initialize a sharp instance of the given class
Sourcepub const fn flat(class: N) -> PitchClass<N, Flat>where
N: RawPitchClass<Tag = Flat>,
pub const fn flat(class: N) -> PitchClass<N, Flat>where
N: RawPitchClass<Tag = Flat>,
initialize a flat instance of the given class
Trait Implementations§
Source§impl<T1, A1, T2, A2> Add<PitchClass<T2, A2>> for PitchClass<T1, A1>
Add two pitch-classes producing a wrapped semitone count in the tonal space.
impl<T1, A1, T2, A2> Add<PitchClass<T2, A2>> for PitchClass<T1, A1>
Add two pitch-classes producing a wrapped semitone count in the tonal space.
Note: returning a compile-time PitchClass subtype from an operator requires a
type-level index; that’s not possible for arbitrary runtime sums. We therefore
return an i32 semitone value (0..11) using PitchMod::pmod. Callers can
convert that numeric result into any runtime/compile-time representation they
prefer.
Source§fn add(
self,
rhs: PitchClass<T2, A2>,
) -> <PitchClass<T1, A1> as Add<PitchClass<T2, A2>>>::Output
fn add( self, rhs: PitchClass<T2, A2>, ) -> <PitchClass<T1, A1> as Add<PitchClass<T2, A2>>>::Output
+ operation. Read moreSource§impl<P, K> AsRef<isize> for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: Accidental,
impl<P, K> AsRef<isize> for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: Accidental,
Source§impl<P, K> AsRef<str> for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: Accidental,
impl<P, K> AsRef<str> for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: Accidental,
Source§impl<P, K> Borrow<isize> for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: Accidental,
impl<P, K> Borrow<isize> for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: Accidental,
Source§impl<P, K> Clone for PitchClass<P, K>
impl<P, K> Clone for PitchClass<P, K>
Source§fn clone(&self) -> PitchClass<P, K>
fn clone(&self) -> PitchClass<P, K>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<P, K> Debug for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: Accidental,
impl<P, K> Debug for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: Accidental,
Source§impl<P, K> Default for PitchClass<P, K>
impl<P, K> Default for PitchClass<P, K>
Source§fn default() -> PitchClass<P, K>
fn default() -> PitchClass<P, K>
Source§impl<P, K> Deref for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: Accidental,
impl<P, K> Deref for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: Accidental,
Source§impl<P, K> Display for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: Accidental,
impl<P, K> Display for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: Accidental,
Source§impl<P, K> FromStr for PitchClass<P, K>
impl<P, K> FromStr for PitchClass<P, K>
Source§impl<P, K> Hash for PitchClass<P, K>
impl<P, K> Hash for PitchClass<P, K>
Source§impl<P, K> Ord for PitchClass<P, K>
impl<P, K> Ord for PitchClass<P, K>
Source§fn cmp(&self, other: &PitchClass<P, K>) -> Ordering
fn cmp(&self, other: &PitchClass<P, K>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<P, K> PartialEq<PitchClass<P, K>> for isizewhere
P: RawPitchClass<Tag = K>,
K: Accidental,
impl<P, K> PartialEq<PitchClass<P, K>> for isizewhere
P: RawPitchClass<Tag = K>,
K: Accidental,
Source§impl<P, K> PartialEq<isize> for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: Accidental,
impl<P, K> PartialEq<isize> for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: Accidental,
Source§impl<P, K> PartialEq for PitchClass<P, K>
impl<P, K> PartialEq for PitchClass<P, K>
Source§impl<P, K> PartialOrd for PitchClass<P, K>
impl<P, K> PartialOrd for PitchClass<P, K>
Source§impl<T1, A1, T2, A2> Sub<PitchClass<T2, A2>> for PitchClass<T1, A1>
impl<T1, A1, T2, A2> Sub<PitchClass<T2, A2>> for PitchClass<T1, A1>
Source§fn sub(
self,
rhs: PitchClass<T2, A2>,
) -> <PitchClass<T1, A1> as Sub<PitchClass<T2, A2>>>::Output
fn sub( self, rhs: PitchClass<T2, A2>, ) -> <PitchClass<T1, A1> as Sub<PitchClass<T2, A2>>>::Output
- operation. Read moreSource§impl<P, K> TryFrom<isize> for PitchClass<P, K>where
P: PitchClassRepr<Tag = K>,
K: Accidental,
impl<P, K> TryFrom<isize> for PitchClass<P, K>where
P: PitchClassRepr<Tag = K>,
K: Accidental,
impl<P, K> Copy for PitchClass<P, K>
impl<P, K> Eq for PitchClass<P, K>
impl<P, K> Send for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: Accidental,
impl<P, K> StructuralPartialEq for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: Accidental,
impl<P, K> Sync for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: Accidental,
Auto Trait Implementations§
impl<P, K> Freeze for PitchClass<P, K>
impl<P, K> RefUnwindSafe for PitchClass<P, K>where
P: RefUnwindSafe,
K: RefUnwindSafe,
impl<P, K> Unpin for PitchClass<P, K>
impl<P, K> UnwindSafe for PitchClass<P, K>where
P: UnwindSafe,
K: UnwindSafe,
Blanket Implementations§
Source§impl<T> AsWeight<T> for Twhere
T: Clone + IntoWeight<T>,
impl<T> AsWeight<T> for Twhere
T: Clone + IntoWeight<T>,
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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