Struct music_theory::theory::scale::Steps
source · pub struct Steps(_);
Expand description
A Steps object is a list of intervals. In this case, the list of notes is represented by the intervals between the notes. The scale formulas build from half steps and whole steps such as [W,W,H,W,W,W,H] for the C Major scale are an example of Steps. Steps can also contain negative intervals, and as big leaps as the Interval type allows.
Example:
use music_theory::theory::*;
let W = Interval::WHOLE;
let S = Interval::SEMI;
let steps = Steps::wrap(vec![W, W, S, W, W, W, S]).unwrap(); /* wraps into Option<Steps> so
when you unwrap again you have Steps. */
assert_eq!(
steps.to_scale_try(Note::C1),
Scale::wrap(
vec![Note::C1, Note::D1, Note::E1, Note::F1, Note::G1, Note::A2, Note::B2]
)
);
Implementations§
source§impl Steps
impl Steps
sourcepub fn mode_nr_of_this(&self, mode: &Steps) -> Option<(usize, Steps)>
pub fn mode_nr_of_this(&self, mode: &Steps) -> Option<(usize, Steps)>
Will try to return an index and a copy of the mode.
For example, calling mode_nr_of_this
on a Ionian mode with a Dorian mode should return
the index of 1
.
The index is zero based so giving itself as in input return an index of 0
.
Example:
use music_theory::theory::*;
let W = Interval::WHOLE;
let H = Interval::SEMI;
let major = Steps::wrap(vec![W, W, H, W, W, W, H]).unwrap();
let minor = major.clone().mode(5);
assert_eq!(
major.mode_nr_of_this(&minor),
Some((5, Steps::wrap(vec![ W, H, W, W, H, W, W]).unwrap()))
);
Trait Implementations§
source§impl AsRelativeIntervals for Steps
impl AsRelativeIntervals for Steps
source§impl AsScaleTry for Steps
impl AsScaleTry for Steps
source§impl Ord for Steps
impl Ord for Steps
source§impl PartialEq<Steps> for Steps
impl PartialEq<Steps> for Steps
source§impl PartialOrd<Steps> for Steps
impl PartialOrd<Steps> for Steps
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 ScaleIteratorSpawner for Steps
impl ScaleIteratorSpawner for Steps
source§fn scale_iter(&self, root: Note) -> ScaleIterator<'_> ⓘ
fn scale_iter(&self, root: Note) -> ScaleIterator<'_> ⓘ
Spawn the iterator, with the root or starting note.
source§impl VecWrapper for Steps
impl VecWrapper for Steps
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 Steps
impl StructuralEq for Steps
impl StructuralPartialEq for Steps
Auto Trait Implementations§
impl RefUnwindSafe for Steps
impl Send for Steps
impl Sync for Steps
impl Unpin for Steps
impl UnwindSafe for Steps
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.