Skip to main content

Interval

Struct Interval 

Source
pub struct Interval { /* private fields */ }
Expand description

A directed musical interval with diatonic spelling and chromatic size.

Implementations§

Source§

impl Interval

Source

pub fn from_name(name: impl Into<String>) -> Result<Self>

Parses an interval name such as "M3", "P5", or "-m6".

Source

pub fn from_semitones(semitones: IntegerType) -> Result<Self>

Creates an implicit diatonic interval from a chromatic semitone count.

Source

pub fn between_pitches(start: &Pitch, end: &Pitch) -> Result<Self>

Returns the directed interval from start to end.

Source

pub fn between_notes(start: &Note, end: &Note) -> Result<Self>

Returns the directed interval from start to end.

Source

pub fn semitones(&self) -> IntegerType

Returns the directed chromatic size in semitones.

Source

pub fn direction(&self) -> IntervalDirection

Returns the directed interval direction.

Source

pub fn name(&self) -> String

Returns the human-readable interval name, such as "Major Third".

Source

pub fn generic_number(&self) -> IntegerType

Returns the simple or compound generic interval number.

Source

pub fn is_implicit_diatonic(&self) -> bool

Returns true when the interval was inferred from semitones only.

Source

pub fn inversion(&self) -> Result<Self>

Returns the complementary interval inversion.

Source

pub fn reversed(&self) -> Result<Self>

Returns the same interval in the opposite direction.

Source

pub fn transpose_pitch(&self, pitch: &Pitch) -> Result<Pitch>

Transposes a pitch by this interval.

Source

pub fn transpose_note(&self, note: &Note) -> Result<Note>

Transposes a note by this interval.

Trait Implementations§

Source§

impl Clone for Interval

Source§

fn clone(&self) -> Interval

Returns a duplicate 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 Interval

Source§

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

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

impl FromStr for Interval

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(value: &str) -> Result<Self>

Parses a string s to return a value of this type. Read more
Source§

impl TryFrom<&str> for Interval

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &str) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<String> for Interval

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: String) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<i32> for Interval

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: IntegerType) -> Result<Self>

Performs the conversion.

Auto Trait Implementations§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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, 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.