Step 06 of 11
Visuals
Piano rolls, scopes and colours that draw your music while it plays.
- 6.1 What you can see
- 6.2 Inline visuals
- 6.3 Full-screen piano roll
- 6.4 Full-screen oscilloscope
- 6.5 Options and tips
6.1What you can see
Strudel can draw what you play: notes as a piano roll, the sound wave, the frequencies, and more. This helps you understand a pattern, find mistakes, and gives the audience something to watch when you perform. Add a visual to the end of any pattern. Every visual comes in two forms:
| Form | Example | Where it's drawn |
|---|---|---|
| With an underscore | ._pianoroll() | A small display right under that line of code. You can use as many as you like, one per line. |
| Without | .pianoroll() | Across the whole editor background, behind your code. Use one at a time: background visuals share one canvas and draw over each other. |
| Visual | Shows | Best for |
|---|---|---|
pianoroll | Notes as bars scrolling past: up = higher, right = later. The line in the middle is "now". | Melodies, basslines, chords |
punchcard | Like a piano roll, but only the rows actually used | Drum patterns |
scope | The sound wave itself (oscilloscope) | Seeing a waveform or filter change |
spectrum | Frequencies from bass to treble, like an equalizer | Filters, brightness, mixing |
pitchwheel | Notes on a circle of the 12 pitches | Chords and scales: you see their shape |
spiral | The cycle as a spiral, with notes along it | Rhythms and loops, and it looks good on stage |
wordfall | Note and sound names falling down the screen | Background only (no _ version) |
6.2Inline visuals, one per line
setcpm(100/4)
// melody as a piano roll
$: n("0 2 4 [6 5] 4 2 1 0").scale("C4:minor").s("piano")._pianoroll()
// drums as a punchcard
$: s("bd*4, ~ cp ~ cp, [~ oh]*4, hh*8").bank("RolandTR909").gain(.6)._punchcard()
// the sawtooth wave of a bass, changing as the filter opens and closes
$: note("<a1 f1 c2 g1>*8").s("sawtooth").lpf(sine.range(300, 2000).slow(4))._scope()
// the chords on the pitch wheel
$: chord("<Am F C G>").voicing().s("gm_epiano1").gain(.6)._pitchwheel()
The sound plays here; the visuals show in the full editor. Open in Strudel ↗
Each display appears under its own line while the music plays. Scroll the editor to see them all.
setcpm(100/4)
// watch the bright part of the spectrum grow as the filter opens
$: note("a2*8").s("sawtooth").lpf(saw.range(200, 5000).slow(4)).gain(.5)._spectrum()
// a melody drawn as a spiral
$: n("0 2 4 7").scale("A4:minor").s("gm_vibraphone")._spiral()
The sound plays here; the visuals show in the full editor. Open in Strudel ↗
6.3A full-screen piano roll with colored layers
Give each layer its own color with .color("…"). Then all(x => x.pianoroll()) draws every layer at once behind the code. labels: 1 writes the note names on the bars. The colors also appear in the code highlighting, so you can see which line is which.
setcpm(124/4)
$: s("bd*4, ~ cp ~ cp").bank("RolandTR909").color("white")
$: note("<a1 f1 c2 g1>").struct("x ~ x x ~ x x ~").s("sawtooth").lpf(600).color("orange")
$: chord("<Am7 F^7 C^7 G7>").struct("[~ x]*2").voicing().s("gm_epiano1").color("cyan")
$: n("0 [~ 2] 4 [3 2]".add("<0 -2 2 -1>")).scale("A4:minor").s("triangle").color("magenta")
// one piano roll for every layer, with note names
all(x => x.pianoroll({ labels: 1 }))
The sound plays here; the visuals show in the full editor. Open in Strudel ↗
6.4A full-screen oscilloscope
setcpm(124/4)
note("<a1 f1 c2 g1>*8").s("sawtooth").lpf(sine.range(300, 2000).slow(4))
.scope({ color: "cyan", thickness: 2, scale: .5 })
The sound plays here; the visuals show in the full editor. Open in Strudel ↗
6.5Options
| Visual | Options (inside { }) | Example |
|---|---|---|
pianoroll, punchcard | labels note names · cycles bars shown (default 4) · vertical scroll top to bottom · playhead where "now" is (0–1) · smear notes leave a trail | .pianoroll({ labels: 1, cycles: 8 }) |
scope | color · thickness line width · scale height of the wave · pos vertical position (0 = top, 1 = bottom) | .scope({ color: "lime", pos: .5 }) |
spiral | size · thickness · stretch turns per cycle · playheadColor | .spiral({ size: 200, thickness: 6 }) |
| Any layer | .color("…"), a color name or #hex, used by piano roll, punchcard and highlighting | .color("#ff3388") |
Tips
- To add visuals to a whole track (like the Night Bus song or the hardcore track), put
.color()on each layer and addall(x => x.pianoroll())at the end. pianoroll,punchcard,pitchwheelandspiraldraw the pattern.scopeandspectrumanalyse the sound that Strudel plays.- Visuals use computer power. If the sound starts to stutter, remove a few.
Tested with Strudel 1.3. Course text: CC BY-SA 4.0, code: CC0 1.0 (licences).