pub struct StagedMIDIWriter { /* private fields */ }Implementations§
Source§impl StagedMIDIWriter
impl StagedMIDIWriter
Sourcepub fn new(
destination: impl AsRef<Path>,
ppq: u16,
) -> Result<Self, MIDIWriteError>
pub fn new( destination: impl AsRef<Path>, ppq: u16, ) -> Result<Self, MIDIWriteError>
Examples found in repository?
examples/staged_write.rs (line 6)
5fn main() {
6 let writer = StagedMIDIWriter::new("./staged-output.mid", 480).unwrap();
7 println!(
8 "Temporary parts file: {}",
9 writer.temporary_parts_path().display()
10 );
11
12 let mut handles = Vec::new();
13 for track_id in 0..3 {
14 let mut track = writer.try_open_track(track_id).unwrap();
15 handles.push(thread::spawn(move || {
16 for step in 0..8 {
17 let pitch = 60 + step as u8;
18 track
19 .write_all(&[0x00, 0x90 | track_id as u8, pitch, 0x40])
20 .unwrap();
21 track
22 .write_all(&[0x10, 0x80 | track_id as u8, pitch, 0x00])
23 .unwrap();
24 }
25 track.end().unwrap();
26 }));
27 }
28
29 for handle in handles {
30 handle.join().unwrap();
31 }
32
33 writer.end().unwrap();
34 println!(
35 "Final MIDI written to {}",
36 writer.destination_path().display()
37 );
38}Sourcepub fn destination_path(&self) -> &Path
pub fn destination_path(&self) -> &Path
Examples found in repository?
examples/staged_write.rs (line 36)
5fn main() {
6 let writer = StagedMIDIWriter::new("./staged-output.mid", 480).unwrap();
7 println!(
8 "Temporary parts file: {}",
9 writer.temporary_parts_path().display()
10 );
11
12 let mut handles = Vec::new();
13 for track_id in 0..3 {
14 let mut track = writer.try_open_track(track_id).unwrap();
15 handles.push(thread::spawn(move || {
16 for step in 0..8 {
17 let pitch = 60 + step as u8;
18 track
19 .write_all(&[0x00, 0x90 | track_id as u8, pitch, 0x40])
20 .unwrap();
21 track
22 .write_all(&[0x10, 0x80 | track_id as u8, pitch, 0x00])
23 .unwrap();
24 }
25 track.end().unwrap();
26 }));
27 }
28
29 for handle in handles {
30 handle.join().unwrap();
31 }
32
33 writer.end().unwrap();
34 println!(
35 "Final MIDI written to {}",
36 writer.destination_path().display()
37 );
38}Sourcepub fn temporary_parts_path(&self) -> &Path
pub fn temporary_parts_path(&self) -> &Path
Examples found in repository?
examples/staged_write.rs (line 9)
5fn main() {
6 let writer = StagedMIDIWriter::new("./staged-output.mid", 480).unwrap();
7 println!(
8 "Temporary parts file: {}",
9 writer.temporary_parts_path().display()
10 );
11
12 let mut handles = Vec::new();
13 for track_id in 0..3 {
14 let mut track = writer.try_open_track(track_id).unwrap();
15 handles.push(thread::spawn(move || {
16 for step in 0..8 {
17 let pitch = 60 + step as u8;
18 track
19 .write_all(&[0x00, 0x90 | track_id as u8, pitch, 0x40])
20 .unwrap();
21 track
22 .write_all(&[0x10, 0x80 | track_id as u8, pitch, 0x00])
23 .unwrap();
24 }
25 track.end().unwrap();
26 }));
27 }
28
29 for handle in handles {
30 handle.join().unwrap();
31 }
32
33 writer.end().unwrap();
34 println!(
35 "Final MIDI written to {}",
36 writer.destination_path().display()
37 );
38}pub fn write_ppq(&self, ppq: u16) -> Result<(), MIDIWriteError>
pub fn write_format(&self, format: u16) -> Result<(), MIDIWriteError>
pub fn try_open_next_track(&self) -> Result<StagedTrackWriter, MIDIWriteError>
Sourcepub fn try_open_track(
&self,
track_id: i32,
) -> Result<StagedTrackWriter, MIDIWriteError>
pub fn try_open_track( &self, track_id: i32, ) -> Result<StagedTrackWriter, MIDIWriteError>
Examples found in repository?
examples/staged_write.rs (line 14)
5fn main() {
6 let writer = StagedMIDIWriter::new("./staged-output.mid", 480).unwrap();
7 println!(
8 "Temporary parts file: {}",
9 writer.temporary_parts_path().display()
10 );
11
12 let mut handles = Vec::new();
13 for track_id in 0..3 {
14 let mut track = writer.try_open_track(track_id).unwrap();
15 handles.push(thread::spawn(move || {
16 for step in 0..8 {
17 let pitch = 60 + step as u8;
18 track
19 .write_all(&[0x00, 0x90 | track_id as u8, pitch, 0x40])
20 .unwrap();
21 track
22 .write_all(&[0x10, 0x80 | track_id as u8, pitch, 0x00])
23 .unwrap();
24 }
25 track.end().unwrap();
26 }));
27 }
28
29 for handle in handles {
30 handle.join().unwrap();
31 }
32
33 writer.end().unwrap();
34 println!(
35 "Final MIDI written to {}",
36 writer.destination_path().display()
37 );
38}pub fn is_ended(&self) -> bool
pub fn try_end(&self) -> Result<(), MIDIWriteError>
Sourcepub fn end(&self) -> Result<(), MIDIWriteError>
pub fn end(&self) -> Result<(), MIDIWriteError>
Examples found in repository?
examples/staged_write.rs (line 33)
5fn main() {
6 let writer = StagedMIDIWriter::new("./staged-output.mid", 480).unwrap();
7 println!(
8 "Temporary parts file: {}",
9 writer.temporary_parts_path().display()
10 );
11
12 let mut handles = Vec::new();
13 for track_id in 0..3 {
14 let mut track = writer.try_open_track(track_id).unwrap();
15 handles.push(thread::spawn(move || {
16 for step in 0..8 {
17 let pitch = 60 + step as u8;
18 track
19 .write_all(&[0x00, 0x90 | track_id as u8, pitch, 0x40])
20 .unwrap();
21 track
22 .write_all(&[0x10, 0x80 | track_id as u8, pitch, 0x00])
23 .unwrap();
24 }
25 track.end().unwrap();
26 }));
27 }
28
29 for handle in handles {
30 handle.join().unwrap();
31 }
32
33 writer.end().unwrap();
34 println!(
35 "Final MIDI written to {}",
36 writer.destination_path().display()
37 );
38}Trait Implementations§
Auto Trait Implementations§
impl Freeze for StagedMIDIWriter
impl RefUnwindSafe for StagedMIDIWriter
impl Send for StagedMIDIWriter
impl Sync for StagedMIDIWriter
impl Unpin for StagedMIDIWriter
impl UnsafeUnpin for StagedMIDIWriter
impl UnwindSafe for StagedMIDIWriter
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
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more