pub struct MeterTerminal { /* private fields */ }Expand description
One span of a bar: a ratio, and how strongly it is felt.
Implementations§
Source§impl MeterTerminal
impl MeterTerminal
Sourcepub fn new(
numerator: UnsignedIntegerType,
denominator: UnsignedIntegerType,
) -> Result<Self>
pub fn new( numerator: UnsignedIntegerType, denominator: UnsignedIntegerType, ) -> Result<Self>
A span of numerator/denominator, undivided, weighing one.
Sourcepub fn from_ratio_string(ratio: &str) -> Result<Self>
pub fn from_ratio_string(ratio: &str) -> Result<Self>
The same, read from "3/8".
Sourcepub fn numerator(&self) -> UnsignedIntegerType
pub fn numerator(&self) -> UnsignedIntegerType
The numerator this span is written with.
Sourcepub fn denominator(&self) -> UnsignedIntegerType
pub fn denominator(&self) -> UnsignedIntegerType
The denominator this span is written with.
Sourcepub fn quarter_length(&self) -> FloatType
pub fn quarter_length(&self) -> FloatType
How long this span is in quarter notes.
Sourcepub fn set_weight(&mut self, weight: FloatType)
pub fn set_weight(&mut self, weight: FloatType)
Sets how strongly this span is felt.
Sourcepub fn parts(&self) -> &[MeterTerminal]
pub fn parts(&self) -> &[MeterTerminal]
What this span is divided into. Empty where it is a leaf.
Sourcepub fn parts_mut(&mut self) -> &mut Vec<MeterTerminal>
pub fn parts_mut(&mut self) -> &mut Vec<MeterTerminal>
The same, to be changed.
Sourcepub fn depth(&self) -> usize
pub fn depth(&self) -> usize
How many levels of division this span has: music21’s depth. A leaf
is nought.
Sourcepub fn flattened(&self) -> Vec<MeterTerminal>
pub fn flattened(&self) -> Vec<MeterTerminal>
Every leaf of this span, in order: music21’s flatten.
Sourcepub fn partition_by_parts(&mut self, parts: &[&str]) -> Result<()>
pub fn partition_by_parts(&mut self, parts: &[&str]) -> Result<()>
Divides this span into the parts named, as ["2/8", "3/8"].
The parts must come to what this span already is; a partition that lengthened or shortened the bar would not be one.
Sourcepub fn partition_by_count(
&mut self,
count: usize,
load_default: bool,
) -> Result<()>
pub fn partition_by_count( &mut self, count: usize, load_default: bool, ) -> Result<()>
Divides this span into count parts, the way music21 divides it.
The first of Self::division_options with that many parts wins. A
count nothing divides into leaves the first option standing, which is
music21’s loadDefault.
Sourcepub fn partition_by_list(
&mut self,
numerators: &[UnsignedIntegerType],
) -> Result<()>
pub fn partition_by_list( &mut self, numerators: &[UnsignedIntegerType], ) -> Result<()>
Divides this span by a list of numerators, as [3, 1] for {3/4+1/4}.
music21 reads the list against this span’s own denominator where the
numerators come to its numerator, and against a finer one where they
come to a multiple of it — [1, 1, 1, 1] of a 2/4 bar is four
eighths, not four quarters.
Sourcepub fn subdivide(&mut self, count: usize) -> Result<()>
pub fn subdivide(&mut self, count: usize) -> Result<()>
Divides this span into count parts and leaves those parts divided
as they were: music21’s MeterTerminal.subdivide.
Sourcepub fn subdivide_partitions_equal(
&mut self,
divisions: Option<usize>,
) -> Result<()>
pub fn subdivide_partitions_equal( &mut self, divisions: Option<usize>, ) -> Result<()>
Divides every part of this span again, the way music21 divides it
when nobody has said how: music21’s subdividePartitionsEqual.
divisions says how many parts each part becomes; None asks for
the division each part conventionally takes — two for a part written
in a binary numerator, three for one written in three, and threes for
the compound numerators. A part nothing divides into is an error,
which is what music21 raises and what a meter written in notes
shorter than a 128th is forgiven.
Sourcepub fn division_options(&self) -> Vec<Vec<String>>
pub fn division_options(&self) -> Vec<Vec<String>>
The ways music21 conventionally divides this meter, in the order it
prefers them: music21’s getPartitionOptions.
Sourcepub fn level_list(&self, level: usize, flat: bool) -> Vec<MeterTerminal>
pub fn level_list(&self, level: usize, flat: bool) -> Vec<MeterTerminal>
The terminals at one level of this sequence: music21’s getLevelList.
A part that is not divided is taken as it stands. A part that is gets
recursed into while there are levels left to descend, and at the level
asked for is either kept whole or, when flat, flattened into a
single terminal carrying that part’s own weight.
Sourcepub fn level(&self, level: usize, flat: bool) -> Result<Self>
pub fn level(&self, level: usize, flat: bool) -> Result<Self>
One level of this sequence as a sequence of its own: music21’s
getLevel.
Sourcepub fn level_span(&self, level: usize) -> Vec<(FloatType, FloatType)>
pub fn level_span(&self, level: usize) -> Vec<(FloatType, FloatType)>
Where each terminal of a level starts and ends, in quarter lengths
from the start of this span: music21’s getLevelSpan.
Sourcepub fn offset_to_depth(
&self,
offset: FloatType,
align: OffsetAlign,
) -> Result<usize>
pub fn offset_to_depth( &self, offset: FloatType, align: OffsetAlign, ) -> Result<usize>
How many levels of this sequence start at an offset: music21’s
offsetToDepth.
A level counts when one of its parts begins where the offset does.
Under OffsetAlign::Quantize the offset is first moved back to the
start of the finest part holding it, so an offset inside a part still
counts the levels that part begins.
Sourcepub fn set_weights_at_level(
&mut self,
level: usize,
weights: &[FloatType],
) -> Result<()>
pub fn set_weights_at_level( &mut self, level: usize, weights: &[FloatType], ) -> Result<()>
Weighs the terminals of a level, looping the weights given over them:
the write half of music21’s setAccentWeight.
A level with no terminals, or no weights to give it, is an error rather than a silent nothing.
Sourcepub fn is_uniform_partition(&self, depth: usize) -> bool
pub fn is_uniform_partition(&self, depth: usize) -> bool
Whether every part of a level is the same ratio: music21’s
isUniformPartition.
Sourcepub fn partition_display(&self) -> String
pub fn partition_display(&self) -> String
The parts written out without the braces around them: music21’s
partitionDisplay, so a bar of 2/4+6/8 reads as it was written.
Sourcepub fn subdivide_by_count(&self, count: usize) -> Result<Self>
pub fn subdivide_by_count(&self, count: usize) -> Result<Self>
This span divided into count parts, as a new sequence: music21’s
subdivideByCount. The weight of this span goes with it.
Sourcepub fn subdivide_by_list(
&self,
numerators: &[UnsignedIntegerType],
) -> Result<Self>
pub fn subdivide_by_list( &self, numerators: &[UnsignedIntegerType], ) -> Result<Self>
This span divided by a list of numerators, as a new sequence:
music21’s subdivideByList.
Sourcepub fn offset_to_index(&self, offset: FloatType) -> Result<usize>
pub fn offset_to_index(&self, offset: FloatType) -> Result<usize>
Which part an offset in quarter notes falls in: music21’s
offsetToIndex. An offset outside the span is an error.
Sourcepub fn offset_to_span(
&self,
offset: FloatType,
permit_meter_modulus: bool,
) -> Result<(FloatType, FloatType)>
pub fn offset_to_span( &self, offset: FloatType, permit_meter_modulus: bool, ) -> Result<(FloatType, FloatType)>
Where the part an offset falls in begins and ends: music21’s
offsetToSpan. With permit_meter_modulus an offset past the end of
the span is read within it.
Sourcepub fn offset_to_weight(&self, offset: FloatType) -> Result<FloatType>
pub fn offset_to_weight(&self, offset: FloatType) -> Result<FloatType>
The weight of the part an offset falls in: music21’s offsetToWeight.
Sourcepub fn partition_string(&self) -> String
pub fn partition_string(&self) -> String
How this span is written: 3/4 undivided, {1/4+1/4+1/4} divided.
Trait Implementations§
Source§impl Clone for MeterTerminal
impl Clone for MeterTerminal
Source§fn clone(&self) -> MeterTerminal
fn clone(&self) -> MeterTerminal
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 MeterTerminal
impl Debug for MeterTerminal
Source§impl<'de> Deserialize<'de> for MeterTerminal
Available on crate feature serde only.
impl<'de> Deserialize<'de> for MeterTerminal
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 MeterTerminal
impl Display for MeterTerminal
Source§impl PartialEq for MeterTerminal
impl PartialEq for MeterTerminal
Source§impl Serialize for MeterTerminal
Available on crate feature serde only.
impl Serialize for MeterTerminal
serde only.impl StructuralPartialEq for MeterTerminal
Auto Trait Implementations§
impl Freeze for MeterTerminal
impl RefUnwindSafe for MeterTerminal
impl Send for MeterTerminal
impl Sync for MeterTerminal
impl Unpin for MeterTerminal
impl UnsafeUnpin for MeterTerminal
impl UnwindSafe for MeterTerminal
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