Step sequencer

class Beat(pz.App): pattern = ["x...x...x...x...", "....x.......x...", "x.x.x.x.x.x.x.x."] step = 0
def view(self): return ui.audio.StepSequencer( pattern=self.pattern, labels=["Kick", "Snare", "Hat"], current=self.step, on_change=lambda e: setattr(self, "pattern", e.value), )Patterns
Section titled “Patterns”pattern is a list of rows. Each row is either a list (True/False, or a velocity from 0
to 1 that sets how bright the step is) or text where x (or 1) is a step that plays and any
other character is a rest: "x...x...x...x..." is a kick on every beat.
change gives the whole new pattern as a list of lists, ready to store. A drag starting on an
empty step paints steps on; one starting on a lit step erases.
Playhead
Section titled “Playhead”current is the step being played: the sequencer frames that column and outlines its steps.
Drive it from a timer (pz.every) or from the engine’s sequencer (node.state["step"]). Steps
are shaded in groups of group (4 by default), so beats are easy to count.
| Property | Default | What it does |
|---|---|---|
pattern |
() |
Rows of steps. |
labels |
() |
A name per row (shown on the left). |
current |
-1 |
The step being played (-1 for none). |
color |
"accent" |
Color of the steps that play. |
group |
4 |
Steps per shaded group. |
cell |
22 |
Size of a step in pixels. |
Event: on_change with the new pattern.