Enum Key

Source
pub enum Key {
Show 24 variants CMajor, DFlatMajor, DMajor, EFlatMajor, EMajor, FMajor, FSharpMajor, GMajor, AFlatMajor, AMajor, BFlatMajor, BMajor, CMinor, CSharpMinor, DMinor, EFlatMinor, EMinor, FMinor, FSharpMinor, GMinor, GSharpMinor, AMinor, BFlatMinor, BMinor,
}

Variants§

§

CMajor

§

DFlatMajor

§

DMajor

§

EFlatMajor

§

EMajor

§

FMajor

§

FSharpMajor

§

GMajor

§

AFlatMajor

§

AMajor

§

BFlatMajor

§

BMajor

§

CMinor

§

CSharpMinor

§

DMinor

§

EFlatMinor

§

EMinor

§

FMinor

§

FSharpMinor

§

GMinor

§

GSharpMinor

§

AMinor

§

BFlatMinor

§

BMinor

Implementations§

Source§

impl Key

Source

pub fn from_string(s: &str) -> Result<Self, ()>

Tries parsing the Key from a string. Just a wrapper around KeyParser::try_from_string().

Source

pub fn from_numeric(number: i32, is_major: bool) -> Result<Self, ()>

Get the key from a numeric representation. Mainly used internally. Number needs to be from 1-12 (1=C,2=D,3=E…) and is_major defining if you want the major or minor version of the note. Returns an error if number is <1 or >12.

Source

pub fn from_numeric_wrapping(number: i32, is_major: bool) -> Self

Same as Key::from_numeric() but number is getting wrapped. So 0 would be wrapped to 12, -1 to 11, 13 to 1…

Source

pub fn numeric(&self) -> (i32, bool)

Returns the numeric representation of this Key variant.

Source

pub fn is_major(&self) -> bool

Returns true if this key is a major key, false if it is minor.

Source

pub fn from_open_key_numeric(number: i32, is_major: bool) -> Result<Self, ()>

Source

pub fn from_open_key_numeric_wrapping( number: i32, is_major: bool, ) -> Result<Self, ()>

Source

pub fn open_key_numeric(&self) -> (i32, bool)

Source

pub fn from_lancelot_numeric(number: i32, is_major: bool) -> Result<Self, ()>

Source

pub fn from_lancelot_numeric_wrapping( number: i32, is_major: bool, ) -> Result<Self, ()>

Source

pub fn lancelot_numeric(&self) -> (i32, bool)

Source

pub fn traditional(&self) -> String

Returns the traditional string representation. Eg Abm, F#m, F…

Source

pub fn open_key(&self) -> String

Returns the open key string representation. Eg 1m, 1d, 2m… 12m,12d

Source

pub fn lancelot(&self) -> String

Returns the lancelot string representation. Eg 1A, 1B, 2A… 12A, 12B

Source§

impl Key

Source

pub fn transpose_semitones(&self, semitones: i32) -> Self

Transpose this key by n semitones

Source

pub fn transpose_tones(&self, tones: i32) -> Self

Transpose this key by n full tones

Source

pub fn transpose_factor(&self, factor: f32) -> Self

Transpose this key by a factor. 0.5 would be half the tempo, 2.0 twice the tempo. (Imagine a pitch fader on a vinyl recorder)

Source

pub fn transpose_bpm(&self, initial_bpm: f32, bpm: f32) -> Self

Transpose this key by an initial bpm and a target bpm. Imagine a track has the Key 3A at 135.0bpm (initial_bpm) and you want to know what bpm it is at 140.4bpm (target bpm).

Source

pub fn to_lancelot_i32(&self) -> i32

Return the i32 representation of this Key in the lancelot sorting. The i32 will be between 0 and 23. This is helpful for serialization and sorting.

Source

pub fn try_from_lancelot_i32(number: i32) -> Result<Self, ()>

Try turning an i32 in lancelot sorting into a Key object. See Key::to_lancelot_i32.

Trait Implementations§

Source§

impl Clone for Key

Source§

fn clone(&self) -> Key

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 Key

Source§

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

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

impl Display for Key

Source§

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

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

impl PartialEq for Key

Source§

fn eq(&self, other: &Key) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Key

Source§

impl StructuralPartialEq for Key

Auto Trait Implementations§

§

impl Freeze for Key

§

impl RefUnwindSafe for Key

§

impl Send for Key

§

impl Sync for Key

§

impl Unpin for Key

§

impl UnwindSafe for Key

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> ToOwned for T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.