pub struct Scale { /* private fields */ }Expand description
A named scale realized from a tonic pitch.
use music21_rs::{Pitch, Scale, ScaleType};
let scale = Scale::new(ScaleType::Octatonic, Pitch::from_name("C4")?);
let names: Vec<String> = scale.pitches()?.iter().map(|p| p.name()).collect();
assert_eq!(names, ["C", "D", "E-", "F", "G-", "A-", "A", "B", "C"]);Implementations§
Source§impl Scale
impl Scale
Sourcepub fn new(scale_type: ScaleType, tonic: Pitch) -> Self
pub fn new(scale_type: ScaleType, tonic: Pitch) -> Self
Builds a scale of the given type on a tonic.
Sourcepub fn scale_type(&self) -> ScaleType
pub fn scale_type(&self) -> ScaleType
Returns the scale type.
Sourcepub fn pitches(&self) -> Result<Vec<Pitch>>
pub fn pitches(&self) -> Result<Vec<Pitch>>
Returns the pitches of one octave, from the tonic through its octave.
The result has degree_count() + 1 entries, since the closing octave is
included the way music21’s getPitches includes it.
Sourcepub fn pitch_at_degree(&self, degree: usize) -> Result<Pitch>
pub fn pitch_at_degree(&self, degree: usize) -> Result<Pitch>
Returns the pitch at a one-based scale degree.
Degree 1 is the tonic and degree_count() + 1 is the octave above it.
Degrees beyond that continue into higher octaves.
Trait Implementations§
impl StructuralPartialEq for Scale
Auto Trait Implementations§
impl Freeze for Scale
impl RefUnwindSafe for Scale
impl Send for Scale
impl Sync for Scale
impl Unpin for Scale
impl UnsafeUnpin 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> 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>
Converts
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>
Converts
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