[−][src]Enum tonality::tpc::Tpc
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
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]
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 PartialEq<Tpc> for Tpc
[src]
impl StructuralPartialEq for Tpc
[src]
impl ToPrimitive for Tpc
[src]
fn to_i64(&self) -> Option<i64>
[src]
fn to_u64(&self) -> Option<u64>
[src]
fn to_isize(&self) -> Option<isize>
[src]
fn to_i8(&self) -> Option<i8>
[src]
fn to_i16(&self) -> Option<i16>
[src]
fn to_i32(&self) -> Option<i32>
[src]
fn to_i128(&self) -> Option<i128>
[src]
fn to_usize(&self) -> Option<usize>
[src]
fn to_u8(&self) -> Option<u8>
[src]
fn to_u16(&self) -> Option<u16>
[src]
fn to_u32(&self) -> Option<u32>
[src]
fn to_u128(&self) -> Option<u128>
[src]
fn to_f32(&self) -> Option<f32>
[src]
fn to_f64(&self) -> Option<f64>
[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>,