pub struct TimeSignature { /* private fields */ }Expand description
A time signature, such as 4/4 or 6/8.
use music21_rs::TimeSignature;
let six_eight = TimeSignature::from_ratio_string("6/8")?;
assert_eq!(six_eight.beat_count(), 2);
assert_eq!(six_eight.beat_quarter_length(), 1.5);
assert_eq!(six_eight.classification(), "Compound Duple");Implementations§
Source§impl TimeSignature
impl TimeSignature
Sourcepub fn new(
numerator: UnsignedIntegerType,
denominator: UnsignedIntegerType,
) -> Result<Self>
pub fn new( numerator: UnsignedIntegerType, denominator: UnsignedIntegerType, ) -> Result<Self>
Creates a time signature from a numerator and denominator.
Both must be non-zero. The denominator need not be a power of two —
music21 accepts irrational meters such as 4/3, and so does this.
Sourcepub fn from_ratio_string(ratio: &str) -> Result<Self>
pub fn from_ratio_string(ratio: &str) -> Result<Self>
Parses a "numerator/denominator" string such as "6/8".
Sourcepub fn numerator(self) -> UnsignedIntegerType
pub fn numerator(self) -> UnsignedIntegerType
Returns the numerator.
Sourcepub fn denominator(self) -> UnsignedIntegerType
pub fn denominator(self) -> UnsignedIntegerType
Returns the denominator.
Sourcepub fn ratio_string(self) -> String
pub fn ratio_string(self) -> String
Returns the "numerator/denominator" spelling.
Sourcepub fn bar_quarter_length(self) -> FloatType
pub fn bar_quarter_length(self) -> FloatType
Returns the length of one bar in quarter lengths.
Sourcepub fn bar_duration(self) -> Duration
pub fn bar_duration(self) -> Duration
Returns the length of one bar as a Duration.
Sourcepub fn beat_count(self) -> UnsignedIntegerType
pub fn beat_count(self) -> UnsignedIntegerType
Returns how many beats one bar carries.
This is music21’s beatCount, which follows the numerator rather than
the denominator — except at 3, where 3/4 is three beats but 3/8 is
one.
Sourcepub fn beat_count_name(self) -> String
pub fn beat_count_name(self) -> String
Returns music21’s name for the beat count, such as "Duple".
Counts above eight are spelled as "<n>-uple", as music21 does.
Sourcepub fn beat_quarter_length(self) -> FloatType
pub fn beat_quarter_length(self) -> FloatType
Returns the length of one beat in quarter lengths.
Every meter this type can express has a uniform beat, so unlike
music21’s beatDuration this never fails. music21 only reports a
non-uniform beat for a hand-partitioned MeterSequence, which has no
counterpart here.
Sourcepub fn beat_duration(self) -> Duration
pub fn beat_duration(self) -> Duration
Returns the length of one beat as a Duration.
Sourcepub fn beat_division(self) -> BeatDivision
pub fn beat_division(self) -> BeatDivision
Returns how the beat subdivides.
Sourcepub fn beat_division_count(self) -> UnsignedIntegerType
pub fn beat_division_count(self) -> UnsignedIntegerType
Returns the number of divisions in one beat.
Sourcepub fn is_compound(self) -> bool
pub fn is_compound(self) -> bool
Returns true when beats divide in three.
Sourcepub fn classification(self) -> String
pub fn classification(self) -> String
Returns music21’s classification, such as "Compound Duple".
Sourcepub fn beat_offsets(self) -> Vec<FloatType> ⓘ
pub fn beat_offsets(self) -> Vec<FloatType> ⓘ
Returns the quarter-length offset of each beat within one bar.
Sourcepub fn beat_at_offset(self, offset: FloatType) -> Result<UnsignedIntegerType>
pub fn beat_at_offset(self, offset: FloatType) -> Result<UnsignedIntegerType>
Returns the one-based beat containing offset quarter lengths into a bar.
Matches music21’s getBeat. Offsets at or beyond the end of the bar are
rejected rather than wrapping.
Trait Implementations§
Source§impl Clone for TimeSignature
impl Clone for TimeSignature
Source§fn clone(&self) -> TimeSignature
fn clone(&self) -> TimeSignature
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for TimeSignature
Source§impl Debug for TimeSignature
impl Debug for TimeSignature
Source§impl Default for TimeSignature
impl Default for TimeSignature
Source§impl Display for TimeSignature
impl Display for TimeSignature
impl Eq for TimeSignature
Source§impl Hash for TimeSignature
impl Hash for TimeSignature
Source§impl PartialEq for TimeSignature
impl PartialEq for TimeSignature
Source§fn eq(&self, other: &TimeSignature) -> bool
fn eq(&self, other: &TimeSignature) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for TimeSignature
Auto Trait Implementations§
impl Freeze for TimeSignature
impl RefUnwindSafe for TimeSignature
impl Send for TimeSignature
impl Sync for TimeSignature
impl Unpin for TimeSignature
impl UnsafeUnpin for TimeSignature
impl UnwindSafe for TimeSignature
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,
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