pub struct Delta<D: MIDINum, E> {
pub delta: D,
pub event: E,
}
Fields§
§delta: D
§event: E
Implementations§
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 35)
13pub fn main() {
14 println!("Opening midi...");
15 let midi = MIDIFile::open_in_ram(
16 "/mnt/fat/Midis/Ra Ra Rasputin Ultimate Black MIDI Final.mid",
17 None,
18 )
19 .unwrap();
20
21 let ppq = midi.ppq();
22 let merged = pipe!(
23 midi.iter_all_track_events_merged_batches()
24 |>TimeCaster::<f64>::cast_event_delta()
25 |>cancel_tempo_events(250000)
26 |>scale_event_time(1.0 / ppq as f64)
27 |>unwrap_items()
28 );
29
30 println!("Tracks: {}", midi.track_count());
31
32 let start = Instant::now();
33 let mut note_count = 0;
34 for batch in merged {
35 for e in batch.iter_events() {
36 if let Event::NoteOn(_) = e.as_event() {
37 note_count += 1;
38 }
39 }
40 }
41
42 println!("Note count: {} \tTime: {:?}", note_count, start.elapsed());
43 println!(
44 "Notes per second: {}",
45 note_count as f64 / start.elapsed().as_secs_f64()
46 );
47}
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> 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