[][src]Enum tonality::tpc::Tpc

pub enum Tpc {
    Fbb,
    Cbb,
    Gbb,
    Dbb,
    Abb,
    Ebb,
    Bbb,
    Fb,
    Cb,
    Gb,
    Db,
    Ab,
    Eb,
    Bb,
    F,
    C,
    G,
    D,
    A,
    E,
    B,
    Fs,
    Cs,
    Gs,
    Ds,
    As,
    Es,
    Bs,
    Fss,
    Css,
    Gss,
    Dss,
    Ass,
    Ess,
    Bss,
}

Tonal pitch class

Has variants for all pitch classes with double or single flats, natural, double or single sharps.

Note that the "s" and "ss" suffixes mean sharp and double sharp. Should not be confused with the names of flat notes, which in some languages use the -s suffix.

Variants

Fbb
Cbb
Gbb
Dbb
Abb
Ebb
Bbb
Fb
Cb
Gb
Db
Ab
Eb
Bb
F
C
G
D
A
E
B
Fs
Cs
Gs
Ds
As
Es
Bs
Fss
Css
Gss
Dss
Ass
Ess
Bss

Implementations

impl Tpc[src]

pub fn alteration(&self, key: Key) -> Alteration[src]

The number of semitones by which the tpc is altered with respect to the key

Example

// C natural is not altered in the key of A flat
assert_eq!(0, Tpc::C.alteration(Key::Ab));
// A major has C sharp, so a C natural is one semitone flat
assert_eq!(-1, Tpc::C.alteration(Key::A));
// Db major has A flat, so an A sharp is two semitones sharp
assert_eq!(2, Tpc::As.alteration(Key::Db));

pub fn altered_step(&self, key: Option<Key>) -> (Step, Option<Accidental>)[src]

Find the appropriate accidental for the Tpc in a key.

If no key is given, default to C major with no fixed accidentals

Example

let tpc = Tpc::C;
let key: Option<Key> = None;
assert_eq!((Step::C, None), tpc.altered_step(key));
 
let key: Option<Key> = Some(Key::A);
assert_eq!((Step::C, Some(Accidental::Natural)), tpc.altered_step(key));
 
let tpc = Tpc::Fss;
let key: Option<Key> = None;
assert_eq!((Step::F, Some(Accidental::DblSharp)), tpc.altered_step(key));

pub fn alter(&self, by: Alteration) -> Option<Tpc>[src]

Adjust alteration while maintaining the step value

Returns None if the alteration would be sharper than double sharp or flatter than double flat

Trait Implementations

impl Clone for Tpc[src]

impl Debug for Tpc[src]

impl<'_> From<&'_ Tpc> for Step[src]

impl FromPrimitive for Tpc[src]

impl PartialEq<Tpc> for Tpc[src]

impl StructuralPartialEq for Tpc[src]

impl ToPrimitive for Tpc[src]

Auto Trait Implementations

impl RefUnwindSafe for Tpc

impl Send for Tpc

impl Sync for Tpc

impl Unpin for Tpc

impl UnwindSafe for Tpc

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.