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
impl MetaEvent
Sourcepub fn data_as_u64(&self, bytes: usize) -> u64
pub fn data_as_u64(&self, bytes: usize) -> u64
Turn bytes
bytes of the data of this event into a u64
Sourcepub fn data_as_text(&self) -> Result<String, FromUtf8Error>
pub fn data_as_text(&self) -> Result<String, FromUtf8Error>
Parse the data of this event into a utf8 string
Sourcepub fn next_event(reader: &mut dyn Read) -> Result<MetaEvent, MetaError>
pub fn next_event(reader: &mut dyn Read) -> Result<MetaEvent, MetaError>
Extract the next meta event from a reader
Sourcepub fn sequence_number(sequence_number: u16) -> MetaEvent
pub fn sequence_number(sequence_number: u16) -> MetaEvent
Create a sequence number meta event
Sourcepub fn text_event(text: String) -> MetaEvent
pub fn text_event(text: String) -> MetaEvent
Create a text meta event
Sourcepub fn copyright_notice(copyright: String) -> MetaEvent
pub fn copyright_notice(copyright: String) -> MetaEvent
Create a copyright notice meta event
Sourcepub fn sequence_or_track_name(name: String) -> MetaEvent
pub fn sequence_or_track_name(name: String) -> MetaEvent
Create a name meta event
Sourcepub fn instrument_name(name: String) -> MetaEvent
pub fn instrument_name(name: String) -> MetaEvent
Create an instrument name meta event
Sourcepub fn lyric_text(text: String) -> MetaEvent
pub fn lyric_text(text: String) -> MetaEvent
Create a lyric text meta event
Sourcepub fn marker_text(text: String) -> MetaEvent
pub fn marker_text(text: String) -> MetaEvent
Create a marker text meta event
Sourcepub fn midichannel_prefix_assignment(channel: u8) -> MetaEvent
pub fn midichannel_prefix_assignment(channel: u8) -> MetaEvent
Create a midi channel prefix assignment meta event
Sourcepub fn midiport_prefix_assignment(port: u8) -> MetaEvent
pub fn midiport_prefix_assignment(port: u8) -> MetaEvent
Create a midi port prefix assignment meta event
Sourcepub fn end_of_track() -> MetaEvent
pub fn end_of_track() -> MetaEvent
Create an end of track meta event
Sourcepub fn tempo_setting(tempo: u32) -> MetaEvent
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.
Sourcepub fn smpte_offset(
hours: u8,
minutes: u8,
seconds: u8,
frames: u8,
fractional: u8,
) -> MetaEvent
pub fn smpte_offset( hours: u8, minutes: u8, seconds: u8, frames: u8, fractional: u8, ) -> MetaEvent
Create an smpte offset meta event
Sourcepub fn time_signature(
numerator: u8,
denominator: u8,
clocks_per_tick: u8,
num_32nd_notes_per_24_clocks: u8,
) -> MetaEvent
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
Sourcepub fn key_signature(sharps_flats: u8, major_minor: u8) -> MetaEvent
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’.
Sourcepub fn sequencer_specific_event(data: Vec<u8>) -> MetaEvent
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.