Struct apres::MIDI [−][src]
pub struct MIDI { /* fields omitted */ }
Expand description
Structural representation of MIDI.
Can represent a file or a real-time performance.
Examples
Load a Song
use apres::MIDI; // Create a MIDI from a file match MIDI::from_path("/path/to/file.mid") { Ok(midi) => { } Err(_) => { } }
Create a new MIDI
use apres::MIDI; // Create an empty MIDI file. let midi = MIDI::new();
Creating a song
use apres::MIDI; use apres::MIDIEvent::{NoteOff, NoteOn}; // Create an empty MIDI file. let mut midi = MIDI::new(); // Press midi note 64 (Middle E) on the first track (0) at the first position (0 ticks) midi.insert_event(0, 0, NoteOn(64, 100, 100)); // Release midi note 64 (Middle E) on the first track (0) one beat later (120 ticks) midi.push_event(0, 120, NoteOn(64, 100, 100)); // Save it to a file midi.save("beep.mid");
Implementations
impl MIDI
[src]
impl MIDI
[src]pub fn from_path(file_path: &str) -> Result<MIDI, ApresError>
[src]
pub fn from_path(file_path: &str) -> Result<MIDI, ApresError>
[src]Construct a new MIDI from a .mid file
pub fn get_event_position(&self, event_id: u64) -> Option<&(usize, usize)>
[src]
pub fn get_event_position(&self, event_id: u64) -> Option<&(usize, usize)>
[src]Get the track and tick of an event, given its id
pub fn get_tracks(&self) -> Vec<Vec<(usize, u64)>>
[src]
pub fn get_tracks(&self) -> Vec<Vec<(usize, u64)>>
[src]Get a list of tracks, each populated by lists of event ids. Each list in each track represents a ‘tick’, so it could be empty
pub fn count_tracks(&self) -> usize
[src]
pub fn count_events(&self) -> usize
[src]
pub fn get_track_length(&self, track: usize) -> usize
[src]
pub fn set_format(&mut self, new_format: u16)
[src]
pub fn get_format(&self) -> u16
[src]
pub fn move_event(&mut self, new_track: usize, new_tick: usize, event_id: u64)
[src]
pub fn move_event(&mut self, new_track: usize, new_tick: usize, event_id: u64)
[src]Change the track or position of an event, given it id in the MIDI
pub fn insert_event(
&mut self,
track: usize,
tick: usize,
event: MIDIEvent
) -> u64
[src]
pub fn insert_event(
&mut self,
track: usize,
tick: usize,
event: MIDIEvent
) -> u64
[src]Insert an event into the track
pub fn push_event(&mut self, track: usize, wait: usize, event: MIDIEvent) -> u64
[src]
pub fn push_event(&mut self, track: usize, wait: usize, event: MIDIEvent) -> u64
[src]Insert an event after the latest event in the track
pub fn get_event(&self, event_id: u64) -> Option<MIDIEvent>
[src]
pub fn replace_event(
&mut self,
event_id: u64,
new_midi_event: MIDIEvent
) -> Result<(), ApresError>
[src]
&mut self,
event_id: u64,
new_midi_event: MIDIEvent
) -> Result<(), ApresError>