pub struct PitchClass<P = CNote, K = <P as RawPitchClass>::Tag>where
P: RawPitchClass<Tag = K>,
K: RawAccidental,{ /* 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: RawAccidental,
impl<P, K> PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: RawAccidental,
pub fn new() -> Self
pub fn from_class(class: P) -> Selfwhere
K: Default,
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>where
T1: RawPitchClass<Tag = A1>,
A1: RawAccidental,
T2: RawPitchClass<Tag = A2>,
A2: RawAccidental,
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>where
T1: RawPitchClass<Tag = A1>,
A1: RawAccidental,
T2: RawPitchClass<Tag = A2>,
A2: RawAccidental,
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§impl<P, K> AsRef<isize> for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: RawAccidental,
impl<P, K> AsRef<isize> for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: RawAccidental,
Source§impl<P, K> AsRef<str> for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: RawAccidental,
impl<P, K> AsRef<str> for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: RawAccidental,
Source§impl<P, K> Borrow<isize> for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: RawAccidental,
impl<P, K> Borrow<isize> for PitchClass<P, K>where
P: RawPitchClass<Tag = K>,
K: RawAccidental,
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 more