Struct Delta

Source
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>>

Source

pub fn into_iter_events(self) -> impl Iterator<Item = Delta<D, T>>

Source

pub fn iter_events(&self) -> impl Iterator<Item = Delta<D, &T>>

Source§

impl<D: MIDINum, T> Delta<D, Track<EventBatch<T>>>

Source

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}
Source§

impl<D: MIDINum, E> Delta<D, E>

Source

pub fn new(delta: D, event: E) -> Self

Trait Implementations§

Source§

impl<D: MIDINum, E: BatchTempo> BatchTempo for Delta<D, E>

Source§

impl<D: MIDINum + MIDINumInto<ND>, ND: MIDINum, E> CastEventDelta<ND> for Delta<D, E>

Source§

type Output = Delta<ND, E>

Source§

fn cast_delta(self) -> Self::Output

Source§

impl<D: Clone + MIDINum, E: Clone> Clone for Delta<D, E>

Source§

fn clone(&self) -> Delta<D, E>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<D: Debug + MIDINum, E: Debug> Debug for Delta<D, E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<D: MIDINum, E> Deref for Delta<D, E>

Source§

type Target = E

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<D: MIDINum, E> DerefMut for Delta<D, E>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<D: MIDINum, T> IntoIterator for Delta<D, Track<EventBatch<T>>>

Source§

type Item = Delta<D, Track<T>>

The type of the elements being iterated over.
Source§

type IntoIter = impl Iterator<Item = Delta<D, Track<T>>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<D: MIDINum, E> MIDIDelta<D> for Delta<D, E>

Source§

fn delta(&self) -> D

Source§

fn delta_mut(&mut self) -> &mut D

Source§

fn set_delta(&mut self, delta: D)

Source§

impl<D: MIDINum, E: MIDIEventEnum> MIDIEvent for Delta<D, E>

Source§

fn key(&self) -> Option<u8>

Source§

fn key_mut(&mut self) -> Option<&mut u8>

Source§

fn channel(&self) -> Option<u8>

Source§

fn channel_mut(&mut self) -> Option<&mut u8>

Source§

fn as_u32(&self) -> Option<u32>

Source§

impl<D: MIDINum, E: MIDIEventEnum> MIDIEventEnum for Delta<D, E>

Source§

fn as_event(&self) -> &Event

Source§

fn as_event_mut(&mut self) -> &mut Event

Source§

impl<D: PartialEq + MIDINum, E: PartialEq> PartialEq for Delta<D, E>

Source§

fn eq(&self, other: &Delta<D, E>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<D: MIDINum, E: SerializeEvent> SerializeEvent for Delta<D, E>

Source§

impl<E: SerializeEvent> SerializeEventWithDelta for Delta<u64, E>

Source§

impl<D: Eq + MIDINum, E: Eq> Eq for Delta<D, E>

Source§

impl<D: MIDINum, E> StructuralPartialEq for Delta<D, E>

Auto Trait Implementations§

§

impl<D, E> Freeze for Delta<D, E>
where D: Freeze, E: Freeze,

§

impl<D, E> RefUnwindSafe for Delta<D, E>

§

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>
where D: Unpin, E: Unpin,

§

impl<D, E> UnwindSafe for Delta<D, E>
where D: UnwindSafe, E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.