pub struct Step {
pub on: bool,
pub octave: u8,
pub key: u8,
pub chord: u8,
pub voicing: u8,
pub accent: bool,
pub gate: u8,
pub reserved: [u8; 2],
}Expand description
One cell of the grid.
Nine bytes, laid out so that the whole pattern is a plain block of memory
that can be memcpy’d to the audio thread. reserved is room for the two
per-step features that are already designed and not yet built —
probability and ratchets — so that adding them later is not a change to
the size of anything.
Fields§
§on: boolWhether this step fires.
octave: u8Octave part of the pitch: the note is octave * 12 + key. The UI
presents one pitch control; the storage stays split because that is
what a mode-quantised walk needs.
key: u8Pitch class part of the pitch, 0..=11.
chord: u8Which Chord this step plays, by Chord::index.
voicing: u8Which Voicing, by Voicing::index, plus Step::ROOT_BELOW.
accent: boolWhether the step takes the pattern’s accent velocity rather than its base velocity. Per-step numeric velocity is a later change to this same field and needs no migration.
gate: u8Gate length as a percentage of the step, or Step::TIE.
reserved: [u8; 2]Probability and ratchets, when they arrive.
Implementations§
Source§impl Step
impl Step
Sourcepub const TIE: u8 = 255
pub const TIE: u8 = 255
A gate that holds the note until the lane’s next onset.
255 rather than a separate field because a gate is one control: the UI walks it up through the percentages and off the end into the tie, which is where a player expects to find it.
Sourcepub const MIN_GATE: u8 = 5
pub const MIN_GATE: u8 = 5
Shortest gate. Below this the note-off arrives before an envelope has opened and the step is inaudible, which reads as a broken step.
Sourcepub const MAX_GATE: u8 = 200
pub const MAX_GATE: u8 = 200
Longest gate: twice the step, so a step can hold through the next one.
Sourcepub const ROOT_BELOW: u8 = 0b0000_0100
pub const ROOT_BELOW: u8 = 0b0000_0100
Bit in Step::voicing that doubles the root an octave below.
Independent of the voicing rather than four more entries in the list, because it composes with all of them.
pub fn chord_kind(self) -> Chord
pub fn voicing_kind(self) -> Voicing
pub fn root_below(self) -> bool
Sourcepub fn gate_ticks(self, ticks_per_step: i64) -> Option<i64>
pub fn gate_ticks(self, ticks_per_step: i64) -> Option<i64>
How long this step holds, in ticks — or None when it is tied and
only the lane’s next onset ends it.
The gate is clamped here rather than where it is written, so that a value out of range can only ever shorten or lengthen a note rather than produce one with a negative length.