pub struct TriadBase<S = TriChord, K = Major, T = <S as RawSpace>::Elem>{ /* private fields */ }Expand description
The TriadBase is an implementation of a triad generic over the chord, or storage, its
classification, and the element type used to represent a note within the triadic chord.
Implementations§
Source§impl<S, T, K> TriadBase<S, K, T>
impl<S, T, K> TriadBase<S, K, T>
Sourcepub fn new(chord: S, class: K) -> Selfwhere
T: Zero,
pub fn new(chord: S, class: K) -> Selfwhere
T: Zero,
Returns a new instance of the TriadBase with the given chord and kind.
Sourcepub fn from_root_with_class(root: T, class: K) -> Self
pub fn from_root_with_class(root: T, class: K) -> Self
Create a new triad from a root pitch and class
Sourcepub fn dynamic(self) -> TriadBase<S, Triads, T>
pub fn dynamic(self) -> TriadBase<S, Triads, T>
consumes the instance to use a dynamic classification enum
Sourcepub const fn class_mut(&mut self) -> &mut K
pub const fn class_mut(&mut self) -> &mut K
returns a mutable reference to the class of the triad.
pub const fn octave_mut(&mut self) -> &mut Octave<T>
Sourcepub fn root_mut(&mut self) -> &mut Twhere
S: TriadReprMut,
pub fn root_mut(&mut self) -> &mut Twhere
S: TriadReprMut,
returns a mutable reference to the root note of the triad.
Sourcepub fn third(&self) -> &Twhere
S: TriadRepr,
pub fn third(&self) -> &Twhere
S: TriadRepr,
returns a reference to the third note of the triad.
Sourcepub fn third_mut(&mut self) -> &mut Twhere
S: TriadReprMut,
pub fn third_mut(&mut self) -> &mut Twhere
S: TriadReprMut,
returns a mutable reference to the third note of the triad.
Sourcepub fn fifth(&self) -> &Twhere
S: TriadRepr,
pub fn fifth(&self) -> &Twhere
S: TriadRepr,
returns a reference to the fifth note of the triad.
Sourcepub fn fifth_mut(&mut self) -> &mut Twhere
S: TriadReprMut,
pub fn fifth_mut(&mut self) -> &mut Twhere
S: TriadReprMut,
returns a mutable reference to the fifth note of the triad.
Sourcepub fn set_chord(&mut self, chord: S) -> &mut Self
pub fn set_chord(&mut self, chord: S) -> &mut Self
update the chord and returns a mutable reference to the triad
Sourcepub fn set_class(&mut self, class: K) -> &mut Self
pub fn set_class(&mut self, class: K) -> &mut Self
update the class and returns a mutable reference to the triad
Sourcepub fn with_chord<S2>(self, chord: S2) -> TriadBase<S2, K>
pub fn with_chord<S2>(self, chord: S2) -> TriadBase<S2, K>
consumes the current instance to create another with the given chord
Sourcepub fn with_class<K2>(self, class: K2) -> TriadBase<S, K2>where
K2: TriadType,
pub fn with_class<K2>(self, class: K2) -> TriadBase<S, K2>where
K2: TriadType,
consumes the current instance to create another with the given class
pub fn with_octave(self, octave: Octave<T>) -> Self
Sourcepub fn into_parts(self) -> (S, K)
pub fn into_parts(self) -> (S, K)
consumes the triad and returns the chord and class
Sourcepub fn is_augmented(&self) -> bool
pub fn is_augmented(&self) -> bool
returns true if the triad is classified as an augmented triad.
Sourcepub fn is_diminished(&self) -> bool
pub fn is_diminished(&self) -> bool
returns true if the triad is classified as a diminished triad.
Sourcepub fn centroid<U>(&self) -> Option<[U; 2]>where
T: Copy + ToPrimitive,
U: Float + FromPrimitive + ToPrimitive + Sum<T>,
S: Clone + IntoIterator<Item = T>,
pub fn centroid<U>(&self) -> Option<[U; 2]>where
T: Copy + ToPrimitive,
U: Float + FromPrimitive + ToPrimitive + Sum<T>,
S: Clone + IntoIterator<Item = T>,
computes the centroid of the triad
Sourcepub fn common_tones(&self, other: &Self) -> Vec<T>
pub fn common_tones(&self, other: &Self) -> Vec<T>
returns a collection containing any tones common to both triads
Sourcepub fn transform<X, Y>(self, step: X) -> Ywhere
Self: Transform<X, Output = Y>,
pub fn transform<X, Y>(self, step: X) -> Ywhere
Self: Transform<X, Output = Y>,
apply the given LPR transformation onto the triad, returning a new triad classified
under Q where Q and K are related via the Rel associated type. For example, if
transforming a major triad, then the resulting triad will be minor (and vice versa).
Sourcepub fn path_finder(&self) -> PathFinder<'_, S, K, T>
pub fn path_finder(&self) -> PathFinder<'_, S, K, T>
returns a path finder for the current triad
Source§impl<S, T> TriadBase<S, Diminished, T>where
S: TriadRepr<Elem = T>,
impl<S, T> TriadBase<S, Diminished, T>where
S: TriadRepr<Elem = T>,
Sourcepub fn diminished(root: T) -> Self
pub fn diminished(root: T) -> Self
returns a new instance of the TriadBase with the given chord and kind as a
diminished triad.
Source§impl<T> TriadBase<[T; 3], Triads, T>
impl<T> TriadBase<[T; 3], Triads, T>
Source§impl<T> TriadBase<[T; 3], Triads, T>
impl<T> TriadBase<[T; 3], Triads, T>
Sourcepub fn walk<I>(&self, path: I) -> Selfwhere
I: IntoIterator<Item = LPR>,
pub fn walk<I>(&self, path: I) -> Selfwhere
I: IntoIterator<Item = LPR>,
apply a series of transformations to a triad
Sourcepub fn walk_inplace<I>(&mut self, path: I)where
I: IntoIterator<Item = LPR>,
pub fn walk_inplace<I>(&mut self, path: I)where
I: IntoIterator<Item = LPR>,
apply a chain of transformations to a triad in-place
Trait Implementations§
Source§impl<T, S, K> BorrowMut<S> for TriadBase<S, K, T>
impl<T, S, K> BorrowMut<S> for TriadBase<S, K, T>
Source§fn borrow_mut(&mut self) -> &mut S
fn borrow_mut(&mut self) -> &mut S
Source§impl<T, S, K> IndexMut<Factors> for TriadBase<S, K, T>where
S: TriadReprMut<Elem = T>,
K: TriadType,
impl<T, S, K> IndexMut<Factors> for TriadBase<S, K, T>where
S: TriadReprMut<Elem = T>,
K: TriadType,
Source§impl<'a, S, T, K, I> IntoIterator for &'a TriadBase<S, K, T>
impl<'a, S, T, K, I> IntoIterator for &'a TriadBase<S, K, T>
Source§impl<'a, S, T, K, I> IntoIterator for &'a mut TriadBase<S, K, T>
impl<'a, S, T, K, I> IntoIterator for &'a mut TriadBase<S, K, T>
Source§impl<S, T, K, I> IntoIterator for TriadBase<S, K, T>where
S: TriadRepr<Elem = T> + IntoIterator<Item = I::Item, IntoIter = I>,
K: TriadType,
I: Iterator<Item = T>,
impl<S, T, K, I> IntoIterator for TriadBase<S, K, T>where
S: TriadRepr<Elem = T> + IntoIterator<Item = I::Item, IntoIter = I>,
K: TriadType,
I: Iterator<Item = T>,
Source§impl<S, K, T: PartialOrd> PartialOrd for TriadBase<S, K, T>
impl<S, K, T: PartialOrd> PartialOrd for TriadBase<S, K, T>
impl<S, K, T: Copy> Copy for TriadBase<S, K, T>
impl<S, K, T: Eq> Eq for TriadBase<S, K, T>
Auto Trait Implementations§
impl<S, K, T> Freeze for TriadBase<S, K, T>
impl<S, K, T> RefUnwindSafe for TriadBase<S, K, T>
impl<S, K, T> Send for TriadBase<S, K, T>
impl<S, K, T> Sync for TriadBase<S, K, T>
impl<S, K, T> Unpin for TriadBase<S, K, T>
impl<S, K, T> UnwindSafe for TriadBase<S, K, T>
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> 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