Skip to main content

TimeSignature

Struct TimeSignature 

Source
pub struct TimeSignature<'a>(/* private fields */);
Expand description

FF 58 04 nn dd cc bb Time Signature

The time signature is expressed as four numbers. nn and dd represent the numerator and denominator of the time signature as it would be notated. The denominator is a negative power of two: 2 represents a quarter-note, 3 represents an eighth-note, etc. The cc parameter expresses the number of MIDI clocks in a metronome click. The bb parameter expresses the number of notated 32nd-notes in a MIDI quarter-note (24 MIDI clocks). This was added because there are already multiple programs which allow a user to specify that what MIDI thinks of as a quarter-note (24 clocks) is to be notated as, or related to in terms of, something else.

Therefore, the complete event for 6/8 time, where the metronome clicks every three eighth-notes, but there are 24 clocks per quarter-note, 72 to the bar, would be (in hex):

FF 58 04 06 03 24 08

That is, 6/8 time (8 is 2 to the 3rd power, so this is 06 03), 36 MIDI clocks per dotted-quarter (24 hex!), and eight notated 32nd-notes per quarter-note.

Implementations§

Source§

impl<'a> TimeSignature<'a>

Source

pub fn new_from_parts( numerator: u8, denominator: u8, clocks_per_quarter: u8, notes_per_clocks: u8, ) -> Self

4 bytes; 6/8 time; 24 MIDI clocks/click, 8 32nd notes/ 24 MIDI clocks (24 MIDI clocks = 1 crotchet = 1 beat) is represented by

let x = TimeSignature::new_from_parts(6, 8, 24, 8);
Source

pub fn new_from_bytes(v: BytesConst<'a, 4>) -> Self

Interpret a byte slice as a time signature

Source

pub fn num(&self) -> u8

numerator of the time signature

Source

pub fn den(&self) -> u8

A negative power of two.

if this returns 3, then 2^3 = 8, so it’s representative of an eigth

Source

pub fn clocks_per_click(&self) -> u8

midi clocks in a metronome click

Source

pub fn notated_32nds_per_24_clocks(&self) -> u8

(24 MIDI clocks = 1 crotchet = 1 beat). 24 midi clocks is a MIDI quarter note

Trait Implementations§

Source§

impl<'a> Clone for TimeSignature<'a>

Source§

fn clone(&self) -> TimeSignature<'a>

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<'a> Debug for TimeSignature<'a>

Source§

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

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

impl Default for TimeSignature<'_>

Source§

fn default() -> Self

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

impl<'a> Hash for TimeSignature<'a>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> PartialEq for TimeSignature<'a>

Source§

fn eq(&self, other: &TimeSignature<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Eq for TimeSignature<'a>

Source§

impl<'a> StructuralPartialEq for TimeSignature<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for TimeSignature<'a>

§

impl<'a> RefUnwindSafe for TimeSignature<'a>

§

impl<'a> Send for TimeSignature<'a>

§

impl<'a> Sync for TimeSignature<'a>

§

impl<'a> Unpin for TimeSignature<'a>

§

impl<'a> UnsafeUnpin for TimeSignature<'a>

§

impl<'a> UnwindSafe for TimeSignature<'a>

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> 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> 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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.