[−][src]Struct atm::utils::BatchedMIDIArchive
Container for tar archive of MIDI files
BatchedMIDIArchive
is a convenience wrapper around functionality
to create tar archives of batches of MIDI files. Most hard drives and OS's
align files to 512 bytes, and the official tar spec aligns headers and
entries the same way. However, MIDI files generated by
libatm::MIDIFile, depending on sequence length,
tend to be much smaller (95 bytes for a 12-note sequence). Thus, in order to maximize
disk space usage, this class bundles batches of MIDI files (compressed tar archives)
into each entry in the output tar archive. During testing, All the Music was able to
compress up to 25 MIDI files per batch using the flate2 crate
with the default compression level.
Examples
// Assumes sequence length of 10, 8 possible notes, and partition depth of 2 let mut archive = atm::utils::BatchedMIDIArchive::new( "archive.tar", 2, 4096.0, atm::utils::gen_partition_size(8.0, 10, 4096.0, 2), 20 ); let sequence = "C:4,D:4,E:4,C:4,D:4,E:4,C:4,D:4,E:4,C:4" .parse::<libatm::MIDINoteSequence>() .unwrap(); let mfile = libatm::MIDIFile::new(sequence, libatm::MIDIFormat::Format0, 1, 1); archive.push(mfile).unwrap(); archive.finish().unwrap();
Fields
partition_depth: u32
Number of partitions
max_files: f32
Maximum number of files per partition
partition_size: u32
Number of MIDI notes per partition
batch_size: u32
Number of MIDI files per batch
state: BatchedMIDIArchiveState
Whether archive is Open
or Closed
Methods
impl BatchedMIDIArchive
[src]
pub fn new(
target_path: &str,
partition_depth: u32,
max_files: f32,
partition_size: u32,
batch_size: u32
) -> BatchedMIDIArchive
[src]
target_path: &str,
partition_depth: u32,
max_files: f32,
partition_size: u32,
batch_size: u32
) -> BatchedMIDIArchive
Create new BatchedMIDIArchive
pub fn push(&mut self, mfile: MIDIFile) -> Result<()>
[src]
Add a MIDI file to the archive
If adding the MIDI file breaks a partition or batch boundary, this function will flush the current batch to the underlying tar archive.
pub fn finish(&mut self) -> Result<()>
[src]
Flush current batch to the tar archive and set the state to Closed
After this function is called, no more files can be written to the archive and
the push function will panic
.
Auto Trait Implementations
impl Send for BatchedMIDIArchive
impl Unpin for BatchedMIDIArchive
impl Sync for BatchedMIDIArchive
impl UnwindSafe for BatchedMIDIArchive
impl RefUnwindSafe for BatchedMIDIArchive
Blanket Implementations
impl<T> From<T> for 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,