[−][src]Struct libatm::midi_file::MIDIFile
MIDI file representation
MIDI files can be complex, allowing for any number of tracks with different notes and instruments playing simultaneously. This library was created for the express purpose of brute-forcing melodies, and thus only supports a subset of the official MIDI standard. More specifically, this implementation is optimized to create the smallest possible single track MIDI files.
Fields
sequence: MIDINoteVec
Sequence of notes to generate the track chunk from
format: MIDIFormat
Format specification (should always be MIDIFormat::0)
tracks: u16
Number of tracks in MIDI file (should always be 1
)
division: u16
Number of ticks to represent a quarter-note (recommended to use 1
)
Implementations
impl MIDIFile
[src]
pub fn new(
sequence: MIDINoteVec,
format: MIDIFormat,
tracks: u16,
division: u16
) -> MIDIFile
[src]
sequence: MIDINoteVec,
format: MIDIFormat,
tracks: u16,
division: u16
) -> MIDIFile
Create new MIDIFile
Examples
let mfile = libatm::MIDIFile::new( "C:4,CSharp:8,D:5,DSharp:3".parse::<libatm::MIDINoteVec>().unwrap(), libatm::MIDIFormat::Format0, 1, 1, ); assert_eq!("601097451", mfile.gen_hash());
pub fn gen_hash(&self) -> String
[src]
Generate unique hash for this file's MIDINote
sequence
This hash function simply concatenates the sequential integer
representation of the file's sequence of MIDINote
. By this definition,
no two non-identical sequences can have the same hash. The primary
intended purpose of this function is to allow for O(1) lookups by note sequence
once a file has been written to disk.
pub fn gen_header(&self) -> MIDIHeader
[src]
Generate header chunk (see: MIDIHeader)
pub fn gen_track_size(&self) -> u32
[src]
Generate the size of this track chunk header in bytes (on disk)
pub fn gen_track_header(&self) -> MIDITrackHeader
[src]
Generate track chunk header (see: MIDITrackHeader)
pub fn gen_track(&self) -> Vec<MIDIChannelVoiceMessage>
[src]
Generate track data (see: MIDIChannelVoiceMessage)
pub fn gen_size(&self) -> u32
[src]
Generate the size of this MIDI file in bytes (on disk)
pub fn write_buffer<T>(&self, target: &mut T) -> Result<()> where
T: WriteBytesExt,
[src]
T: WriteBytesExt,
Write MIDI file to buffer
pub fn write_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
[src]
Write MIDI file to path on disk
pub fn gen_file(&self) -> Result<Vec<u8>>
[src]
Generate buffer containing entire MIDI file
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for MIDIFile
impl Send for MIDIFile
impl Sync for MIDIFile
impl Unpin for MIDIFile
impl UnwindSafe for MIDIFile
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,