pub struct StepScale { /* private fields */ }Expand description
A scale built by walking a cycle of intervals from a tonic.
use music21::{Pitch, StepScale};
let tonic = Pitch::from_name("C4")?;
let cyclical = StepScale::cyclical(tonic.clone(), &["m3", "M3"])?;
let names: Vec<String> = cyclical.pitches()?.iter().map(|p| p.name()).collect();
assert_eq!(names, ["C", "Eb", "G"]);
let repeating = StepScale::octave_repeating(tonic, &["m3", "M3"])?;
let names: Vec<String> = repeating.pitches()?.iter().map(|p| p.name()).collect();
assert_eq!(names, ["C", "Eb", "G", "C"]);Interval implements neither PartialEq nor Hash, so neither is derived
here; compare realized pitches instead.
Implementations§
Source§impl StepScale
impl StepScale
Sourcepub fn cyclical(tonic: Pitch, steps: &[&str]) -> Result<Self>
pub fn cyclical(tonic: Pitch, steps: &[&str]) -> Result<Self>
Builds music21’s CyclicalScale: the intervals walked once, no closing.
A cycle of whole semitones adding up to 1, 2, 3, 4, 6 or 12 semitones
comes back to its tonic within an octave, and is repeated to fill the
octave with its last step spelled to land on the tonic, so it repeats
there: ["M3"] is M3 M3 d4, and ["m2"] is twelve steps.
An empty list defaults to a single m2, as music21 does.
Sourcepub fn cyclical_of(tonic: Pitch, steps: Vec<Interval>) -> Result<Self>
pub fn cyclical_of(tonic: Pitch, steps: Vec<Interval>) -> Result<Self>
The same from intervals already in hand, which is the only way to give a step that has no name: one measured in cents.
Sourcepub fn octave_repeating(tonic: Pitch, steps: &[&str]) -> Result<Self>
pub fn octave_repeating(tonic: Pitch, steps: &[&str]) -> Result<Self>
Builds music21’s OctaveRepeatingScale: the intervals plus a closing
interval that completes the octave, where they do not reach it
already.
An empty list defaults to a single m2, as music21 does.
Steps that come to twelve semitones close on the tonic: the last one
is respelled to land on its octave, so M3 M3 M3 is M3 M3 d4.
Otherwise the closing interval is the complement of the interval
sum, which is how music21 derives it — not the interval between the
last realized pitch and the octave. The two differ in spelling
whenever realization respells a degree: three m2 steps from C sum to
dd4, whose complement is AA5, not the major sixth from the E-
the walk reaches. A note the walk reaches on the tonic’s place is
spelled as the tonic, so that scale still ends on C.
A cycle wider than an octave is closed at the octave above its last
pitch: ["P5", "P5"] is C4 G4 D5 C6.
Sourcepub fn octave_repeating_of(tonic: Pitch, steps: Vec<Interval>) -> Result<Self>
pub fn octave_repeating_of(tonic: Pitch, steps: Vec<Interval>) -> Result<Self>
The same from intervals already in hand.
Sourcepub fn sieve(tonic: Pitch, expression: &str) -> Result<Self>
pub fn sieve(tonic: Pitch, expression: &str) -> Result<Self>
Builds music21’s SieveScale from a Xenakis sieve expression.
The sieve’s interval widths become the cycle, which music21 then treats
as a CyclicalScale — so "3@0" from C is C E- F# A C, and the major-scale
sieve gives a major scale.
The widths are counted in semitones; Self::sieve_by counts them in
anything else.
Sourcepub fn sieve_by(tonic: Pitch, expression: &str, eld: FloatType) -> Result<Self>
pub fn sieve_by(tonic: Pitch, expression: &str, eld: FloatType) -> Result<Self>
The same with the sieve’s unit said: music21’s eld, the elementary
displacement, in semitones. A sieve of every integer counted in twos
is a whole-tone scale, and counted in halves is a scale of quarter
tones.
Sourcepub fn degree_count(&self) -> usize
pub fn degree_count(&self) -> usize
Returns the number of steps, which is one fewer than the pitch count.
Sourcepub fn scale(&self) -> Result<Scale>
pub fn scale(&self) -> Result<Scale>
The same cycle as a Scale, which is what answers everything a
scale is asked past its own notes: a range of them, the degree a note
stands on, the note beside another.
Sourcepub fn pitches(&self) -> Result<Vec<Pitch>>
pub fn pitches(&self) -> Result<Vec<Pitch>>
Returns the pitches of one pass through the cycle, starting at the tonic. Each step is spelled with at most one accidental, as music21’s interval network spells it, and a scale that repeats at the octave ends on its tonic’s name. A tonic with no octave gives pitches with none.
Trait Implementations§
Auto Trait Implementations§
impl Forget for StepScale
impl Freeze for StepScale
impl RefUnwindSafe for StepScale
impl Send for StepScale
impl Sync for StepScale
impl Unpin for StepScale
impl UnsafeUnpin for StepScale
impl UnwindSafe for StepScale
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more