pub struct PatternBlock {Show 14 fields
pub steps: u8,
pub rate: Rate,
pub swing: u8,
pub base_vel: u8,
pub accent_vel: u8,
pub default_gate: u8,
pub mode: Mode,
pub tonic: u8,
pub lanes: [Lane; 8],
pub playing: bool,
pub pending_slot: Option<u8>,
pub switch_quant: SwitchQuant,
pub chain: [ChainEntry; 16],
pub chain_len: u8,
}Expand description
A whole pattern, as the audio thread holds it.
Every field is a plain scalar or an array of them: the type is Copy,
nothing in it points anywhere, and a command carrying one is a memcpy.
Five of the fields — playing, pending_slot, switch_quant, chain
and chain_len — describe the track rather than this pattern. They ride
on the block because a block is how the UI thread says anything to the
audio thread about a sequencer, and PatternPlayer::apply takes the
most recent word on them from whichever slot arrived last. The UI keeps
its own single copy and writes it into every block it sends, which is what
phosphor-app’s single dispatch function exists to guarantee.
Fields§
§steps: u8How many steps play, one of STEP_COUNTS.
Shortening a pattern masks: steps past the end keep their contents and come back when the pattern is lengthened again.
rate: Rate§swing: u8Swing as a percentage, 50 (straight) to 75 (fully triplet).
base_vel: u8Velocity of an ordinary step.
accent_vel: u8Velocity of an accented step.
default_gate: u8The gate a newly enabled step inherits.
mode: ModeThe scale pitch walking and the diatonic chords work in.
tonic: u8Tonic pitch class for mode, 0..=11. Named tonic and not key
because Step::key is a different thing one field away.
lanes: [Lane; 8]§playing: boolWhether this sequencer runs when the transport does.
pending_slot: Option<u8>A slot queued to take over at the next SwitchQuant point.
Queueing the slot that is already playing is not a switch, which is what makes a stale queue on the UI side harmless.
switch_quant: SwitchQuant§chain: [ChainEntry; 16]§chain_len: u8How many entries of chain are real. Zero means no chain, and the
live slot is whatever was last selected or queued.
Implementations§
Source§impl PatternBlock
impl PatternBlock
Sourcepub const SIZE: usize
pub const SIZE: usize
How many bytes one of these is, and therefore what a SetPattern
command costs to sit in the queue.
Sourcepub const MAX_SWING: u8 = 75
pub const MAX_SWING: u8 = 75
Highest swing setting. At 75 the pair is 3:1, which is a triplet feel; past it the second note lands on the following step and the pattern reads as a different rhythm rather than a swung one.
Sourcepub fn step_count(&self) -> usize
pub fn step_count(&self) -> usize
How many steps actually play. Always at least one, never more than
MAX_STEPS — a length out of range would otherwise index off the
end of a lane or divide by zero.
pub fn ticks_per_step(&self) -> i64
Sourcepub fn length_ticks(&self) -> i64
pub fn length_ticks(&self) -> i64
One time through, in ticks.
Sourcepub fn swing_offset(&self, step_index: usize) -> i64
pub fn swing_offset(&self, step_index: usize) -> i64
How far an odd-numbered step is pushed late, in ticks.
MPC-style: the offset is a fraction of two steps, so 75% puts the off-beat three quarters of the way through the pair — a triplet feel — and 50% is straight. Integer arithmetic on purpose: the bounce and the live player run this same expression, so “the bounce swings identically” needs no tolerance at all.
Even step indices are never offset, which is what keeps the downbeat where the transport says it is.
Sourcepub fn onset(&self, origin: i64, index: i64) -> i64
pub fn onset(&self, origin: i64, index: i64) -> i64
The tick step index fires at, counting from origin.
index is a global step number and may run past the end of the
pattern or before its start: index 17 of a 16-step pattern is step 1
of the second time through.
Sourcepub fn step_at(&self, origin: i64, tick: i64) -> usize
pub fn step_at(&self, origin: i64, tick: i64) -> usize
Which step is under tick, counting from origin. Swing is not
applied: this is where the playhead is, not when a note fires.
Sourcepub fn lane_audible(&self, lane: usize) -> bool
pub fn lane_audible(&self, lane: usize) -> bool
Whether a lane sounds, given the pattern’s mute and solo state.
Sourcepub fn chain_entries(&self) -> &[ChainEntry]
pub fn chain_entries(&self) -> &[ChainEntry]
The chain as real entries, ignoring anything past chain_len.
Trait Implementations§
Source§impl Clone for PatternBlock
impl Clone for PatternBlock
Source§fn clone(&self) -> PatternBlock
fn clone(&self) -> PatternBlock
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more