pub struct Key { /* private fields */ }Expand description
A tonal key with a tonic pitch and mode.
Implementations§
Source§impl Key
impl Key
Sourcepub fn from_tonic_mode<'a, M>(tonic: &str, mode: M) -> Result<Self>
pub fn from_tonic_mode<'a, M>(tonic: &str, mode: M) -> Result<Self>
Builds a key from a tonic and mode.
Pass a mode string such as "major", "minor", "dorian", or
None::<&str> to infer major/minor from tonic case.
Sourcepub fn from_tonic(tonic: &str) -> Result<Self>
pub fn from_tonic(tonic: &str) -> Result<Self>
Builds a key and infers major/minor from tonic case.
Sourcepub fn tonic_pitch(&self) -> &Pitch
pub fn tonic_pitch(&self) -> &Pitch
Returns a borrowed tonic pitch.
Sourcepub fn sharps(&self) -> IntegerType
pub fn sharps(&self) -> IntegerType
Returns the number of sharps in the key signature.
Sourcepub fn key_signature(&self) -> KeySignature
pub fn key_signature(&self) -> KeySignature
Returns the matching key signature.
Sourcepub fn scale(&self) -> DiatonicScale
pub fn scale(&self) -> DiatonicScale
Returns the diatonic scale for this key.
Sourcepub fn pitch_from_degree(&self, degree: usize) -> Result<Pitch>
pub fn pitch_from_degree(&self, degree: usize) -> Result<Pitch>
Returns the pitch at a one-based scale degree.
Sourcepub fn pitches(&self) -> Result<Vec<Pitch>>
pub fn pitches(&self) -> Result<Vec<Pitch>>
Returns scale pitches from degree 1 through the octave.
Sourcepub fn triad_from_degree(&self, degree: usize) -> Result<Chord>
pub fn triad_from_degree(&self, degree: usize) -> Result<Chord>
Builds the diatonic triad on a one-based degree.
Sourcepub fn seventh_chord_from_degree(&self, degree: usize) -> Result<Chord>
pub fn seventh_chord_from_degree(&self, degree: usize) -> Result<Chord>
Builds the diatonic seventh chord on a one-based degree.
Sourcepub fn harmonized_triads(&self) -> Result<Vec<Chord>>
pub fn harmonized_triads(&self) -> Result<Vec<Chord>>
Returns all seven diatonic triads.
Sourcepub fn harmonized_sevenths(&self) -> Result<Vec<Chord>>
pub fn harmonized_sevenths(&self) -> Result<Vec<Chord>>
Returns all seven diatonic seventh chords.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Key
impl RefUnwindSafe for Key
impl Send for Key
impl Sync for Key
impl Unpin for Key
impl UnsafeUnpin for Key
impl UnwindSafe for Key
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