pub struct ChromaticInterval { /* private fields */ }Expand description
A signed number of semitones, fractional for microtonal intervals.
Implementations§
Source§impl ChromaticInterval
impl ChromaticInterval
Sourcepub fn new(semitones: FloatType) -> Result<Self>
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.
Sourcepub fn from_int(semitones: IntegerType) -> Self
pub fn from_int(semitones: IntegerType) -> Self
A chromatic interval of a whole number of semitones.
Sourcepub fn undirected(&self) -> FloatType
pub fn undirected(&self) -> FloatType
The semitone count without its sign.
Sourcepub fn whole_semitones(&self) -> IntegerType
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.
Sourcepub fn direction(&self) -> Direction
pub fn direction(&self) -> Direction
Ascending, descending, or oblique for no semitones at all.
Sourcepub fn mod12(&self) -> IntegerType
pub fn mod12(&self) -> IntegerType
The semitones reduced to a pitch class, 0 to 11, so a descending
major third is 8.
Sourcepub fn simple_directed(&self) -> IntegerType
pub fn simple_directed(&self) -> IntegerType
The semitones within one octave, keeping the sign.
Sourcepub fn simple_undirected(&self) -> IntegerType
pub fn simple_undirected(&self) -> IntegerType
The semitones within one octave, without the sign.
Sourcepub fn interval_class(&self) -> IntegerType
pub fn interval_class(&self) -> IntegerType
The interval class, 0 to 6: the smaller of the pitch-class
distance and its complement.
Sourcepub fn is_chromatic_step(&self) -> bool
pub fn is_chromatic_step(&self) -> bool
Whether the interval is one semitone either way.
Sourcepub fn is_step(&self) -> bool
pub fn is_step(&self) -> bool
The same as Self::is_chromatic_step, as music21 defines isStep
on a chromatic interval.
Sourcepub fn get_diatonic(&self) -> DiatonicInterval
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.
Sourcepub fn transpose_pitch(&self, pitch: &Pitch) -> Result<Pitch>
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
impl Clone for ChromaticInterval
Source§fn clone(&self) -> ChromaticInterval
fn clone(&self) -> ChromaticInterval
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChromaticInterval
impl Debug for ChromaticInterval
Source§impl<'de> Deserialize<'de> for ChromaticInterval
Available on crate feature serde only.
impl<'de> Deserialize<'de> for ChromaticInterval
serde only.Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for ChromaticInterval
impl Display for ChromaticInterval
Source§impl PartialEq for ChromaticInterval
impl PartialEq for ChromaticInterval
Source§impl Serialize for ChromaticInterval
Available on crate feature serde only.
impl Serialize for ChromaticInterval
serde only.impl StructuralPartialEq for ChromaticInterval
Auto Trait Implementations§
impl Freeze for ChromaticInterval
impl RefUnwindSafe for ChromaticInterval
impl Send for ChromaticInterval
impl Sync for ChromaticInterval
impl Unpin for ChromaticInterval
impl UnsafeUnpin for ChromaticInterval
impl UnwindSafe for ChromaticInterval
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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