Struct redact_composer_musical::Chord
source · pub struct Chord { /* private fields */ }
Expand description
Describes a chord using a root PitchClass
, and ChordShape
.
use redact_composer_musical::{Chord, ChordShape::maj7, PitchClassCollection, NoteName::*};
assert_eq!(Chord::from((C, maj7)).pitch_classes(), [C, E, G, B]);
Implementations§
source§impl Chord
impl Chord
sourcepub fn new<R: Into<PitchClass>>(root: R, shape: ChordShape) -> Chord
pub fn new<R: Into<PitchClass>>(root: R, shape: ChordShape) -> Chord
Constructs a Chord
from a root and interval collection.
sourcepub fn is_in_key(&self, key: &Key) -> bool
pub fn is_in_key(&self, key: &Key) -> bool
Checks if this chord contains notes exclusively from a particular key.
sourcepub fn root(&self) -> PitchClass
pub fn root(&self) -> PitchClass
Returns the root PitchClass
of this chord.
sourcepub fn shape(&self) -> ChordShape
pub fn shape(&self) -> ChordShape
Returns the ChordShape
of this chord. (e.g. maj, min…)
sourcepub fn contains<P: PitchClassCollection>(&self, pitches: &P) -> bool
pub fn contains<P: PitchClassCollection>(&self, pitches: &P) -> bool
Checks if all PitchClass
s from a collection belong to this Chord
.
use redact_composer_musical::{Chord, ChordShape::maj, NoteName::*};
assert!(Chord::from((C, maj)).contains(&[C, E, G]));
Trait Implementations§
source§impl<R> From<(R, ChordShape)> for Chordwhere
R: Into<PitchClass>,
impl<R> From<(R, ChordShape)> for Chordwhere
R: Into<PitchClass>,
source§fn from(value: (R, ChordShape)) -> Self
fn from(value: (R, ChordShape)) -> Self
Converts to this type from the input type.
source§impl IntervalCollection for Chord
impl IntervalCollection for Chord
source§impl NoteIterator for Chord
impl NoteIterator for Chord
source§fn iter_notes_in_range<R: RangeBounds<Note>>(
&self,
note_range: R
) -> NoteIter<R> ⓘ
fn iter_notes_in_range<R: RangeBounds<Note>>( &self, note_range: R ) -> NoteIter<R> ⓘ
Returns a note iterator (
NoteIter
) for notes of an interval pattern within the given note range.source§fn notes_in_range<R: RangeBounds<Note>>(&self, note_range: R) -> Vec<Note>
fn notes_in_range<R: RangeBounds<Note>>(&self, note_range: R) -> Vec<Note>
Returns all notes matching an interval pattern within the given note range.
source§impl PartialEq for Chord
impl PartialEq for Chord
source§impl PitchClassCollection for Chord
impl PitchClassCollection for Chord
source§fn pitch_classes(&self) -> Vec<PitchClass>
fn pitch_classes(&self) -> Vec<PitchClass>
Returns this type’s pitches.
impl Copy for Chord
impl Eq for Chord
impl StructuralPartialEq for Chord
Auto Trait Implementations§
impl Freeze for Chord
impl RefUnwindSafe for Chord
impl Send for Chord
impl Sync for Chord
impl Unpin for Chord
impl UnwindSafe for Chord
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