Skip to main content

Delta

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 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}
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> 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> 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> IntoEither for T

Source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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