[−][src]Struct libatm::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 class is optimized for creating the smallest possible single track MIDI files.
Fields
sequence: MIDINoteSequence
Sequence of notes (MIDINoteSequence) from which the track chunk is generated
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
)
Methods
impl MIDIFile
[src]
pub fn new(
sequence: MIDINoteSequence,
format: MIDIFormat,
tracks: u16,
division: u16
) -> MIDIFile
[src]
sequence: MIDINoteSequence,
format: MIDIFormat,
tracks: u16,
division: u16
) -> MIDIFile
Create new MIDIFile
Arguments
See field comments above.
Examples
let mfile = libatm::MIDIFile::new( libatm::MIDINoteSequence::new(vec![ libatm::MIDINote::new(libatm::MIDINoteType::C, 4), libatm::MIDINote::new(libatm::MIDINoteType::D, 5), libatm::MIDINote::new(libatm::MIDINoteType::CSharp, 8), libatm::MIDINote::new(libatm::MIDINoteType::DSharp, 3), ]), libatm::MIDIFormat::Format0, 1, 1, ); assert_eq!("607410951", mfile.gen_hash());
pub fn gen_track_size_static(num_notes: u32) -> u32
[src]
Generate the size in bytes of the track chunk for a MIDI file
with a sequence of length num_notes
once written to disk
pub fn gen_size_static(num_notes: u32) -> u32
[src]
Generate the size in bytes of a MIDI file with a sequence of length
num_notes
once written to disk
pub fn gen_hash(&self) -> String
[src]
Generate unique hash for this file's MIDINoteSequence
This hash function simply concatenates the sequential integer
representation of the file's MIDINotesequence
. 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, and thus there is no requirement
to mitigate collisions for identical sequences.
pub fn gen_header(&self) -> MIDIHeader
[src]
Generate header chunk (see: MIDIHeader)
pub fn gen_track_size(&self) -> u32
[src]
Generate the size in bytes of the track chunk once written to 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 in bytes of this MIDI file once written to disk
pub fn write_buffer<T>(&self, target: &mut T) -> Result<()> where
T: WriteBytesExt,
[src]
T: WriteBytesExt,
Write MIDI file to buffer
pub fn gen_buffer(&self) -> Result<Vec<u8>>
[src]
Generate buffer containing entire MIDI file
pub fn write_file(&self, path: &str) -> Result<()>
[src]
Write MIDI file to path on disk
Trait Implementations
impl Clone for MIDIFile
[src]
fn clone(&self) -> MIDIFile
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for MIDIFile
[src]
Auto Trait Implementations
impl Send for MIDIFile
impl Unpin for MIDIFile
impl Sync for MIDIFile
impl UnwindSafe for MIDIFile
impl RefUnwindSafe for MIDIFile
Blanket Implementations
impl<T> From<T> for T
[src]
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> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,