Enum Intervals

Source
#[repr(u8)]
pub enum Intervals { Semitone = 1, Tone = 2, Thirds(Third), Fourths(Fourth), Fifths(Fifth), Sevenths(Seventh), Octave = 12, }
Expand description

Intervals enumerates the various intervals used within music theory. The system considers a semitone to be the smallest interval, while the octave describe the maximum distance between any two pitches.

Variants§

§

Semitone = 1

§

Tone = 2

§

Thirds(Third)

§

Fourths(Fourth)

§

Fifths(Fifth)

§

Sevenths(Seventh)

§

Octave = 12

Implementations§

Source§

impl Intervals

Source

pub const fn is_semitone(&self) -> bool

Returns true if the enum is Intervals::Semitone otherwise false

Source

pub const fn is_tone(&self) -> bool

Returns true if the enum is Intervals::Tone otherwise false

Source

pub const fn is_thirds(&self) -> bool

Returns true if the enum is Intervals::Thirds otherwise false

Source

pub const fn is_fourths(&self) -> bool

Returns true if the enum is Intervals::Fourths otherwise false

Source

pub const fn is_fifths(&self) -> bool

Returns true if the enum is Intervals::Fifths otherwise false

Source

pub const fn is_sevenths(&self) -> bool

Returns true if the enum is Intervals::Sevenths otherwise false

Source

pub const fn is_octave(&self) -> bool

Returns true if the enum is Intervals::Octave otherwise false

Source§

impl Intervals

Source

pub fn dist(a: impl IntoPitch, b: impl IntoPitch) -> Self

Source

pub fn new<A, B, C>(lhs: A, rhs: B) -> Self
where A: Sub<B, Output = C>, C: Into<Intervals>,

Source

pub fn from_value(value: impl IntoPitch) -> Self

Use the difference between two pitches to determine the interval.

Source

pub fn octave() -> Self

A convenience method for constructing a new instance of the Octave variant.

Source

pub fn semitone() -> Self

A convenience method for constructing a new instance of the Semitone variant.

Source

pub fn tone() -> Self

A convenience method for constructing a new instance of the Tone variant.

Source

pub fn third(third: Third) -> Self

A convenience method for constructing a new variant, Thirds.

Source

pub fn major_third() -> Self

Source

pub fn minor_third() -> Self

Source

pub fn fourth(fourth: Fourth) -> Self

A convenience method for constructing a new variant, Fourths.

Source

pub fn perfect_fourth() -> Self

Source

pub fn fifth(fifth: Fifth) -> Self

A convenience method for constructing a new variant, Fifths.

Source

pub fn augmented_fifth() -> Self

Source

pub fn diminished_fifth() -> Self

Source

pub fn perfect_fifth() -> Self

Source

pub fn seventh(seventh: Seventh) -> Self

A convenience method for constructing a new variant, Sevenths.

Source

pub fn augmented_seventh() -> Self

Source

pub fn diminished_seventh() -> Self

Source

pub fn major_seventh() -> Self

Source

pub fn minor_seventh() -> Self

Source

pub fn as_pitch(&self) -> Pitch

Interpret the current interval as a pitch.

Source

pub fn name(&self) -> &str

Returns the name of the selected interval.

Source

pub fn value(&self) -> i8

Returns the value of the selected interval.

Trait Implementations§

Source§

impl<'a> Add<&'a Note> for &'a Intervals

Source§

type Output = Note

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'a Note) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a> Add<&'a Note> for Intervals

Source§

type Output = Note

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'a Note) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a> Add<Intervals> for &'a Note

Source§

type Output = Note

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Intervals) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<Intervals> for Note

Source§

type Output = Note

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Intervals) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a> Add<Note> for &'a Intervals

Source§

type Output = Note

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Note) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<Note> for Intervals

Source§

type Output = Note

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Note) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign<Intervals> for Note

Source§

fn add_assign(&mut self, rhs: Intervals)

Performs the += operation. Read more
Source§

impl AsRef<str> for Intervals

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Intervals

Source§

fn clone(&self) -> Intervals

Returns a copy 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 Intervals

Source§

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

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

impl Default for Intervals

Source§

fn default() -> Intervals

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Intervals

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Intervals

Source§

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

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

impl<'a> Div<&'a Note> for &'a Intervals

Source§

type Output = Note

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &'a Note) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<&'a Note> for Intervals

Source§

type Output = Note

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &'a Note) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<Intervals> for &'a Note

Source§

