Struct redact_composer_musical::Interval
source · pub struct Interval(pub u8);
Expand description
A pitch difference, measured in half-steps/semitones.
Tuple Fields§
§0: u8
Implementations§
source§impl Interval
impl Interval
sourcepub fn is_simple(&self) -> bool
pub fn is_simple(&self) -> bool
Returns true
if this is a simple interval (up to one octave).
assert!(Interval::P5.is_simple());
sourcepub fn to_simple(self) -> Interval
pub fn to_simple(self) -> Interval
Return the simple interval counterpart.
Note: This function will reduce Interval::Octave
to Interval::P1
.
assert_eq!(Interval::m9.to_simple(), Interval::m2);
sourcepub fn is_compound(&self) -> bool
pub fn is_compound(&self) -> bool
Returns true
if this is a compound interval (larger than one octave).
assert!(Interval::m9.is_compound());
sourcepub fn to_compound(self) -> Interval
pub fn to_compound(self) -> Interval
Return the compound interval counterpart (added octave). Does nothing if the interval is already compound.
assert_eq!(Interval::m2.to_compound(), Interval::m9);
Trait Implementations§
source§impl Add<Interval> for Note
impl Add<Interval> for Note
source§impl Add<Interval> for PitchClass
impl Add<Interval> for PitchClass
source§fn add(self, rhs: Interval) -> Self::Output
fn add(self, rhs: Interval) -> Self::Output
Returns the pitch class a given interval above this.
use redact_composer_musical::{Interval as I, NoteName::{C, G}, PitchClass};
assert_eq!(PitchClass::from(C) + I::P5, PitchClass::from(G));
assert_eq!(PitchClass::from(C) + I::Octave, PitchClass::from(C));
§type Output = PitchClass
type Output = PitchClass
The resulting type after applying the
+
operator.source§impl AddAssign<Interval> for Note
impl AddAssign<Interval> for Note
source§fn add_assign(&mut self, rhs: Interval)
fn add_assign(&mut self, rhs: Interval)
Performs the
+=
operation. Read moresource§impl AddAssign<Interval> for PitchClass
impl AddAssign<Interval> for PitchClass
source§fn add_assign(&mut self, rhs: Interval)
fn add_assign(&mut self, rhs: Interval)
Performs the
+=
operation. Read moresource§impl AddAssign for Interval
impl AddAssign for Interval
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moresource§impl Ord for Interval
impl Ord for Interval
source§impl PartialEq for Interval
impl PartialEq for Interval
source§impl PartialOrd for Interval
impl PartialOrd for Interval
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl Sub<Interval> for Note
impl Sub<Interval> for Note
source§impl Sub<Interval> for PitchClass
impl Sub<Interval> for PitchClass
source§fn sub(self, rhs: Interval) -> Self::Output
fn sub(self, rhs: Interval) -> Self::Output
Returns the pitch class a given interval below this.
use redact_composer_musical::{Interval as I, NoteName::{C, F}, PitchClass};
assert_eq!(PitchClass::from(C) - I::P5, PitchClass::from(F));
assert_eq!(PitchClass::from(C) - I::Octave, PitchClass::from(C));
§type Output = PitchClass
type Output = PitchClass
The resulting type after applying the
-
operator.source§impl SubAssign<Interval> for Note
impl SubAssign<Interval> for Note
source§fn sub_assign(&mut self, rhs: Interval)
fn sub_assign(&mut self, rhs: Interval)
Performs the
-=
operation. Read moresource§impl SubAssign<Interval> for PitchClass
impl SubAssign<Interval> for PitchClass
source§fn sub_assign(&mut self, rhs: Interval)
fn sub_assign(&mut self, rhs: Interval)
Performs the
-=
operation. Read moreimpl Copy for Interval
impl Eq for Interval
impl StructuralPartialEq for Interval
Auto Trait Implementations§
impl Freeze for Interval
impl RefUnwindSafe for Interval
impl Send for Interval
impl Sync for Interval
impl Unpin for Interval
impl UnwindSafe for Interval
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