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

source

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 AsChord for Steps

source§

fn as_chord(&self) -> Chord

Borrow self and return a Chord.
source§

impl AsRelativeIntervals for Steps

source§

fn as_relative_intervals(&self, reference: &Self) -> Option<Intervals>

Borrow self and a reference and compare piecewise. Try to return the differences as Interval’s. Inputs must be of equal length.
source§

impl AsScaleTry for Steps

source§

fn as_scale_try(&self, note: Note) -> Option<Scale>

Borrow self and try to return Scale. Note is either the root of the scale or the octave.
source§

impl AsSubs for Steps

source§

fn as_subs(&self, max_len: Option<usize>) -> Vec<Self>

Generate all subs sets with optional maximal subset length. The output size of this grows really fast with the input size so be aware: 2, 5, 16, 65, 326, 1957, 13700, 109601, 986410, 9864101, 108505112.
source§

impl Clone for Steps

source§

fn clone(&self) -> Steps

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 Steps

source§

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

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

impl Default for Steps

source§

fn default() -> Steps

Returns the “default value” for a type. Read more
source§

impl Hash for Steps

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Index<usize> for Steps

§

type Output = Interval

The returned type after indexing.
source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl IndexMut<usize> for Steps

source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl ModeTrait for Steps

source§

fn next_mode_mut(&mut self)

Modify the value so it turns into it’s next mode.
source§

fn next_mode(self) -> Self

Take the value and give back it’s next mode.
source§

fn mode(self, mode: Mode) -> Self

Take the value and give back it’s Nth mode.
source§

impl Ord for Steps

source§

fn cmp(&self, other: &Steps) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Steps> for Steps

source§

fn eq(&self, other: &Steps) -> 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 PartialOrd<Steps> for Steps

source§

fn partial_cmp(&self, other: &Steps) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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 more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl ScaleIteratorSpawner for Steps

source§

fn scale_iter(&self, root: Note) -> ScaleIterator<'_>

Spawn the iterator, with the root or starting note.
source§

impl VecWrapper for Steps

§

type Item = Interval

The type the new type wraps.
source§

fn len(&self) -> usize

Return the length of the inner vector.
source§

fn is_empty(&self) -> bool

Return whether the inner vector is empty or not.
source§

fn iter(&self) -> Iter<'_, Self::Item>

Iterate over the inner vector.
source§

fn contains(&self, item: &Self::Item) -> bool

Returns whether the inner vector contains an item.
source§

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

Returns whether the inner vector contains any of the given items.
source§

impl Wrapper for Steps

§

type Inner = Vec<Interval, Global>

The type the new type wraps.
source§

fn wrap(steps: Self::Inner) -> Option<Self>

Try to wrap a Self::Inner type into the Self type.
source§

fn unwrap(self) -> Self::Inner

Unwrap a Self type into a Self::Inner type.
source§

impl Eq for Steps

source§

impl StructuralEq for Steps

source§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ModeIteratorSpawner<T> for Twhere T: ModeTrait + VecWrapper,

source§

fn mode_iter(self) -> ModeIterator<T>

Spawn the mode iterator.
source§

impl<T> ToChord for Twhere T: AsChord,

source§

fn to_chord(self) -> Chord

Take self and return Chord.
source§

impl<T> ToOwned for Twhere 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> ToRelativeIntervals for Twhere T: AsRelativeIntervals,

source§

fn to_relative_intervals(self, reference: &T) -> Option<Vec<Interval, Global>>

Borrow self and a reference and compare piecewise. Try to return the differences as Interval’s. Inputs must be of equal length.
source§

impl<T> ToScaleTry for Twhere T: AsScaleTry,

source§

fn to_scale_try(self, note: Note) -> Option<Scale>

Take self and try to return Scale. Note is either the root of the scale or the octave.
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.