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
impl GenericInterval
Sourcepub fn new(value: IntegerType) -> Result<Self>
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”.
Sourcepub fn from_name(name: &str) -> Result<Self>
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".
Sourcepub fn value(&self) -> IntegerType
pub fn value(&self) -> IntegerType
The signed step count: music21’s value and directed.
Sourcepub fn directed(&self) -> IntegerType
pub fn directed(&self) -> IntegerType
The signed step count.
Sourcepub fn undirected(&self) -> IntegerType
pub fn undirected(&self) -> IntegerType
The step count without its sign.
Sourcepub fn simple_directed(&self) -> IntegerType
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.
Sourcepub fn simple_undirected(&self) -> IntegerType
pub fn simple_undirected(&self) -> IntegerType
The interval within one octave, without the sign.
Sourcepub fn semi_simple_directed(&self) -> IntegerType
pub fn semi_simple_directed(&self) -> IntegerType
Like Self::simple_directed, but an octave stays 8 (or -8)
rather than folding to a unison.
Sourcepub fn semi_simple_undirected(&self) -> IntegerType
pub fn semi_simple_undirected(&self) -> IntegerType
Like Self::simple_undirected, but an octave stays 8.
Sourcepub fn undirected_octaves(&self) -> IntegerType
pub fn undirected_octaves(&self) -> IntegerType
How many whole octaves the interval spans, ignoring direction.
Sourcepub fn octaves(&self) -> IntegerType
pub fn octaves(&self) -> IntegerType
How many whole octaves the interval spans, negative when descending.
Sourcepub fn staff_distance(&self) -> IntegerType
pub fn staff_distance(&self) -> IntegerType
The signed number of staff positions moved: a third is 2, a
descending third -2, a unison 0.
Sourcepub fn mod7(&self) -> IntegerType
pub fn mod7(&self) -> IntegerType
The simple interval measured upward, so a descending third is 6.
Sourcepub fn mod7_inversion(&self) -> IntegerType
pub fn mod7_inversion(&self) -> IntegerType
The inversion of the simple interval: a third becomes a sixth.
Sourcepub fn is_perfectable(&self) -> bool
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.
Sourcepub fn is_diatonic_step(&self) -> bool
pub fn is_diatonic_step(&self) -> bool
The same as Self::is_step, as music21 defines isDiatonicStep
on a generic interval.
Sourcepub fn simple_nice_name(&self) -> String
pub fn simple_nice_name(&self) -> String
The spelled-out name of the simple interval.
Sourcepub fn semi_simple_nice_name(&self) -> String
pub fn semi_simple_nice_name(&self) -> String
The spelled-out name of the semi-simple interval.
Sourcepub fn complement(&self) -> Self
pub fn complement(&self) -> Self
The interval that completes the octave: a third’s complement is a sixth, whatever the direction.
Sourcepub fn reverse(&self) -> Self
pub fn reverse(&self) -> Self
The same interval in the other direction; a unison stays a unison.
Sourcepub fn get_diatonic(&self, spec: Specifier) -> DiatonicInterval
pub fn get_diatonic(&self, spec: Specifier) -> DiatonicInterval
Pairs the interval with a quality.
Sourcepub fn transpose_pitch(&self, pitch: &Pitch) -> Result<Pitch>
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.
Sourcepub fn transpose_pitch_key_aware(
&self,
pitch: &Pitch,
key_signature: Option<&KeySignature>,
) -> Result<Pitch>
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
impl Clone for GenericInterval
Source§fn clone(&self) -> GenericInterval
fn clone(&self) -> GenericInterval
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 GenericInterval
impl Debug for GenericInterval
Source§impl<'de> Deserialize<'de> for GenericInterval
Available on crate feature serde only.
impl<'de> Deserialize<'de> for GenericInterval
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 GenericInterval
impl Display for GenericInterval
impl Eq for GenericInterval
Source§impl Hash for GenericInterval
impl Hash for GenericInterval
Source§impl PartialEq for GenericInterval
impl PartialEq for GenericInterval
Source§impl Serialize for GenericInterval
Available on crate feature serde only.
impl Serialize for GenericInterval
serde only.impl StructuralPartialEq for GenericInterval
Auto Trait Implementations§
impl Freeze for GenericInterval
impl RefUnwindSafe for GenericInterval
impl Send for GenericInterval
impl Sync for GenericInterval
impl Unpin for GenericInterval
impl UnsafeUnpin for GenericInterval
impl UnwindSafe for GenericInterval
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