pub struct Track { /* private fields */ }
Expand description
2.3 - Track Chunks The track chunks (type MTrk) are where actual song data is stored. Each track chunk is simply a stream of MIDI events (and non-MIDI events), preceded by delta-time values. The format for Track Chunks (described below) is exactly the same for all three formats (0, 1, and 2: see “Header Chunk” above) of MIDI Files.
Here is the syntax of an MTrk chunk (the + means “one or more”: at least one MTrk event must be present):
<Track Chunk> = <chunk type><length><MTrk event>+
Implementations§
Source§impl Track
impl Track
Sourcepub fn events_len(&self) -> usize
pub fn events_len(&self) -> usize
The number of events in the track.
Sourcepub fn events(&self) -> impl Iterator<Item = &TrackEvent>
pub fn events(&self) -> impl Iterator<Item = &TrackEvent>
Iterator over the events in the track.
Sourcepub fn push_event(&mut self, delta_time: u32, event: Event) -> Result<()>
pub fn push_event(&mut self, delta_time: u32, event: Event) -> Result<()>
Add an event to the end.
Sourcepub fn insert_event(
&mut self,
index: u32,
delta_time: u32,
event: Event,
) -> Result<()>
pub fn insert_event( &mut self, index: u32, delta_time: u32, event: Event, ) -> Result<()>
Add event at index
and shift everything after it.
Sourcepub fn replace_event(
&mut self,
index: u32,
delta_time: u32,
event: Event,
) -> Result<()>
pub fn replace_event( &mut self, index: u32, delta_time: u32, event: Event, ) -> Result<()>
Replace the event at index
.
Sourcepub fn set_name<S: Into<String>>(&mut self, name: S) -> Result<()>
pub fn set_name<S: Into<String>>(&mut self, name: S) -> Result<()>
Add, or replace, the track name at the beginning of a track.
Sourcepub fn set_instrument_name<S: Into<String>>(&mut self, name: S) -> Result<()>
pub fn set_instrument_name<S: Into<String>>(&mut self, name: S) -> Result<()>
Add, or replace, the instrument name at the beginning of a track.
Sourcepub fn set_general_midi(
&mut self,
channel: Channel,
value: GeneralMidi,
) -> Result<()>
pub fn set_general_midi( &mut self, channel: Channel, value: GeneralMidi, ) -> Result<()>
Add, or replace, the general midi program at the beginning of a track.
Sourcepub fn push_time_signature(
&mut self,
delta_time: u32,
numerator: u8,
denominator: DurationName,
click: Clocks,
) -> Result<()>
pub fn push_time_signature( &mut self, delta_time: u32, numerator: u8, denominator: DurationName, click: Clocks, ) -> Result<()>
Add a time signature.
Sourcepub fn push_tempo(
&mut self,
delta_time: u32,
quarters_per_minute: QuartersPerMinute,
) -> Result<()>
pub fn push_tempo( &mut self, delta_time: u32, quarters_per_minute: QuartersPerMinute, ) -> Result<()>
Add a tempo message.
Sourcepub fn push_note_on(
&mut self,
delta_time: u32,
channel: Channel,
note_number: NoteNumber,
velocity: Velocity,
) -> Result<()>
pub fn push_note_on( &mut self, delta_time: u32, channel: Channel, note_number: NoteNumber, velocity: Velocity, ) -> Result<()>
Add a note on message.
Sourcepub fn push_note_off(
&mut self,
delta_time: u32,
channel: Channel,
note_number: NoteNumber,
velocity: Velocity,
) -> Result<()>
pub fn push_note_off( &mut self, delta_time: u32, channel: Channel, note_number: NoteNumber, velocity: Velocity, ) -> Result<()>
Add a note off message.
Sourcepub fn push_lyric<S: Into<String>>(
&mut self,
delta_time: u32,
lyric: S,
) -> Result<()>
pub fn push_lyric<S: Into<String>>( &mut self, delta_time: u32, lyric: S, ) -> Result<()>
Add a lyric.
Sourcepub fn push_pitch_bend(
&mut self,
delta_time: u32,
channel: Channel,
pitch_bend: PitchBendValue,
) -> Result<()>
pub fn push_pitch_bend( &mut self, delta_time: u32, channel: Channel, pitch_bend: PitchBendValue, ) -> Result<()>
Add a pitch bend value.