Skip to main content

MetricModulation

Struct MetricModulation 

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

A change of tempo written as an equation between two metronome marks: music21’s MetricModulation.

The usual one keeps a number and moves it to another note value – quarter = 60 becoming dotted quarter = 60 – so the old mark and the new are what the equation is written with. Either side may be given by its note value alone and take its number from the other, and the old side may take it from the mark in force before the modulation, which a score knows and this type is handed (MetricModulation::update_from).

use music21_rs::{tempo::{MetricModulation, MetronomeMark}, Duration};

let mut modulation = MetricModulation::new();
modulation.set_old_metronome(Some(MetronomeMark::new(60.0)));
modulation.set_new_referent(Duration::half());
assert_eq!(modulation.number(), Some(60.0));
assert_eq!(modulation.new_metronome().unwrap().quarter_bpm(), Some(120.0));

Implementations§

Source§

impl MetricModulation

Source

pub fn new() -> Self

A modulation between two marks not yet given, written with =.

Source

pub fn placement(&self) -> Option<Placement>

Which side of the staff the modulation is written on, where the score says.

Source

pub fn set_placement(&mut self, placement: Option<Placement>)

Says which side of the staff the modulation is written on.

Source

pub fn old_metronome(&self) -> Option<&MetronomeMark>

The mark in force before the modulation, if one is given.

Source

pub fn new_metronome(&self) -> Option<&MetronomeMark>

The mark in force after it, if one is given.

Source

pub fn set_old_metronome(&mut self, mark: Option<MetronomeMark>)

Sets the mark in force before the modulation, or takes it away.

Source

pub fn set_new_metronome(&mut self, mark: Option<MetronomeMark>)

Sets the mark in force after the modulation, or takes it away.

Source

pub fn old_referent(&self) -> Option<&Duration>

The note value the old mark counts.

Source

pub fn new_referent(&self) -> Option<&Duration>

The note value the new mark counts.

Source

pub fn set_old_referent( &mut self, referent: Duration, previous: Option<&MetronomeMark>, )

Counts the old side in referent: the old mark’s own tempo counted that way, or where there is none the tempo of previous – the mark in force before the modulation – counted that way, or failing both a mark with no number yet. music21’s oldReferent setter.

Source

pub fn set_new_referent(&mut self, referent: Duration)

Counts the new side in referent: the new mark’s own tempo counted that way, or where there is none the old mark’s number moved to that note value – the modulation proper – or failing both a mark with no number yet. music21’s newReferent setter.

Source

pub fn number(&self) -> Option<FloatType>

The number of the new mark, which is what the modulation sets.

Source

pub fn update_from(&mut self, previous: Option<&MetronomeMark>)

Fills in what the marks leave unsaid from previous, the mark in force before the modulation: music21’s updateByContext, with the context search done by whoever knows the score.

The old side becomes previous counted in the old side’s note value, or previous itself where there is no old side; and a new side with a note value takes the old side’s number, since the number is what a modulation keeps.

Source

pub fn set_equality_by_referent( &mut self, side: Option<ModulationSide>, referent: Duration, ) -> Result<()>

Sets one side to the same tempo as the other counted in referent: music21’s setEqualityByReferent. With no side named, the side not yet given is the one set; it is an error when both are given or when the other side is missing.

Source

pub fn set_other_by_referent( &mut self, side: Option<ModulationSide>, referent: Duration, ) -> Result<()>

Sets one side to the other’s number counted in referent, which is a different tempo: music21’s setOtherByReferent. The side is chosen as MetricModulation::set_equality_by_referent chooses it.

Source

pub fn classical_style(&self) -> bool

Whether the first mark written is the new tempo rather than the old, the reverse of the usual order: music21’s classicalStyle.

Source

pub fn set_classical_style(&mut self, classical: bool)

Sets whether the first mark written is the new tempo.

Source

pub fn maintain_beat(&self) -> bool

Whether the beat is kept after the equation, as it is going from 3/4 to 6/8: music21’s maintainBeat.

Source

pub fn set_maintain_beat(&mut self, maintain: bool)

Sets whether the beat is kept after the equation.

Source

pub fn transition_symbol(&self) -> &str

What the equation is written with, = unless an edition says otherwise.

Source

pub fn set_transition_symbol(&mut self, symbol: impl Into<String>)

Sets what the equation is written with.

Source

pub fn arrow_direction(&self) -> Option<&str>

Which way an arrow drawn for the equation points, where older editions draw one: "left", "right", or none.

Source

pub fn set_arrow_direction(&mut self, direction: Option<String>)

Sets which way the arrow points, or takes it away.

Source

pub fn parentheses(&self) -> bool

Whether the equation is written in parentheses.

Source

pub fn set_parentheses(&mut self, parentheses: bool)

Sets whether the equation is written in parentheses.

Trait Implementations§

Source§

impl Clone for MetricModulation

Source§

fn clone(&self) -> Self

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 MetricModulation

Source§

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

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

impl Default for MetricModulation

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for MetricModulation

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 From<MetricModulation> for StreamElement

Source§

fn from(value: MetricModulation) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for MetricModulation

Source§

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

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 MetricModulation

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, 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.