Skip to main content

GenericInterval

Struct GenericInterval 

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

A directed interval counted in scale steps: 3 is a third up, -3 a third down, 1 a unison. Zero is not an interval.

Implementations§

Source§

impl GenericInterval

Source

pub fn new(value: IntegerType) -> Result<Self>

A generic interval of value steps, signed. Zero is an error, as music21 says: “The Zeroth is not an interval”.

Source

pub fn from_name(name: &str) -> Result<Self>

Parses a generic interval from music21’s spellings: a number, an ordinal such as "third" or "octave", optionally preceded by "descending" or "ascending".

Source

pub fn value(&self) -> IntegerType

The signed step count: music21’s value and directed.

Source

pub fn directed(&self) -> IntegerType

The signed step count.

Source

pub fn undirected(&self) -> IntegerType

The step count without its sign.

Source

pub fn direction(&self) -> Direction

Ascending, descending, or oblique for a unison.

Source

pub fn simple_directed(&self) -> IntegerType

The interval within one octave, keeping the sign, so a descending ninth is -2 and any octave is 1.

Source

pub fn simple_undirected(&self) -> IntegerType

The interval within one octave, without the sign.

Source

pub fn semi_simple_directed(&self) -> IntegerType

Like Self::simple_directed, but an octave stays 8 (or -8) rather than folding to a unison.

Source

pub fn semi_simple_undirected(&self) -> IntegerType

Like Self::simple_undirected, but an octave stays 8.

Source

pub fn undirected_octaves(&self) -> IntegerType

How many whole octaves the interval spans, ignoring direction.

Source

pub fn octaves(&self) -> IntegerType

How many whole octaves the interval spans, negative when descending.

Source

pub fn staff_distance(&self) -> IntegerType

The signed number of staff positions moved: a third is 2, a descending third -2, a unison 0.

Source

pub fn mod7(&self) -> IntegerType

The simple interval measured upward, so a descending third is 6.

Source

pub fn mod7_inversion(&self) -> IntegerType

The inversion of the simple interval: a third becomes a sixth.

Source

pub fn is_perfectable(&self) -> bool

Whether the simple interval is a unison, fourth or fifth, the ones that take perfect rather than major and minor qualities.

Source

pub fn is_step(&self) -> bool

Whether the interval is a second in either direction.

Source

pub fn is_diatonic_step(&self) -> bool

The same as Self::is_step, as music21 defines isDiatonicStep on a generic interval.

Source

pub fn is_skip(&self) -> bool

Whether the interval is larger than a second.

Source

pub fn is_unison(&self) -> bool

Whether the interval is a unison.

Source

pub fn nice_name(&self) -> String

The spelled-out name, Third, Octave, Fifteenth, 23rd.

Source

pub fn simple_nice_name(&self) -> String

The spelled-out name of the simple interval.

Source

pub fn semi_simple_nice_name(&self) -> String

The spelled-out name of the semi-simple interval.

Source

pub fn complement(&self) -> Self

The interval that completes the octave: a third’s complement is a sixth, whatever the direction.

Source

pub fn reverse(&self) -> Self

The same interval in the other direction; a unison stays a unison.

Source

pub fn get_diatonic(&self, spec: Specifier) -> DiatonicInterval

Pairs the interval with a quality.

Source

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

Moves a pitch by the staff distance, keeping its accidental, as music21’s generic transposePitch does: a third above C#4 is E#4.

Source

pub fn transpose_pitch_key_aware( &self, pitch: &Pitch, key_signature: Option<&KeySignature>, ) -> Result<Pitch>

Moves a pitch by the staff distance, taking the accidental from the key signature when one is given and the pitch had none of its own.

Trait Implementations§

Source§

impl Clone for GenericInterval

Source§

fn clone(&self) -> GenericInterval

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GenericInterval

Source§

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

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

impl<'de> Deserialize<'de> for GenericInterval

Available on crate feature serde only.
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 GenericInterval

Source§

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

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

impl Eq for GenericInterval

Source§

impl Hash for GenericInterval

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 PartialEq for GenericInterval

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for GenericInterval

Available on crate feature serde only.
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 StructuralPartialEq for GenericInterval

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.