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
impl MetricModulation
Sourcepub fn placement(&self) -> Option<Placement>
pub fn placement(&self) -> Option<Placement>
Which side of the staff the modulation is written on, where the score says.
Sourcepub fn set_placement(&mut self, placement: Option<Placement>)
pub fn set_placement(&mut self, placement: Option<Placement>)
Says which side of the staff the modulation is written on.
Sourcepub fn old_metronome(&self) -> Option<&MetronomeMark>
pub fn old_metronome(&self) -> Option<&MetronomeMark>
The mark in force before the modulation, if one is given.
Sourcepub fn new_metronome(&self) -> Option<&MetronomeMark>
pub fn new_metronome(&self) -> Option<&MetronomeMark>
The mark in force after it, if one is given.
Sourcepub fn set_old_metronome(&mut self, mark: Option<MetronomeMark>)
pub fn set_old_metronome(&mut self, mark: Option<MetronomeMark>)
Sets the mark in force before the modulation, or takes it away.
Sourcepub fn set_new_metronome(&mut self, mark: Option<MetronomeMark>)
pub fn set_new_metronome(&mut self, mark: Option<MetronomeMark>)
Sets the mark in force after the modulation, or takes it away.
Sourcepub fn old_referent(&self) -> Option<&Duration>
pub fn old_referent(&self) -> Option<&Duration>
The note value the old mark counts.
Sourcepub fn new_referent(&self) -> Option<&Duration>
pub fn new_referent(&self) -> Option<&Duration>
The note value the new mark counts.
Sourcepub fn set_old_referent(
&mut self,
referent: Duration,
previous: Option<&MetronomeMark>,
)
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.
Sourcepub fn set_new_referent(&mut self, referent: Duration)
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.
Sourcepub fn number(&self) -> Option<FloatType>
pub fn number(&self) -> Option<FloatType>
The number of the new mark, which is what the modulation sets.
Sourcepub fn update_from(&mut self, previous: Option<&MetronomeMark>)
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.
Sourcepub fn set_equality_by_referent(
&mut self,
side: Option<ModulationSide>,
referent: Duration,
) -> Result<()>
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.
Sourcepub fn set_other_by_referent(
&mut self,
side: Option<ModulationSide>,
referent: Duration,
) -> Result<()>
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.
Sourcepub fn classical_style(&self) -> bool
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.
Sourcepub fn set_classical_style(&mut self, classical: bool)
pub fn set_classical_style(&mut self, classical: bool)
Sets whether the first mark written is the new tempo.
Sourcepub fn maintain_beat(&self) -> bool
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.
Sourcepub fn set_maintain_beat(&mut self, maintain: bool)
pub fn set_maintain_beat(&mut self, maintain: bool)
Sets whether the beat is kept after the equation.
Sourcepub fn transition_symbol(&self) -> &str
pub fn transition_symbol(&self) -> &str
What the equation is written with, = unless an edition says
otherwise.
Sourcepub fn set_transition_symbol(&mut self, symbol: impl Into<String>)
pub fn set_transition_symbol(&mut self, symbol: impl Into<String>)
Sets what the equation is written with.
Sourcepub fn arrow_direction(&self) -> Option<&str>
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.
Sourcepub fn set_arrow_direction(&mut self, direction: Option<String>)
pub fn set_arrow_direction(&mut self, direction: Option<String>)
Sets which way the arrow points, or takes it away.
Sourcepub fn parentheses(&self) -> bool
pub fn parentheses(&self) -> bool
Whether the equation is written in parentheses.
Sourcepub fn set_parentheses(&mut self, parentheses: bool)
pub fn set_parentheses(&mut self, parentheses: bool)
Sets whether the equation is written in parentheses.
Trait Implementations§
Source§impl Clone for MetricModulation
impl Clone for MetricModulation
Source§impl Debug for MetricModulation
impl Debug for MetricModulation
Source§impl Default for MetricModulation
impl Default for MetricModulation
Source§impl<'de> Deserialize<'de> for MetricModulation
Available on crate feature serde only.
impl<'de> Deserialize<'de> for MetricModulation
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 From<MetricModulation> for StreamElement
impl From<MetricModulation> for StreamElement
Source§fn from(value: MetricModulation) -> Self
fn from(value: MetricModulation) -> Self
Source§impl PartialEq for MetricModulation
impl PartialEq for MetricModulation
Source§impl Serialize for MetricModulation
Available on crate feature serde only.
impl Serialize for MetricModulation
serde only.impl StructuralPartialEq for MetricModulation
Auto Trait Implementations§
impl Freeze for MetricModulation
impl RefUnwindSafe for MetricModulation
impl Send for MetricModulation
impl Sync for MetricModulation
impl Unpin for MetricModulation
impl UnsafeUnpin for MetricModulation
impl UnwindSafe for MetricModulation
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