Skip to main content

EventSink

Trait EventSink 

Source
pub trait EventSink {
    // Required method
    fn accept(&mut self, event: PatternEvent) -> bool;
}
Expand description

Somewhere for generated events to go.

The whole point of the trait is that there is one generator behind both consumers: the audio thread writes straight into the track’s plugin queue, converting ticks to sample offsets as they arrive and refusing to grow it, and the bounce writes into a Vec that cannot overflow. Generic rather than dyn, so each call site compiles to the same code it would if the sink were named directly.

Events arrive in no particular tick order. Both consumers sort by tick or by sample offset with a stable sort, which is what carries the one ordering rule that matters: a note-off pushed before a note-on at the same tick stays before it, and so a switch boundary cannot cut the note it just started.

Required Methods§

Source

fn accept(&mut self, event: PatternEvent) -> bool

Returns whether the event was taken. false means the sink is full, and the generator stops rather than dropping events silently in the middle of a step.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl EventSink for Vec<PatternEvent>

Source§

fn accept(&mut self, event: PatternEvent) -> bool

Implementors§