Skip to main content

MetronomeMark

Struct MetronomeMark 

Source
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

Source

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.

Source

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.

Source

pub fn with_number_and_text(number: FloatType, text: impl Into<String>) -> Self

A mark carrying both an explicit number and an explicit word.

Source

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.

Source

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.

Source

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.

Source

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

The beats per minute, if known.

Source

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.

Source

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.

Source

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

Sets the note value the number counts, leaving the number alone — so the tempo itself changes.

Source

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

The tempo word, if any.

Source

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.

Source

pub fn referent(&self) -> &Duration

The note value the number counts.

Source

pub fn number_implicit(&self) -> bool

Whether the number was implied from the tempo word.

Source

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.

Source

pub fn text_implicit(&self) -> bool

Whether the tempo word was implied from the number.

Source

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.

Source

pub fn set_number_sounding(&mut self, number: Option<FloatType>)

Sets how fast the mark is played, apart from what it says.

Source

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.

Source

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

The tempo as quarter notes per minute, whatever the referent.

Source

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

Source

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.

Source

pub fn quarter_length_to_seconds( &self, quarter_length: FloatType, ) -> Result<FloatType>

Seconds a span of the given quarter length lasts at this tempo.

Source

pub fn duration_to_seconds(&self, duration: &Duration) -> Result<FloatType>

Seconds a duration lasts at this tempo.

Source

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

Source§

fn clone(&self) -> MetronomeMark

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 MetronomeMark

Source§

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

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

impl Default for MetronomeMark

Source§

fn default() -> Self

A mark that says nothing yet: no number, no word, counting quarters. music21 builds one of these and fills it in.

Source§

impl<'de> Deserialize<'de> for MetronomeMark

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<MetronomeMark> for StreamElement

Source§

fn from(value: MetronomeMark) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for MetronomeMark

Source§

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

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 MetronomeMark

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.