Struct coremidi::EventBuffer [−][src]
pub struct EventBuffer { /* fields omitted */ }
Implementations
Create an empty EventBuffer
for a given Protocol without allocating.
Create an empty EventBuffer
of a given capacity for a given Protocol.
Add a new packet containing the provided timestamp and data. It consumes the instance and returns it modified with the new packet.
See EventBuffer::push for further details.
Example:
use coremidi::{Protocol, Timestamp, EventBuffer};
let buffer = EventBuffer::new(Protocol::Midi20)
.with_packet(0, &[0x40903c00, 0xffff0000]); // Note On for Middle C
assert_eq!(buffer.len(), 1);
assert_eq!(
buffer.iter()
.map(|packet| (packet.timestamp(), packet.data().to_vec()))
.collect::<Vec<(Timestamp, Vec<u32>)>>(),
vec![(0, vec![0x40903c00, 0xffff0000])],
)
Add a new event containing the provided timestamp and data.
According to the official documentation for CoreMIDI, the timestamp represents the time at which the events are to be played, where zero means “now”. The timestamp applies to the first MIDI word in the packet.
An event must not have a timestamp that is smaller than that of a previous event
in the same EventBuffer
Example:
use coremidi::{EventBuffer, Protocol, Timestamp};
let mut buffer = EventBuffer::new(Protocol::Midi20);
buffer.push(0, &[0x40903c00, 0xffff0000]); // Note On for Middle C
assert_eq!(buffer.len(), 1);
assert_eq!(
buffer.iter()
.map(|packet| (packet.timestamp(), packet.data().to_vec()))
.collect::<Vec<(Timestamp, Vec<u32>)>>(),
vec![(0, vec![0x40903c00, 0xffff0000])],
)
Methods from Deref<Target = EventList>
pub fn iter(&self) -> EventListIter<'_>ⓘNotable traits for EventListIter<'a>impl<'a> Iterator for EventListIter<'a> type Item = &'a EventPacket;
pub fn iter(&self) -> EventListIter<'_>ⓘNotable traits for EventListIter<'a>impl<'a> Iterator for EventListIter<'a> type Item = &'a EventPacket;
impl<'a> Iterator for EventListIter<'a> type Item = &'a EventPacket;
Get an iterator for the packets in the list.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for EventBuffer
impl Send for EventBuffer
impl Sync for EventBuffer
impl Unpin for EventBuffer
impl UnwindSafe for EventBuffer
Blanket Implementations
Mutably borrows from an owned value. Read more