Struct vst::api::Event

source ·
#[repr(C)]
pub struct Event { pub event_type: EventType, pub byte_size: i32, pub delta_frames: i32, pub _flags: i32, pub _reserved: [u8; 16], }
Expand description

A VST event intended to be casted to a corresponding type.

The event types are not all guaranteed to be the same size, so casting between them can be done via mem::transmute() while leveraging pointers, e.g.

// let event: *const Event = ...;
let midi_event: &MidiEvent = unsafe { std::mem::transmute(event) };

Fields§

§event_type: EventType

The type of event. This lets you know which event this object should be casted to.

Example

// let mut event: *mut Event = ...
match unsafe { (*event).event_type } {
    EventType::Midi => {
        let midi_event: &MidiEvent = unsafe {
            std::mem::transmute(event)
        };

        // ...
    }
    EventType::SysEx => {
        let sys_event: &SysExEvent = unsafe {
            std::mem::transmute(event)
        };

        // ...
    }
    // ...
}
§byte_size: i32

Size of this structure; mem::sizeof::<Event>().

§delta_frames: i32

Number of samples into the current processing block that this event occurs on.

E.g. if the block size is 512 and this value is 123, the event will occur on sample samples[123].

§_flags: i32

Generic flags, none defined in VST api yet.

§_reserved: [u8; 16]

The Event type is cast appropriately, so this acts as reserved space.

The actual size of the data may vary as this type is not guaranteed to be the same size as the other event types.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.