MidiEvent

Struct MidiEvent 

Source
pub struct MidiEvent {
    pub sample_offset: u32,
    pub event: MidiEventKind,
}
Expand description

A sample-accurate MIDI event.

The sample_offset field specifies when within the current audio buffer this event should be processed, enabling sample-accurate MIDI timing.

Fields§

§sample_offset: u32

Sample offset within the current buffer (0 = start of buffer).

§event: MidiEventKind

The MIDI event data.

Implementations§

Source§

impl MidiEvent

Source

pub const fn note_on( sample_offset: u32, channel: MidiChannel, pitch: MidiNote, velocity: f32, note_id: NoteId, tuning: f32, length: i32, ) -> Self

Create a new note-on event.

Source

pub const fn note_off( sample_offset: u32, channel: MidiChannel, pitch: MidiNote, velocity: f32, note_id: NoteId, tuning: f32, ) -> Self

Create a new note-off event.

Source

pub const fn poly_pressure( sample_offset: u32, channel: MidiChannel, pitch: MidiNote, pressure: f32, note_id: NoteId, ) -> Self

Create a polyphonic pressure event.

Source

pub const fn control_change( sample_offset: u32, channel: MidiChannel, controller: u8, value: f32, ) -> Self

Create a control change event.

Source

pub const fn pitch_bend( sample_offset: u32, channel: MidiChannel, value: f32, ) -> Self

Create a pitch bend event.

Source

pub const fn channel_pressure( sample_offset: u32, channel: MidiChannel, pressure: f32, ) -> Self

Create a channel pressure event.

Source

pub const fn program_change( sample_offset: u32, channel: MidiChannel, program: u8, ) -> Self

Create a program change event.

Source

pub fn sysex(sample_offset: u32, data: &[u8]) -> Self

Create a SysEx event.

Note: This allocates the SysEx data on the heap. SysEx messages are relatively rare, so the allocation is acceptable.

Source

pub const fn note_expression_value( sample_offset: u32, note_id: NoteId, expression_type: u32, value: f64, ) -> Self

Create a Note Expression value event.

Source

pub const fn note_expression_int( sample_offset: u32, note_id: NoteId, expression_type: u32, value: u64, ) -> Self

Create a Note Expression integer event.

Source

pub fn note_expression_text( sample_offset: u32, note_id: NoteId, expression_type: u32, text: &str, ) -> Self

Create a Note Expression text event.

Note: This is not const because it initializes the fixed-size buffer.

Source

pub fn chord_info( sample_offset: u32, root: i8, bass_note: i8, mask: u16, name: &str, ) -> Self

Create a Chord info event.

Note: This is not const because it initializes the fixed-size buffer.

Source

pub fn scale_info(sample_offset: u32, root: i8, mask: u16, name: &str) -> Self

Create a Scale info event.

Note: This is not const because it initializes the fixed-size buffer.

Trait Implementations§

Source§

impl Clone for MidiEvent

Source§

fn clone(&self) -> MidiEvent

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 Debug for MidiEvent

Source§

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

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

impl Default for MidiEvent

Source§

fn default() -> Self

Creates a default MidiEvent (NoteOff with all fields zeroed).

Used for buffer initialization. Does not allocate.

Source§

impl PartialEq for MidiEvent

Source§

fn eq(&self, other: &MidiEvent) -> 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 StructuralPartialEq for MidiEvent

Auto Trait Implementations§

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