pub struct MetronomeMark { /* private fields */ }Expand description
A metronome marking: a beats-per-minute number, a tempo word, and the note value the number counts.
Either half may be implied from the other: a number alone picks up the nearest tempo word, and a word alone picks up its conventional number.
Implementations§
Source§impl MetronomeMark
impl MetronomeMark
Sourcepub fn new(number: FloatType) -> Self
pub fn new(number: FloatType) -> Self
A mark of number beats per minute, counting quarter notes, with the
tempo word implied from the number when one is close enough.
Sourcepub fn from_text(text: impl Into<String>) -> Self
pub fn from_text(text: impl Into<String>) -> Self
A mark from a tempo word alone, with the number implied from the word when music21 knows it.
Sourcepub fn with_number_and_text(number: FloatType, text: impl Into<String>) -> Self
pub fn with_number_and_text(number: FloatType, text: impl Into<String>) -> Self
A mark carrying both an explicit number and an explicit word.
Sourcepub fn with_referent(self, referent: Duration) -> Self
pub fn with_referent(self, referent: Duration) -> Self
Changes the note value the number counts, so Duration::half() makes
the number a count of half notes.
Sourcepub fn equivalent_by_referent(&self, referent: Duration) -> MetronomeMark
pub fn equivalent_by_referent(&self, referent: Duration) -> MetronomeMark
The same tempo counted in a different note value: music21’s
getEquivalentByReferent, so quarter = 60 becomes eighth = 120. The
tempo word is carried over unchanged, implied or not.
Sourcepub fn maintained_number_with_referent(
&self,
referent: Duration,
) -> MetronomeMark
pub fn maintained_number_with_referent( &self, referent: Duration, ) -> MetronomeMark
The same number counted in a different note value, so the tempo
itself changes: music21’s getMaintainedNumberWithReferent.
Sourcepub fn set_number(&mut self, number: Option<FloatType>)
pub fn set_number(&mut self, number: Option<FloatType>)
Sets the beats per minute, which is then no longer implied. A mark with no word of its own picks one up, as music21 does.
Sourcepub fn set_text(&mut self, text: impl Into<String>)
pub fn set_text(&mut self, text: impl Into<String>)
Sets the tempo word, which is then no longer implied. A mark with no number of its own picks one up.
Sourcepub fn set_referent(&mut self, referent: Duration)
pub fn set_referent(&mut self, referent: Duration)
Sets the note value the number counts, leaving the number alone — so the tempo itself changes.
Sourcepub fn text_expression(&self, return_implicit: bool) -> Option<&str>
pub fn text_expression(&self, return_implicit: bool) -> Option<&str>
The tempo word as something a score would carry: music21’s
getTextExpression. A word only implied from the number is not
answered unless return_implicit asks for it.
Sourcepub fn number_implicit(&self) -> bool
pub fn number_implicit(&self) -> bool
Whether the number was implied from the tempo word.
Sourcepub fn set_number_implicit(&mut self, implicit: bool)
pub fn set_number_implicit(&mut self, implicit: bool)
Says so, or unsays it. music21 lets a caller write this: its MIDI reader copies a mark onto every staff and marks the copies implicit, which is how the parts after the first hide the number.
Sourcepub fn text_implicit(&self) -> bool
pub fn text_implicit(&self) -> bool
Whether the tempo word was implied from the number.
Sourcepub fn number_sounding(&self) -> Option<FloatType>
pub fn number_sounding(&self) -> Option<FloatType>
music21’s numberSounding: how fast the mark is actually played,
where that is not the number written over the staff.
A score may say Allegro and be played at a hundred and forty-four,
and a MusicXML <sound tempo=...> with no metronome mark beside it
is a tempo that sounds and is never written. Nothing here is
answered from it unless it is asked for: Self::quarter_bpm reads
the written number, and Self::sounding_quarter_bpm reads this.
Sourcepub fn set_number_sounding(&mut self, number: Option<FloatType>)
pub fn set_number_sounding(&mut self, number: Option<FloatType>)
Sets how fast the mark is played, apart from what it says.
Sourcepub fn with_number_sounding(self, number: FloatType) -> Self
pub fn with_number_sounding(self, number: FloatType) -> Self
A mark built to be played at this speed.
It does not become the mark’s number: a mark that says nothing and sounds at a hundred and sixty-eight still says nothing, which is how music21 carries a tempo that is played and never written.
Sourcepub fn quarter_bpm(&self) -> Option<FloatType>
pub fn quarter_bpm(&self) -> Option<FloatType>
The tempo as quarter notes per minute, whatever the referent.
Sourcepub fn sounding_quarter_bpm(&self) -> Option<FloatType>
pub fn sounding_quarter_bpm(&self) -> Option<FloatType>
The same, at the speed the mark is played rather than the one it
says: music21’s getQuarterBPM(useNumberSounding=True).
Sourcepub fn seconds_per_quarter(&self) -> Result<FloatType>
pub fn seconds_per_quarter(&self) -> Result<FloatType>
Seconds each quarter note lasts.
A mark of nought beats a minute is refused rather than answered with an infinity, which is what dividing by it gives and what every arithmetic downstream of it would then carry.
Sourcepub fn quarter_length_to_seconds(
&self,
quarter_length: FloatType,
) -> Result<FloatType>
pub fn quarter_length_to_seconds( &self, quarter_length: FloatType, ) -> Result<FloatType>
Seconds a span of the given quarter length lasts at this tempo.
Sourcepub fn duration_to_seconds(&self, duration: &Duration) -> Result<FloatType>
pub fn duration_to_seconds(&self, duration: &Duration) -> Result<FloatType>
Seconds a duration lasts at this tempo.
Sourcepub fn seconds_to_duration(&self, seconds: FloatType) -> Result<Duration>
pub fn seconds_to_duration(&self, seconds: FloatType) -> Result<Duration>
The duration that lasts the given number of seconds at this tempo.
Trait Implementations§
Source§impl Clone for MetronomeMark
impl Clone for MetronomeMark
Source§fn clone(&self) -> MetronomeMark
fn clone(&self) -> MetronomeMark
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 MetronomeMark
impl Debug for MetronomeMark
Source§impl Default for MetronomeMark
impl Default for MetronomeMark
Source§impl<'de> Deserialize<'de> for MetronomeMark
Available on crate feature serde only.
impl<'de> Deserialize<'de> for MetronomeMark
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<MetronomeMark> for StreamElement
impl From<MetronomeMark> for StreamElement
Source§fn from(value: MetronomeMark) -> Self
fn from(value: MetronomeMark) -> Self
Source§impl PartialEq for MetronomeMark
impl PartialEq for MetronomeMark
Source§impl Serialize for MetronomeMark
Available on crate feature serde only.
impl Serialize for MetronomeMark
serde only.impl StructuralPartialEq for MetronomeMark
Auto Trait Implementations§
impl Freeze for MetronomeMark
impl RefUnwindSafe for MetronomeMark
impl Send for MetronomeMark
impl Sync for MetronomeMark
impl Unpin for MetronomeMark
impl UnsafeUnpin for MetronomeMark
impl UnwindSafe for MetronomeMark
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