May this site count your visit with Google Analytics? It sets cookies and is used only for visit statistics. Privacy →

Step 06 of 11

Visuals

Piano rolls, scopes and colours that draw your music while it plays.

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:

FormExampleWhere 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.
VisualShowsBest for
pianorollNotes as bars scrolling past: up = higher, right = later. The line in the middle is "now".Melodies, basslines, chords
punchcardLike a piano roll, but only the rows actually usedDrum patterns
scopeThe sound wave itself (oscilloscope)Seeing a waveform or filter change
spectrumFrequencies from bass to treble, like an equalizerFilters, brightness, mixing
pitchwheelNotes on a circle of the 12 pitchesChords and scales: you see their shape
spiralThe cycle as a spiral, with notes along itRhythms and loops, and it looks good on stage
wordfallNote and sound names falling down the screenBackground only (no _ version)

6.2Inline visuals, one per line

Strudel · inline visualsOpen in Strudel ↗
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.

Strudel · spectrum & spiralOpen in Strudel ↗
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.

Strudel · colored piano rollOpen in Strudel ↗
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

Strudel · background scopeOpen in Strudel ↗
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

VisualOptions (inside { })Example
pianoroll, punchcardlabels 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 })
scopecolor · thickness line width · scale height of the wave · pos vertical position (0 = top, 1 = bottom).scope({ color: "lime", pos: .5 })
spiralsize · 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 add all(x => x.pianoroll()) at the end.
  • pianoroll, punchcard, pitchwheel and spiral draw the pattern. scope and spectrum analyse 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).