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: u32Sample offset within the current buffer (0 = start of buffer).
event: MidiEventKindThe MIDI event data.
Implementations§
Source§impl MidiEvent
impl MidiEvent
Sourcepub const fn note_on(
sample_offset: u32,
channel: MidiChannel,
pitch: MidiNote,
velocity: f32,
note_id: NoteId,
tuning: f32,
length: i32,
) -> Self
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.
Sourcepub const fn note_off(
sample_offset: u32,
channel: MidiChannel,
pitch: MidiNote,
velocity: f32,
note_id: NoteId,
tuning: f32,
) -> Self
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.
Sourcepub const fn poly_pressure(
sample_offset: u32,
channel: MidiChannel,
pitch: MidiNote,
pressure: f32,
note_id: NoteId,
) -> Self
pub const fn poly_pressure( sample_offset: u32, channel: MidiChannel, pitch: MidiNote, pressure: f32, note_id: NoteId, ) -> Self
Create a polyphonic pressure event.
Sourcepub const fn control_change(
sample_offset: u32,
channel: MidiChannel,
controller: u8,
value: f32,
) -> Self
pub const fn control_change( sample_offset: u32, channel: MidiChannel, controller: u8, value: f32, ) -> Self
Create a control change event.
Sourcepub const fn pitch_bend(
sample_offset: u32,
channel: MidiChannel,
value: f32,
) -> Self
pub const fn pitch_bend( sample_offset: u32, channel: MidiChannel, value: f32, ) -> Self
Create a pitch bend event.
Sourcepub const fn channel_pressure(
sample_offset: u32,
channel: MidiChannel,
pressure: f32,
) -> Self
pub const fn channel_pressure( sample_offset: u32, channel: MidiChannel, pressure: f32, ) -> Self
Create a channel pressure event.
Sourcepub const fn program_change(
sample_offset: u32,
channel: MidiChannel,
program: u8,
) -> Self
pub const fn program_change( sample_offset: u32, channel: MidiChannel, program: u8, ) -> Self
Create a program change event.
Sourcepub fn sysex(sample_offset: u32, data: &[u8]) -> Self
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.
Sourcepub const fn note_expression_value(
sample_offset: u32,
note_id: NoteId,
expression_type: u32,
value: f64,
) -> Self
pub const fn note_expression_value( sample_offset: u32, note_id: NoteId, expression_type: u32, value: f64, ) -> Self
Create a Note Expression value event.
Sourcepub const fn note_expression_int(
sample_offset: u32,
note_id: NoteId,
expression_type: u32,
value: u64,
) -> Self
pub const fn note_expression_int( sample_offset: u32, note_id: NoteId, expression_type: u32, value: u64, ) -> Self
Create a Note Expression integer event.
Sourcepub fn note_expression_text(
sample_offset: u32,
note_id: NoteId,
expression_type: u32,
text: &str,
) -> Self
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.