pub struct Delta<D: MIDINum, E> {
pub delta: D,
pub event: E,
}Fields§
§delta: D§event: EImplementations§
Source§impl<D: MIDINum, T> Delta<D, EventBatch<T>>
impl<D: MIDINum, T> Delta<D, EventBatch<T>>
pub fn into_iter_events(self) -> impl Iterator<Item = Delta<D, T>>
pub fn iter_events(&self) -> impl Iterator<Item = Delta<D, &T>>
Source§impl<D: MIDINum, T> Delta<D, Track<EventBatch<T>>>
impl<D: MIDINum, T> Delta<D, Track<EventBatch<T>>>
Sourcepub fn iter_events(&self) -> impl Iterator<Item = Delta<D, Track<&T>>>
pub fn iter_events(&self) -> impl Iterator<Item = Delta<D, Track<&T>>>
Examples found in repository?
examples/nps_bench.rs (line 30)
9pub fn main() {
10 println!("Opening midi...");
11 let midi = MIDIFile::open_in_ram(
12 "/mnt/fat/Midis/Ra Ra Rasputin Ultimate Black MIDI Final.mid",
13 None,
14 )
15 .unwrap();
16
17 let ppq = midi.ppq();
18 let merged = midi
19 .iter_all_track_events_merged_batches()
20 .cast_event_delta::<f64>()
21 .cancel_tempo_events(250000)
22 .scale_event_time(1.0 / ppq as f64)
23 .unwrap_items();
24
25 println!("Tracks: {}", midi.track_count());
26
27 let start = Instant::now();
28 let mut note_count = 0;
29 for batch in merged {
30 for e in batch.iter_events() {
31 if let Event::NoteOn(_) = e.as_event() {
32 note_count += 1;
33 }
34 }
35 }
36
37 println!("Note count: {} \tTime: {:?}", note_count, start.elapsed());
38 println!(
39 "Notes per second: {}",
40 note_count as f64 / start.elapsed().as_secs_f64()
41 );
42}Trait Implementations§
Source§impl<D: MIDINum, E: BatchTempo> BatchTempo for Delta<D, E>
impl<D: MIDINum, E: BatchTempo> BatchTempo for Delta<D, E>
fn inner_tempo(&self) -> Option<u32>
fn without_tempo(self) -> Option<Self>
Source§impl<D: MIDINum + MIDINumInto<ND>, ND: MIDINum, E> CastEventDelta<ND> for Delta<D, E>
impl<D: MIDINum + MIDINumInto<ND>, ND: MIDINum, E> CastEventDelta<ND> for Delta<D, E>
Source§impl<D: MIDINum, T> IntoIterator for Delta<D, Track<EventBatch<T>>>
impl<D: MIDINum, T> IntoIterator for Delta<D, Track<EventBatch<T>>>
Source§impl<D: MIDINum, E: MIDIEventEnum> MIDIEventEnum for Delta<D, E>
impl<D: MIDINum, E: MIDIEventEnum> MIDIEventEnum for Delta<D, E>
Source§impl<D: MIDINum, E: SerializeEvent> SerializeEvent for Delta<D, E>
impl<D: MIDINum, E: SerializeEvent> SerializeEvent for Delta<D, E>
fn serialize_event<T: Write>( &self, buf: &mut T, ) -> Result<usize, MIDIWriteError>
Source§impl<E: SerializeEvent> SerializeEventWithDelta for Delta<u64, E>
impl<E: SerializeEvent> SerializeEventWithDelta for Delta<u64, E>
fn serialize_delta<T: Write>( &self, buf: &mut T, ) -> Result<usize, MIDIWriteError>
fn serialize_event_with_delta<T: Write>( &self, buf: &mut T, ) -> Result<usize, MIDIWriteError>
impl<D: Eq + MIDINum, E: Eq> Eq for Delta<D, E>
impl<D: MIDINum, E> StructuralPartialEq for Delta<D, E>
Auto Trait Implementations§
impl<D, E> Freeze for Delta<D, E>
impl<D, E> RefUnwindSafe for Delta<D, E>where
D: RefUnwindSafe,
E: RefUnwindSafe,
impl<D, E> Send for Delta<D, E>where
E: Send,
impl<D, E> Sync for Delta<D, E>where
E: Sync,
impl<D, E> Unpin for Delta<D, E>
impl<D, E> UnsafeUnpin for Delta<D, E>where
D: UnsafeUnpin,
E: UnsafeUnpin,
impl<D, E> UnwindSafe for Delta<D, E>where
D: UnwindSafe,
E: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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