Skip to main content

PatternPlayer

Struct PatternPlayer 

Source
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

Source

pub fn new() -> Self

Source

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.

Source

pub fn slot(&self, index: usize) -> &PatternBlock

Source

pub fn live_slot(&self) -> u8

Source

pub fn queued_slot(&self) -> Option<u8>

Source

pub fn current_step(&self) -> u8

The step the playhead was over on the last callback. What the UI draws its marker at.

Source

pub fn is_playing(&self) -> bool

Source

pub fn held_notes(&self) -> usize

Source

pub fn silence(&mut self)

Forget every held note without sounding an off. For a panic, where the instruments are reset underneath us.

Source

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.

Source

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

Source§

fn clone(&self) -> PatternPlayer

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for PatternPlayer

Source§

impl Debug for PatternPlayer

Source§

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

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

impl Default for PatternPlayer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more