Struct MetaEvent

Source
pub struct MetaEvent {
    pub command: MetaCommand,
    pub length: u64,
    pub data: Vec<u8>,
}
Expand description

Meta event building and parsing. See http://cs.fit.edu/~ryan/cse4051/projects/midi/midi.html#meta_event for a description of the various meta events and their formats

Fields§

§command: MetaCommand§length: u64§data: Vec<u8>

Implementations§

Source§

impl MetaEvent

Source

pub fn data_as_u64(&self, bytes: usize) -> u64

Turn bytes bytes of the data of this event into a u64

Source

pub fn data_as_text(&self) -> Result<String, FromUtf8Error>

Parse the data of this event into a utf8 string

Source

pub fn next_event(reader: &mut dyn Read) -> Result<MetaEvent, MetaError>

Extract the next meta event from a reader

Source

pub fn sequence_number(sequence_number: u16) -> MetaEvent

Create a sequence number meta event

Source

pub fn text_event(text: String) -> MetaEvent

Create a text meta event

Source

pub fn copyright_notice(copyright: String) -> MetaEvent

Create a copyright notice meta event

Source

pub fn sequence_or_track_name(name: String) -> MetaEvent

Create a name meta event

Source

pub fn instrument_name(name: String) -> MetaEvent

Create an instrument name meta event

Source

pub fn lyric_text(text: String) -> MetaEvent

Create a lyric text meta event

Source

pub fn marker_text(text: String) -> MetaEvent

Create a marker text meta event

Source

pub fn cue_point(text: String) -> MetaEvent

Create a cue point meta event

Source

pub fn midichannel_prefix_assignment(channel: u8) -> MetaEvent

Create a midi channel prefix assignment meta event

Source

pub fn midiport_prefix_assignment(port: u8) -> MetaEvent

Create a midi port prefix assignment meta event

Source

pub fn end_of_track() -> MetaEvent

Create an end of track meta event

Source

pub fn tempo_setting(tempo: u32) -> MetaEvent

Create an event to set track tempo. This is stored as a 24-bit value. This method will fail an assertion if the supplied tempo is greater than 2^24.

Source

pub fn smpte_offset( hours: u8, minutes: u8, seconds: u8, frames: u8, fractional: u8, ) -> MetaEvent

Create an smpte offset meta event

Source

pub fn time_signature( numerator: u8, denominator: u8, clocks_per_tick: u8, num_32nd_notes_per_24_clocks: u8, ) -> MetaEvent

Create a time signature event. Time signature of the form: numerator/2^denominator eg: 6/8 would be specified using numerator=6, denominator=3

The parameter clocks_per_tick is the number of MIDI Clocks per metronome tick. Normally, there are 24 MIDI Clocks per quarter note. However, some software allows this to be set by the user. The parameter num_32nd_notes_per_24_clocks defines this in terms of the number of 1/32 notes which make up the usual 24 MIDI Clocks (the ‘standard’ quarter note). 8 is standard

Source

pub fn key_signature(sharps_flats: u8, major_minor: u8) -> MetaEvent

Create a Key Signature event expressed as the number of sharps or flats, and a major/minor flag. sharps_flats of 0 represents a key of C, negative numbers represent ‘flats’, while positive numbers represent ‘sharps’.

Source

pub fn sequencer_specific_event(data: Vec<u8>) -> MetaEvent

This is the MIDI-file equivalent of the System Exclusive Message. sequencer-specific directives can be incorporated into a MIDI file using this event.

Trait Implementations§

Source§

impl Clone for MetaEvent

Source§

fn clone(&self) -> MetaEvent

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MetaEvent

Source§

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

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

impl Display for MetaEvent

Source§

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

Formats the value using the given formatter. Read more

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.