MIDIEventList

Struct MIDIEventList 

Source
#[repr(C)]
pub struct MIDIEventList { pub protocol: MIDIProtocolID, pub numPackets: u32, pub packet: [MIDIEventPacket; 1], }
Available on crate feature MIDIServices only.
Expand description

A variable-length list of MIDIEventPackets.

The timestamps in the list must be in ascending order.

Note that the packets in the list, while defined as an array, may not be accessed as an array, since they are variable-length. To iterate through the packets in an event list, use a loop such as:

MIDIEventPacket *packet =
&packetList
->packet[0];
for (unsigned i = 0; i
<
packetList->numPackets; ++i) {
...
packet = MIDIEventPacketNext(packet);
}

WARNING: When using MIDIEventList in C++ be aware of the following:

MIDIEventList is a variable-length struct and should ALWAYS be passed-by-pointer rather than passed-by-reference. Conversion from a MIDIEventList reference to a pointer is undefined behavior and can lead to the unintended truncation of data.

Field: protocol The MIDI protocol variant of the events in the list. Field: numPackets The number of MIDIEventPacket structs in the list. Field: packet An open-ended array of variable-length MIDIEventPacket structs.

See also Apple’s documentation

Fields§

§protocol: MIDIProtocolID§numPackets: u32§packet: [MIDIEventPacket; 1]

Implementations§

Source§

impl MIDIEventList

Source

pub unsafe fn for_each_event( evtlist: *const MIDIEventList, visitor: MIDIEventVisitor, visitor_context: *mut c_void, )

Available on crate feature MIDIMessages only.

Parses UMPs from a MIDIEventList.

MIDIEventListForEachEvent iterates over all UMPs in the provided MIDIEventList. It parses each UMP and fills a MIDIUniversalMessage struct. It calls the provided visitor on each of these UMPs. In case of an unknown UMP the raw UMP words will be provided.

Parameter evtlist: The MIDIEventList which is to be parsed.

Parameter visitor: The visitor that is called on each UMP in evtlist.

Parameter visitorContext: A context for the visitor that is passed to it when being called.

§Safety
  • evtlist must be a valid pointer.
  • visitor must be implemented correctly.
  • visitor_context must be a valid pointer.
Source§

impl MIDIEventList

Source

pub unsafe fn init( evtlist: NonNull<MIDIEventList>, protocol: MIDIProtocolID, ) -> NonNull<MIDIEventPacket>

Prepares a MIDIEventList to be built up dynamically.

Parameter evtlist: The event list to be initialized.

Returns: A pointer to the first MIDIEventPacket in the event list.

§Safety

evtlist must be a valid pointer.

Source

pub unsafe fn add( evtlist: NonNull<MIDIEventList>, list_size: c_ulong, cur_packet: NonNull<MIDIEventPacket>, time: MIDITimeStamp, word_count: c_ulong, words: NonNull<u32>, ) -> NonNull<MIDIEventPacket>

Adds a MIDI event to a MIDIEventList.

Parameter evtlist: The event list to which the event is to be added.

Parameter listSize: The capacity, in bytes, of the event list.

Parameter curPacket: A packet pointer returned by a previous call to MIDIEventListInit or MIDIEventListAdd for this packet list.

Parameter time: The new event’s time.

Parameter wordCount: The number of valid MIDI 32-bit words which follow, in data.

Parameter words: The new event. May be a single MIDI event, or a partial sys-ex event. Running status is not permitted.

Returns: Returns null if there was not room in the packet for the event; otherwise returns a packet pointer which should be passed as curPacket in a subsequent call to this function.

The maximum size of a event list is 65536 bytes. Large sysex messages must be sent in smaller event lists.

Note that events must use the same protocol as was passed to MIDIEventListInit().

§Safety
  • evtlist must be a valid pointer.
  • cur_packet must be a valid pointer.
  • words must be a valid pointer.

Trait Implementations§

Source§

impl Clone for MIDIEventList

Source§

fn clone(&self) -> MIDIEventList

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 MIDIEventList

Source§

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

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

impl Encode for MIDIEventList

Available on crate feature objc2 only.
Source§

const ENCODING: Encoding

The Objective-C type-encoding for this type.
Source§

impl PartialEq for MIDIEventList

Source§

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

Available on crate feature objc2 only.
Source§

const ENCODING_REF: Encoding

The Objective-C type-encoding for a reference of this type. Read more
Source§

impl Copy for MIDIEventList

Source§

impl StructuralPartialEq for MIDIEventList

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> EncodeArgument for T
where T: Encode,

Source§

const ENCODING_ARGUMENT: Encoding = T::ENCODING

The Objective-C type-encoding for this type.
Source§

impl<T> EncodeReturn for T
where T: Encode,

Source§

const ENCODING_RETURN: Encoding = T::ENCODING

The Objective-C type-encoding for this type.
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.
Source§

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