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

source

pub fn new<R: Into<PitchClass>>(root: R, shape: ChordShape) -> Chord

Constructs a Chord from a root and interval collection.

source

pub fn is_in_key(&self, key: &Key) -> bool

Checks if this chord contains notes exclusively from a particular key.

source

pub fn root(&self) -> PitchClass

Returns the root PitchClass of this chord.

source

pub fn shape(&self) -> ChordShape

Returns the ChordShape of this chord. (e.g. maj, min…)

source

pub fn contains<P: PitchClassCollection>(&self, pitches: &P) -> bool

Checks if all PitchClasss 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 Clone for Chord

source§

fn clone(&self) -> Chord

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 Chord

source§

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

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

impl<R> From<(R, ChordShape)> for Chord
where R: Into<PitchClass>,

source§

fn from(value: (R, ChordShape)) -> Self

Converts to this type from the input type.
source§

impl IntervalCollection for Chord

source§

fn intervals(&self) -> Vec<Interval>

Provides a collection of intervals, each as an absolute interval from a relative pitch.
source§

impl NoteIterator for Chord

source§

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>

Returns all notes matching an interval pattern within the given note range.
source§

impl PartialEq for Chord

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PitchClassCollection for Chord

source§

fn pitch_classes(&self) -> Vec<PitchClass>

Returns this type’s pitches.
source§

impl Copy for Chord

source§

impl Eq for Chord

source§

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> 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> 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<T> ToOwned for T
where T: Clone,

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V