Struct music_theory::theory::scale::Scale
source · pub struct Scale(_);
Expand description
A scale is a list of notes. For example, the C2 Major scale contains the notes [C2, D2, E2, F2, G2, A3, B3].
Example:
use music_theory::theory::*;
let scale = Scale::wrap(
vec![Note::C1, Note::D1, Note::E1, Note::F1, Note::G1, Note::A2, Note::B2]
).unwrap();
assert!(scale.contains_all(&[Note::E1, Note::A2]));
Implementations§
source§impl Scale
impl Scale
sourcepub fn as_octave_steps(&self) -> Option<Steps>
pub fn as_octave_steps(&self) -> Option<Steps>
Will try to convert the scale to steps that define an octave scale. This means it needs to fit into one octave. It will add a last step so the steps wrap back onto the first note.
Example:
use music_theory::theory::*;
let W = Interval::WHOLE;
let H = Interval::SEMI;
assert_eq!( // C Major
Scale::wrap(vec![Note::C1, Note::D1, Note::E1, Note::F1, Note::G1, Note::A2, Note::B2])
.unwrap().as_octave_steps(),
Steps::wrap(vec![W, W, H, W, W, W, H])
);
Trait Implementations§
source§impl AsEnharmonicNotes for Scale
impl AsEnharmonicNotes for Scale
source§fn as_enharmonic_notes(&self) -> Vec<EnharmonicNote>
fn as_enharmonic_notes(&self) -> Vec<EnharmonicNote>
Borrow self and return a vector of EnharmonicNote.
source§impl AsEnharmonicNotesWithStart for Scale
impl AsEnharmonicNotesWithStart for Scale
source§fn as_enharmonic_notes_with_start(
&self,
start: Option<EnharmonicNote>
) -> Vec<EnharmonicNote>
fn as_enharmonic_notes_with_start( &self, start: Option<EnharmonicNote> ) -> Vec<EnharmonicNote>
Borrow self and return a vector of EnharmonicNote.
You can optionally specify a starting note.
This will affect the spelling.
Subsequent notes will be spelled with subsequent letters.
source§impl AsRootedChord for Scale
impl AsRootedChord for Scale
source§fn as_rooted_chord(&self) -> RootedChord
fn as_rooted_chord(&self) -> RootedChord
Borrow self and return a RootedChord.
source§impl Ord for Scale
impl Ord for Scale
source§impl PartialEq<Scale> for Scale
impl PartialEq<Scale> for Scale
source§impl PartialOrd<Scale> for Scale
impl PartialOrd<Scale> for Scale
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 moresource§impl VecWrapper for Scale
impl VecWrapper for Scale
source§fn contains(&self, item: &Self::Item) -> bool
fn contains(&self, item: &Self::Item) -> bool
Returns whether the inner vector contains an item.
source§fn contains_all(&self, items: &[Self::Item]) -> bool
fn contains_all(&self, items: &[Self::Item]) -> bool
Returns whether the inner vector contains all of the given items.
source§fn contains_any(&self, items: &[Self::Item]) -> bool
fn contains_any(&self, items: &[Self::Item]) -> bool
Returns whether the inner vector contains any of the given items.
impl Eq for Scale
impl StructuralEq for Scale
impl StructuralPartialEq for Scale
Auto Trait Implementations§
impl RefUnwindSafe for Scale
impl Send for Scale
impl Sync for Scale
impl Unpin for Scale
impl UnwindSafe for Scale
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
source§impl<T> ModeIteratorSpawner<T> for Twhere
T: ModeTrait + VecWrapper,
impl<T> ModeIteratorSpawner<T> for Twhere T: ModeTrait + VecWrapper,
source§fn mode_iter(self) -> ModeIterator<T> ⓘ
fn mode_iter(self) -> ModeIterator<T> ⓘ
Spawn the mode iterator.
source§impl<T> ToEnharmonicNotes for Twhere
T: AsEnharmonicNotes,
impl<T> ToEnharmonicNotes for Twhere T: AsEnharmonicNotes,
source§fn to_enharmonic_notes(self) -> Vec<EnharmonicNote, Global>
fn to_enharmonic_notes(self) -> Vec<EnharmonicNote, Global>
Take self and return a vector of EnharmonicNote.
source§impl<T> ToEnharmonicNotesWithStart for Twhere
T: AsEnharmonicNotesWithStart,
impl<T> ToEnharmonicNotesWithStart for Twhere T: AsEnharmonicNotesWithStart,
source§fn to_enharmonic_notes_with_start(
self,
start: Option<EnharmonicNote>
) -> Vec<EnharmonicNote, Global>
fn to_enharmonic_notes_with_start( self, start: Option<EnharmonicNote> ) -> Vec<EnharmonicNote, Global>
Take self and return a vector of EnharmonicNote.
You can optionally specify a starting note.
This will affect the spelling.
Subsequent notes will be spelled with subsequent letters.
source§impl<T> ToRootedChord for Twhere
T: AsRootedChord,
impl<T> ToRootedChord for Twhere T: AsRootedChord,
source§fn to_rooted_chord(self) -> RootedChord
fn to_rooted_chord(self) -> RootedChord
Take self and return a RootedChord.