pub struct PatternPlayer { /* private fields */ }Expand description
Everything one sequencer track needs on the audio thread.
The bank lives here rather than on the UI side because a pattern switch has to be decided on the audio thread: the quantization point is a tick, the tick arrives in the middle of a callback, and asking the UI what to play next at that moment would make the answer depend on when the UI thread happened to be scheduled. With all eight slots resident, a switch is an index change and a chain is a lookup.
Around 19 kB per sequencer track, allocated once, when the track’s first
pattern arrives — the same shape as an instrument allocating its voice
array in Plugin::init. Nothing after that reaches the allocator.
Implementations§
Source§impl PatternPlayer
impl PatternPlayer
pub fn new() -> Self
Sourcepub fn apply(&mut self, slot: u8, block: PatternBlock)
pub fn apply(&mut self, slot: u8, block: PatternBlock)
Take a pattern for one slot, and with it the UI’s current word on the track-level settings.
pub fn slot(&self, index: usize) -> &PatternBlock
pub fn live_slot(&self) -> u8
pub fn queued_slot(&self) -> Option<u8>
Sourcepub fn current_step(&self) -> u8
pub fn current_step(&self) -> u8
The step the playhead was over on the last callback. What the UI draws its marker at.
pub fn is_playing(&self) -> bool
pub fn held_notes(&self) -> usize
Sourcepub fn silence(&mut self)
pub fn silence(&mut self)
Forget every held note without sounding an off. For a panic, where the instruments are reset underneath us.
Sourcepub fn countdown(&self, now: i64) -> Option<(u8, i64)>
pub fn countdown(&self, now: i64) -> Option<(u8, i64)>
Where the switch queued on this track will happen, and how many steps
away that is from now. None when nothing is queued.
Pure, and the UI computes the same answer from its own mirror: the countdown on screen is arithmetic, not a message from the audio thread that may or may not have arrived yet.
Sourcepub fn render(
&mut self,
window: &PlaybackWindow,
transport_playing: bool,
out: &mut impl EventSink,
)
pub fn render( &mut self, window: &PlaybackWindow, transport_playing: bool, out: &mut impl EventSink, )
Produce this callback’s events.
transport_playing is the DAW transport; the pattern also has to be
running on its own account. Everything else — which step, which slot,
where the switch lands — comes out of the window’s ticks.
Trait Implementations§
Source§impl Clone for PatternPlayer
impl Clone for PatternPlayer
Source§fn clone(&self) -> PatternPlayer
fn clone(&self) -> PatternPlayer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more