Struct music_theory::theory::chord::RelativeChord
source · pub struct RelativeChord {
pub degree: ScaleDegree,
pub chord: Chord,
}
Expand description
Relative chord is a chord build not from a specific root note but a scale degree. Could be used for example to define chord progressions (eg. II -> V -> I).
Example:
use music_theory::theory::*;
assert_eq!(
RelativeChord::new(ScaleDegree::I, MAJOR),
RelativeChord{ degree: ScaleDegree::I, chord: Chord::new(MAJOR) }
);
Fields§
§degree: ScaleDegree
The degree from which the chord is buld.
chord: Chord
The quality of the chord.
Implementations§
source§impl RelativeChord
impl RelativeChord
sourcepub fn new(degree: ScaleDegree, intervals: &[Note]) -> Self
pub fn new(degree: ScaleDegree, intervals: &[Note]) -> Self
Create a new RelativeChord
from a ScaleDegree
and the chord intervals.
Example:
use music_theory::theory::*;
let chord = RelativeChord::new(ScaleDegree::I, &MAJOR);
assert!(chord.chord.contains_all(&POWER));
sourcepub fn from_chord(degree: ScaleDegree, chord: Chord) -> Self
pub fn from_chord(degree: ScaleDegree, chord: Chord) -> Self
Create a new ‘RelativeChord’ from a ScaleDegree and a chord.
Example:
use music_theory::theory::*;
let chord = RelativeChord::from_chord(ScaleDegree::I, Chord::new(&MAJOR_SEVENTH_CHORD));
assert!(chord.chord.contains_all(&MAJOR));
sourcepub fn as_string(&self, style: ChordStyle) -> String
pub fn as_string(&self, style: ChordStyle) -> String
Stringify the RelativeChord
.
Example:
use music_theory::theory::*;
let std = ChordStyle::Std(MStyle::Symbol, EStyle::Symbol);
assert_eq!(&RelativeChord::new(ScaleDegree::II, &MINOR_MAJOR_SEVENTH).as_string(std), "II-Δ");
sourcepub fn to_rooted_chord_with_pc(self, tonic: PC) -> RootedChord
pub fn to_rooted_chord_with_pc(self, tonic: PC) -> RootedChord
Convert to a RootedChord.
Example:
use music_theory::theory::*;
let rel_chord = RelativeChord::new(ScaleDegree::I, &MAJOR);
let root_chord = RootedChord::new(Note::C0, &MAJOR);
assert_eq!(rel_chord.to_rooted_chord_with_pc(PC::C), root_chord);
sourcepub fn to_rooted_chord_with_note(self, tonic: Note) -> RootedChord
pub fn to_rooted_chord_with_note(self, tonic: Note) -> RootedChord
Convert to a RootedChord.
Example:
use music_theory::theory::*;
let rel_chord = RelativeChord::new(ScaleDegree::I, &MAJOR);
let root_chord = RootedChord::new(Note::C2, &MAJOR);
assert_eq!(rel_chord.to_rooted_chord_with_note(Note::C2), root_chord);
Trait Implementations§
source§impl Clone for RelativeChord
impl Clone for RelativeChord
source§fn clone(&self) -> RelativeChord
fn clone(&self) -> RelativeChord
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for RelativeChord
impl Debug for RelativeChord
source§impl Display for RelativeChord
impl Display for RelativeChord
source§impl Hash for RelativeChord
impl Hash for RelativeChord
source§impl Ord for RelativeChord
impl Ord for RelativeChord
source§fn cmp(&self, other: &RelativeChord) -> Ordering
fn cmp(&self, other: &RelativeChord) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq<RelativeChord> for RelativeChord
impl PartialEq<RelativeChord> for RelativeChord
source§fn eq(&self, other: &RelativeChord) -> bool
fn eq(&self, other: &RelativeChord) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<RelativeChord> for RelativeChord
impl PartialOrd<RelativeChord> for RelativeChord
source§fn partial_cmp(&self, other: &RelativeChord) -> Option<Ordering>
fn partial_cmp(&self, other: &RelativeChord) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for RelativeChord
impl StructuralEq for RelativeChord
impl StructuralPartialEq for RelativeChord
Auto Trait Implementations§
impl RefUnwindSafe for RelativeChord
impl Send for RelativeChord
impl Sync for RelativeChord
impl Unpin for RelativeChord
impl UnwindSafe for RelativeChord
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