Skip to main content

ChromaticInterval

Struct ChromaticInterval 

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

A signed number of semitones, fractional for microtonal intervals.

Implementations§

Source§

impl ChromaticInterval

Source

pub fn new(semitones: FloatType) -> Result<Self>

A chromatic interval of semitones, negative for descending and fractional for a microtonal one: a quarter tone is 0.5.

A count that is not finite spells no interval. It used to spell a perfect unison: what reads an interval off a count casts it first, and a cast answers nought for anything it cannot represent.

Source

pub fn from_int(semitones: IntegerType) -> Self

A chromatic interval of a whole number of semitones.

Source

pub fn semitones(&self) -> FloatType

The signed semitone count.

Source

pub fn directed(&self) -> FloatType

The signed semitone count: music21’s directed.

Source

pub fn undirected(&self) -> FloatType

The semitone count without its sign.

Source

pub fn whole_semitones(&self) -> IntegerType

The semitone count rounded to a whole number, which is how music21 reads a microtonal interval wherever it needs a diatonic spelling or a pitch class.

Source

pub fn direction(&self) -> Direction

Ascending, descending, or oblique for no semitones at all.

Source

pub fn cents(&self) -> FloatType

The size in cents, signed, so a quarter tone is 50.0.

Source

pub fn mod12(&self) -> IntegerType

The semitones reduced to a pitch class, 0 to 11, so a descending major third is 8.

Source

pub fn simple_directed(&self) -> IntegerType

The semitones within one octave, keeping the sign.

Source

pub fn simple_undirected(&self) -> IntegerType

The semitones within one octave, without the sign.

Source

pub fn interval_class(&self) -> IntegerType

The interval class, 0 to 6: the smaller of the pitch-class distance and its complement.

Source

pub fn is_chromatic_step(&self) -> bool

Whether the interval is one semitone either way.

Source

pub fn is_step(&self) -> bool

The same as Self::is_chromatic_step, as music21 defines isStep on a chromatic interval.

Source

pub fn reverse(&self) -> Self

The same interval in the other direction.

Source

pub fn get_diatonic(&self) -> DiatonicInterval

The simplest diatonic spelling of the semitone count, as music21’s getDiatonic reads it: six semitones are a diminished fifth, one a minor second, and a microtonal count is rounded to the nearest of those.

Source

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

Moves a pitch by the semitone count, respelling it from its new pitch space the way music21’s chromatic transposePitch does. A pitch without an octave keeps having none.

Trait Implementations§

Source§

impl Clone for ChromaticInterval

Source§

fn clone(&self) -> ChromaticInterval

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 ChromaticInterval

Source§

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

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

impl<'de> Deserialize<'de> for ChromaticInterval

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 ChromaticInterval

Source§

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

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

impl PartialEq for ChromaticInterval

Source§

fn eq(&self, other: &ChromaticInterval) -> 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 ChromaticInterval

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 ChromaticInterval

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.