Skip to main content

MeterTerminal

Struct MeterTerminal 

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

One span of a bar: a ratio, and how strongly it is felt.

Implementations§

Source§

impl MeterTerminal

Source

pub fn new( numerator: UnsignedIntegerType, denominator: UnsignedIntegerType, ) -> Result<Self>

A span of numerator/denominator, undivided, weighing one.

Source

pub fn from_ratio_string(ratio: &str) -> Result<Self>

The same, read from "3/8".

Source

pub fn numerator(&self) -> UnsignedIntegerType

The numerator this span is written with.

Source

pub fn denominator(&self) -> UnsignedIntegerType

The denominator this span is written with.

Source

pub fn quarter_length(&self) -> FloatType

How long this span is in quarter notes.

Source

pub fn weight(&self) -> FloatType

How strongly this span is felt: music21’s weight.

Source

pub fn set_weight(&mut self, weight: FloatType)

Sets how strongly this span is felt.

Source

pub fn parts(&self) -> &[MeterTerminal]

What this span is divided into. Empty where it is a leaf.

Source

pub fn parts_mut(&mut self) -> &mut Vec<MeterTerminal>

The same, to be changed.

Source

pub fn len(&self) -> usize

How many parts this span has at its top level, music21’s len.

Source

pub fn is_empty(&self) -> bool

Whether this span is divided at all.

Source

pub fn depth(&self) -> usize

How many levels of division this span has: music21’s depth. A leaf is nought.

Source

pub fn flattened(&self) -> Vec<MeterTerminal>

Every leaf of this span, in order: music21’s flatten.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn division_options(&self) -> Vec<Vec<String>>

The ways music21 conventionally divides this meter, in the order it prefers them: music21’s getPartitionOptions.

Source

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.

Source

pub fn level(&self, level: usize, flat: bool) -> Result<Self>

One level of this sequence as a sequence of its own: music21’s getLevel.

Source

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.

Source

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.

Source

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.

Source

pub fn is_uniform_partition(&self, depth: usize) -> bool

Whether every part of a level is the same ratio: music21’s isUniformPartition.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn offset_to_weight(&self, offset: FloatType) -> Result<FloatType>

The weight of the part an offset falls in: music21’s offsetToWeight.

Source

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

Source§

fn clone(&self) -> MeterTerminal

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 MeterTerminal

Source§

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

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

impl<'de> Deserialize<'de> for MeterTerminal

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 MeterTerminal

Source§

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

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

impl PartialEq for MeterTerminal

Source§

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

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 MeterTerminal

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.