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.
Trait Implementations§
source§impl Ord for Track
impl Ord for Track
source§impl PartialOrd for Track
impl PartialOrd for Track
impl Eq for Track
impl StructuralPartialEq for Track
Auto Trait Implementations§
impl Freeze for Track
impl RefUnwindSafe for Track
impl Send for Track
impl Sync for Track
impl Unpin for Track
impl UnwindSafe for Track
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)