type Output = Note

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Intervals) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Intervals> for Note

Source§

type Output = Note

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Intervals) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<Note> for &'a Intervals

Source§

type Output = Note

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Note) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Note> for Intervals

Source§

type Output = Note

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Note) -> Self::Output

Performs the / operation. Read more
Source§

impl DivAssign<Intervals> for Note

Source§

fn div_assign(&mut self, rhs: Intervals)

Performs the /= operation. Read more
Source§

impl From<Fifth> for Intervals

Source§

fn from(value: Fifth) -> Self

Converts to this type from the input type.
Source§

impl From<Fourth> for Intervals

Source§

fn from(value: Fourth) -> Self

Converts to this type from the input type.
Source§

impl<P> From<P> for Intervals
where P: IntoPitch,

Source§

fn from(value: P) -> Self

Converts to this type from the input type.
Source§

impl From<Seventh> for Intervals

Source§

fn from(value: Seventh) -> Self

Converts to this type from the input type.
Source§

impl From<Third> for Intervals

Source§

fn from(value: Third) -> Self

Converts to this type from the input type.
Source§

impl Hash for Intervals

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IntervalKind for Intervals

Source§

fn value(&self) -> i8

Returns the value associated with the interval
Source§

fn kind(&self) -> Intervals

Returns the interval associated with the value
Source§

impl<'a> Mul<&'a Note> for &'a Intervals

Source§

type Output = Note

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'a Note) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<&'a Note> for Intervals

Source§

type Output = Note

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'a Note) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<Intervals> for &'a Note

Source§

type Output = Note

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Intervals) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Intervals> for Note

Source§

type Output = Note

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Intervals) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<Note> for &'a Intervals

Source§

type Output = Note

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Note) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Note> for Intervals

Source§

type Output = Note

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Note) -> Self::Output

Performs the * operation. Read more
Source§

impl MulAssign<Intervals> for Note

Source§

fn mul_assign(&mut self, rhs: Intervals)

Performs the *= operation. Read more
Source§

impl Ord for Intervals

Source§

fn cmp(&self, other: &Intervals) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Intervals

Source§

fn eq(&self, other: &Intervals) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Intervals

Source§

fn partial_cmp(&self, other: &Intervals) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a> Rem<&'a Note> for &'a Intervals

Source§

type Output = Note

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &'a Note) -> Self::Output

Performs the % operation. Read more
Source§

impl<'a> Rem<&'a Note> for Intervals

Source§

type Output = Note

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &'a Note) -> Self::Output

Performs the % operation. Read more
Source§

impl<'a> Rem<Intervals> for &'a Note

Source§

type Output = Note

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Intervals) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<Intervals> for Note

Source§

type Output = Note

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Intervals) -> Self::Output

Performs the % operation. Read more
Source§

impl<'a> Rem<Note> for &'a Intervals

Source§

type Output = Note

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Note) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<Note> for Intervals

Source§

type Output = Note

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Note) -> Self::Output

Performs the % operation. Read more
Source§

impl RemAssign<Intervals> for Note

Source§

fn rem_assign(&mut self, rhs: Intervals)

Performs the %= operation. Read more
Source§

impl Serialize for Intervals

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a> Sub<&'a Note> for &'a Intervals

Source§

type Output = Note

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'a Note) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a> Sub<&'a Note> for Intervals

Source§

type Output = Note

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'a Note) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a> Sub<Intervals> for &'a Note

Source§

type Output = Note

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Intervals) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<Intervals> for Note

Source§

type Output = Note

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Intervals) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a> Sub<Note> for &'a Intervals

Source§

type Output = Note

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Note) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<Note> for Intervals

Source§

type Output = Note

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Note) -> Self::Output

Performs the - operation. Read more
Source§

impl SubAssign<Intervals> for Note

Source§

fn sub_assign(&mut self, rhs: Intervals)

Performs the -= operation. Read more
Source§

impl Copy for Intervals

Source§

impl Eq for Intervals

Source§

impl StructuralPartialEq for Intervals

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<A, B, C> AbsMod<B> for A
where A: Add<C, Output = C> + Copy + Rem<B, Output = C>, B: Copy, C: Add<B, Output = C> + Rem<B, Output = C> + Signed,

Source§

type Output = C

Source§

fn absmod(&self, rhs: B) -> <A as AbsMod<B>>::Output

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<I> IntoInterval for I
where I: Into<Intervals>,

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,

Source§

impl<T, Base> RefNum<Base> for T
where T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>,