[−][src]Enum tonality::tpc::Tpc
Tonal pitch class
Has variants for all pitch classes with double or single flats, natural, double or single sharps. The numeric value of the enum corresponds to steps away from C on the "line of fifths". For instance, F is one fifth below C and has the value -1.
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
Implementations
impl Tpc
[src]
pub const MAX: Tpc
[src]
The sharpest valid Tpc: B double sharp
pub const MIN: Tpc
[src]
The flattest valid Tpc: F double flat
pub fn step(self) -> Step
[src]
The basic step of the Tpc, or where it is placed on the staff
assert_eq!(Step::C, Tpc::C.step()); assert_eq!(Step::C, Tpc::Cs.step()); assert_eq!(Tpc::Gb.step(), Tpc::Gs.step());
#[must_use]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));
#[must_use]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
assert_eq!(Some(Tpc::Gs), Tpc::G.alter(1)); assert_eq!(None, Tpc::Bbb.alter(-1)); assert_eq!(Some(Tpc::Abb), Tpc::As.alter(-3));
#[must_use]pub fn enharmonic(self, other: Tpc) -> bool
[src]
Whether the two tpcs are enharmonic, i.e. represent the same pitch class in twelve tone equal temperament.
This relation applies even to tpcs which doesn't have a valid interval between them, such as Abb and Fss.
assert!(Tpc::Gs.enharmonic(Tpc::Ab)); assert!(Tpc::Fs.enharmonic(Tpc::Ess)); assert!(Tpc::Abb.enharmonic(Tpc::Fss)); assert!(!Tpc::Fs.enharmonic(Tpc::F));
Trait Implementations
impl Add<Interval> for Tpc
[src]
type Output = Option<Tpc>
The resulting type after applying the +
operator.
fn add(self, rhs: Interval) -> Self::Output
[src]
impl Clone for Tpc
[src]
impl Copy for Tpc
[src]
impl Debug for Tpc
[src]
impl Eq for Tpc
[src]
impl From<Tpc> for Step
[src]
impl FromPrimitive for Tpc
[src]
fn from_i64(n: i64) -> Option<Self>
[src]
fn from_u64(n: u64) -> Option<Self>
[src]
fn from_isize(n: isize) -> Option<Self>
[src]
fn from_i8(n: i8) -> Option<Self>
[src]
fn from_i16(n: i16) -> Option<Self>
[src]
fn from_i32(n: i32) -> Option<Self>
[src]
fn from_i128(n: i128) -> Option<Self>
[src]
fn from_usize(n: usize) -> Option<Self>
[src]
fn from_u8(n: u8) -> Option<Self>
[src]
fn from_u16(n: u16) -> Option<Self>
[src]
fn from_u32(n: u32) -> Option<Self>
[src]
fn from_u128(n: u128) -> Option<Self>
[src]
fn from_f32(n: f32) -> Option<Self>
[src]
fn from_f64(n: f64) -> Option<Self>
[src]
impl Ord for Tpc
[src]
fn cmp(&self, other: &Tpc) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Tpc> for Tpc
[src]
impl PartialOrd<Tpc> for Tpc
[src]
fn partial_cmp(&self, other: &Tpc) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl StructuralEq for Tpc
[src]
impl StructuralPartialEq for Tpc
[src]
impl Sub<Interval> for Tpc
[src]
type Output = Option<Tpc>
The resulting type after applying the -
operator.
fn sub(self, rhs: Interval) -> Self::Output
[src]
impl Sub<Tpc> 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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,