Live-coding music with Strudel
The Strudel Editor at /tools/StrudelEditor reproduces the strudel.cc player: pick a pattern,
edit the code, and press the play button above the editor.
- The button reads Stop while the pattern plays, and Update once the code has been edited since it started; Update, like Ctrl+Enter, swaps the playing pattern and its visuals for the edited code. Code that fails to run stops playback rather than leave the old pattern going, and loading another pattern stops the one playing.
- The code is saved to the browser's local storage as you type, so a refresh or a later visit opens where you left off. An address naming a pattern opens that pattern instead, and picking one replaces the saved code.
- The editor loads the same sounds strudel.cc does: dirt-samples, the piano, the VCSL
instruments, the tidal drum machines with their short names (
.bank("TR909")), the uzu drum kit and wavetables, mridangam, and the General MIDI soundfonts (gm_piano,gm_acoustic_bassand the rest), so code copied from strudel.cc plays unchanged. They load on the first Play, or earlier when the sounds tab or the flow canvas opens. Where two banks share a name, dirt-samples wins:bd,sd,hhand six more are the dirt kit, not the uzu drum kit, so the shipped examples sound as written.
A panel opens on the hints tab, followed by seven of the strudel.cc tabs, an import tab and the flow tab:
- hints: what the pattern is missing for its style (below)
- welcome: intro and about
- patterns: your saved patterns, then the examples, then the songs:
original songs in several hint styles, with a second stoner rock and grunge song. Those songs are
Dust and Diesel and Sun Bleached (stoner rock), Rust and Rain and Paper Skies (grunge),
Uptown Strut (funk), Late Fusion (jazz funk), and Acid Doom (psytrance doom). They are written
as
$:layers with a.maskholding one number a bar, so each layer can be read, muted or rearranged on its own, and the hints tab finds nothing missing in them. Each is a link that puts it in the address, so/tools/StrudelEditor?pattern=dust-and-dieselopens on Dust and Diesel, Back returns to the pattern before, and a pattern can open in a new tab. The name field at the top saves the code in the editor under that name, in local storage; a save is linked like the rest, as?pattern=saved-<name>, saving under a name already used replaces it, and its cross deletes it. How each style is written is in Writing a song in a Strudel style. - sounds: every sound the editor can play, filtered as on strudel.cc into samples, drum
machines, synths (soundfonts included) and wavetables, and grouped by where it comes from:
each sample bank, each drum machine, the General MIDI families from pianos to sound effects.
Each sound shows a readable name ("Bass drum", "Acoustic bass") with the name code plays it
by in grey beside it (
rolandtr909_bd,gm_acoustic_bass); search matches either, or the group. Clicking a sound plays it once; the number is how many variationsnpicks from. - import: turn an MP3, other audio, a MIDI file, a tab or a piano score image into a pattern (below)
- midi: play or drive MIDI devices (below)
- export: save the code as a WAV or MIDI file (below)
- console: evaluation log
- compose: write, revise or review the code with an AI model (below)
- settings: theme, panel position, and the OpenRouter key and models the AI features use
- functions: search every documented Strudel function and add it as a node (below)

The open tab is in the address too, so /tools/StrudelEditor?tab=midi opens on the midi tab
and ?tab=flow opens the flow canvas. The two combine: ?pattern=dust-and-diesel&tab=export opens
Dust and Diesel with the export tab ready, which is how scripts/strudel-export.mjs and the render API
reach it. Opening and closing a tab from the toolbar replaces the address rather than adding to Back,
which steps through the patterns picked. The Instrument tab is compact by default, as a game shows it: the fretboard, the calibration notes and the input. ?advanced=1 opens the whole tab with the note log, export, import and delay, for example strudel.cnotv.xyz/?tab=instrument&advanced=1. The editor mode is there as well: flow is ?mode=flow,
and code, the default, has no key, so ?pattern=dust-and-diesel&mode=flow opens that pattern on the canvas. Links from before the query, such as #dust-and-diesel or
#export, still open what they named and are rewritten to the query form.
Audio starts on the first Play press or the first click on a pattern, since browsers only allow
sound after a user gesture. Clicking an example, a song or a saved pattern plays it at once from
its start and replaces whatever was playing; opening a link to one, or moving with Back, only
loads it. iOS is stricter: audio has to start inside the tap itself, and the engine download that follows
outlasts it. So strudelPlayback.ts creates and resumes the page's one AudioContext before
anything downloads, hands it to Strudel, and resumes it again on every Play or Update. It also
asks for iOS's playback audio session, so an iPhone plays with the ring switch on silent.
Patterns run on the Strudel engine (@strudel/core, @strudel/mini, @strudel/transpiler,
@strudel/webaudio, @strudel/tonal, @strudel/draw, @strudel/midi), loaded lazily so the rest of the app
never pays for it. Press the stop button to hush the output; leaving the view stops it too. A
pattern that fails to evaluate shows its error under the editor instead of playing.
Hints
The hints tab names the pattern's style and goes through the code in three groups, each hint saying why it matters and showing the code it changes:
- Review what is there: layers to mute or visuals to remove, so the hints don't only ever add.
- Missing for the style: the tempo, instruments and visuals it is usually built with.
- Keep going: variations to take a finished pattern further.
Each hint's button (Add, Mute or Remove) makes the change. The list follows the code as you type.

The style comes from the first of these that names one, and the tab says which:
- the Style picker at the top of the tab;
- the comment on the code's first line, such as
// deep house grooveor// my first dnb tune; - a guess from the code, which needs a tempo inside the style's range and the instruments that define it: a kick for most; a snare too for drum and bass, hip hop, grunge and death metal (a kick, a snare and chords); a bass too for dub and synthwave; bass and chords for stoner rock; chords, melody and bass for classical and jazz; bass, chords and percussion for funk; chords for ambient; and a sampled break for breakbeat.
Most songs are none of these, so a guitar riff at 120 BPM gets no style rather than the nearest one, and the tab asks you to name or pick it.
There are fifteen styles: techno, house, drum and bass, hip hop, ambient, trance, dub,
breakbeat, synthwave, stoner rock, grunge, death metal, classical, funk and jazz. Each has a usual tempo
range, the instruments it is built from, and the visuals that
suit it. The table is STRUDEL_MUSIC_STYLES in the editor's config.ts, and nothing is sent
anywhere.
| Hint | When it shows | What its button does |
|---|---|---|
| Review | a line draws more than one visual | removes all but the first, which would otherwise draw over each other |
a $: block plays only instruments the style isn't built with | mutes it as _$:, which keeps it in the code; delete the _ to bring it back | |
a $: block plays only parts an earlier layer already plays | mutes it the same way | |
| Tempo | no setcps or setcpm, or one outside the style's range | setcps(<bpm>/60/4), replacing the tempo set or under the header comments |
| Instrument | none of the code's sounds or calls plays that part | a new $: block with the layer |
| Visual | the style suits it, and a layer it fits draws nothing yet | ._punchcard() or similar, chained onto that layer |
| Keep going | a layer it suits doesn't have it yet; three at a time | .mask("<1 1 1 0>") or similar, chained onto that layer |
Each visual goes on the layer it suits: a punchcard on the drums, a pianoroll on the melody or
chords, a scope on the bass. A layer that already draws something is never offered a second
visual, so no two draw over each other. The ideas are a breakdown every fourth bar, a filter
sweep, a phrase turned round, drum fills, swing, stereo spread and an echo; their table is
STRUDEL_PATTERN_IDEAS. To keep a version you like, save it in the patterns tab and build a
variation on a copy.
The filter sweep moves once per note, so a busy line sweeps smoothly and a held note steps, and
it is not offered on a sine, which has nothing for a filter to remove. The stereo spread is not
offered on a clap, since reversing ~ cp ~ cp moves it off the backbeat in one ear.
Instruments are read from sound names in strings (bd is a kick, hh a hi-hat, jvbass a bass),
from notes (octave 2 and below is bass, above is melody), and from calls (chord and voicing
are chords, scale a melody), in the patterns and in the const parts a song stacks together.
Words in comments name the style but never an instrument, so // bass and hats counts as
neither. A muted block counts as nothing.
Strudel plays only the $: blocks once any exists, so the first instrument added to a plain
pattern turns that pattern into a block too, and both keep playing. Only $: blocks can be muted
on their own, so a single plain pattern is never reviewed. Every snippet uses only the sounds the
editor loads and Strudel's built-in synths, and each style's snippets share a key and are
balanced to play together without clipping: the reasoning is in
Balancing the Strudel hints.
The timeline
A timeline runs along the bottom of the left side, under the code editor or the flow canvas. It shows where the pattern is in the song: the cycle, the step inside the cycle and the time in seconds. Its playhead follows the sound while the pattern plays.

- Play and Pause play from the picked time and, while the pattern plays, pause it. A pause stops the sound where it is and makes that the picked time, so the next Play carries on from there.
- Stop (the square button, or Ctrl+. anywhere in the editor, in flow mode too) stops the sound and rewinds to cycle 1. The same stop sits above the editor.
- Loop (the repeat toggle) is on by default and plays on past the end of the song. Off plays from the picked time to the end of the song once, then stops and rewinds.
- Click or drag anywhere on the timeline row, not only on its line, to pick a time. While the pattern plays it carries on from there; while it is stopped, the next Play starts there. The arrow keys move it once the playhead has focus.
- On a touch screen a swipe across the timeline scrolls it and leaves the playhead where it is. A tap picks the time under your finger, and a touch on the playhead line, or just beside it, drags it.
- One row for the whole song: every cycle is marked with a line and every step with a shorter tick, drawn behind the playhead. A cycle is at least 48 pixels wide, so a song longer than the window scrolls sideways. A faded edge shows there is more of the song that way. The timeline never scrolls on its own: the playhead, a thin coloured line, can run off the visible part while you look elsewhere in the song.
- Left aligned without the lanes: while Show instrument cycles is off the timeline always starts at the left edge, whichever progression is picked. Centring needs the lanes: the Centred progression only takes effect once they are shown.
- The readout shows three values, each behind an icon with a tooltip: the cycle (
3/8), the step (2/4) and the time (5.1s). A step is one beat: the flow patch sets how many a cycle holds, and code mode uses 4. One bar is one cycle, and the seconds come from the tempo the code sets. - The song length is measured each time the pattern plays or updates: the shortest number of
whole cycles after which every instrument comes round together. Instruments of different
lengths only line up at their least common multiple, so a 3 bar bass under a 4 bar lead gives
12, and an
arrangegives its total. A pattern with a layer that never repeats, such as one built onrand, runs to the cap of 64 cycles so every variation stays reachable. The Export tab shares the same 64 cycle cap and fills its cycle count from it. - Code and flow mode share one position: both play the same compiled code through one scheduler, so switching mode keeps the playhead where it is.
The code editor
The editor fills the left side of the screen at full height and scrolls on its own; the
tabs sit on the right. On a phone they stack, editor first. It is
strudel.cc's own CodeMirror setup from @strudel/codemirror, so code written there works
here unchanged:
- Ctrl+Enter (or Alt+Enter) plays the code, Ctrl+. stops it.
slider(value, min, max, step)draws a slider in the code. Dragging it rewrites the number and changes the sound while it plays.minandmaxdefault to 0 and 1.._pianoroll(),._scope(),._punchcard(),._spiral(),._pitchwheel()and._spectrum()draw under the line the call is on..pianoroll()and.scope(), without the underscore, draw behind the code.- Deleting an underscore call removes its drawing and the space under its line at once. Every visual the code no longer calls stops and is cleared when the code next runs, with Ctrl+Enter or Play, and on Stop.
- The notes that are playing are boxed in the mini-notation as they sound.
- Autocomplete lists the options as you type, and resting the pointer on a function's name shows its documentation, both described below.

The Sliders and scopes example shows all of them at once.
Five more examples show one visual each: Punchcard drums, Spiral, Pitch wheel,
Spectrum and Pianoroll behind the code. Each passes the visual a colour through
.color(), and each is a starting point for a visual of your own. Two more come from strudel.cc's
visual feedback guide:
- Punchcard vs pianoroll:
._punchcard()draws what everything chained after it does, so a later.color()shows, while._pianoroll()draws the pattern as it stood at the call. - Scope: the guide's
s("sawtooth")._scope(), then a second scope sized with itsthicknessandscaleoptions. A scope ignores acoloroption and reads the pattern's.color().

The spiral, the pitch wheel and the spectrum size their drawing in canvas pixels, which is Strudel's own behaviour. They look smaller on a high-density screen than on a standard one.
The flow editor
The Code and Flow switch above the editor changes what fills the left side. Choosing Flow also opens the flow tab in the player panel; choosing Code puts the code editor back. The player tabs keep working in either mode, so hints, patterns and settings stay one click away. The panel button beside the switch hides the player panel when the graph needs the width; the same button brings it back.
Flow replaces typing with a small graph, after Strudel Flow by xyflow, the makers of React Flow: its node set, controls, radial menu and look follow theirs. Add a node from the palette or with the + button in the canvas; the + and a right-click both open the radial menu, split into Instruments, Effects and Sounds. A bar over the canvas sets the tempo in BPM and the beats in one cycle (B/C).
The Functions drawer, open in code mode and flow mode alike, lists every documented Strudel
function except setup and internals, searchable by name, synonym or description. Groups are
collapsed until opened or searched, and each shows its count. Start here at the top holds the functions that make a sound on their own (s, sound, note) and the ones that combine patterns (stack, arrange, cat, seq). A combiner takes the nodes cabled into it as its arguments, so cable several patterns in and it writes stack(a, b). Every function links to its page in
the Strudel docs. Add puts a generic function node on the canvas holding only that call, with a
knob, switch or field for each documented argument; nothing from the examples is added around it.
Connect it to a pattern and it chains as .name(...); left alone it starts a pattern as
name(...). Reset patch removes every node.


| Node | Kind | What it plays |
|---|---|---|
| Pad | instrument | an eight-note grid, arpeggio or chord mode, key, scale and octave |
| Beats | instrument | up to eight drum tracks of any sample on up to sixteen steps |
| Chords | instrument | a chord progression with preset shapes and editable notes |
| Notes | instrument | a note("…") or chord("…") line in mini notation, drawn as a tab, sheet or names |
| Samples | instrument | an s("…") line edited as steps, rests, groups and layers |
| Code | instrument | any Strudel expression, for what the controls do not cover |
| Filter | effect | lpf and lpq |
| Delay | effect | delay, delaytime and delayfeedback |
| Space | effect | room, roomsize, roomfade, roomlp and roomdim |
| Gain | effect | gain |
| Level | effect | pan and postgain |
| Mask | effect | mask: which steps or cycles play |
| Struct | effect | struct: which steps hit, as switches |
| Slow | effect | slow: how many times longer a cycle lasts, as a knob |
| Voicing | effect | voicing: spreads chord symbols into played notes |
| Envelope | effect | attack, decay, sustain and release |
| Visualizer | effect | a pianoroll, punchcard, scope, spiral, pitch wheel or spectrum, picked from a list |
| Effect | effect | one chained call no other node covers, such as .jux(rev) |
| Voice | sound | the synth or sample bank, written as sound("…") |
A Notes node draws its notes so they read as music. Auto picks the notation from the sound the notes play: a bass sound gets a four string bass tab, a guitar a six string guitar tab, a piano, keys or organ sheet music on a treble and a bass staff, and any other sound a list of note names with their lengths. Piano roll is there to pick by hand. The Notation picker on the node overrides it, one node at a time, and its Auto entry says what it chose. While a notation is drawn the mini notation text is hidden; the Mini notation switch on the node shows it under the drawing, for editing, and the node remembers the switch. Picking Mini notation as the notation shows the text alone. A tab places each note on the string that moves the hand least from the last one, within 24 frets, and draws the rhythm under the staff the way the tab import reads it, so a tab screenshot imported and shown again looks like the page it came from. A staff wider than the node scrolls inside it. Why it works this way is in Drawing a Notes node as a tab.
| Bass tab | Guitar tab |
|---|---|
![]() | ![]() |
| Piano sheet | Piano roll |
|---|---|
![]() | ![]() |
| Note names |
|---|
![]() |
The Beats node has a sample picker on each track, grouped into kicks, snares, hi-hats, claps,
toms, cymbals and percussion from the loaded kit. Its Shape footer sets how many steps play,
how many tracks there are, and whether the variation picker shows under each step: *2 repeats a
hit within its step, !2 repeats the step, @2 stretches it and /2 plays it every other cycle.
Each track is written as a plain sample line, such as s("~ cp ~ cp*2"), so typing a line like
that reads back as a Beats track too. Below the shortlist, each track's picker also lists every
other sample and drum machine in the library, grouped and named as in the sounds tab.
The Samples node shows its line as numbered step tiles rather than mini notation; the steps share
one cycle, left to right. A sample tile has the sample's picker, with its instrument icon, and a
plays list whose icon shows what it does: once, faster (2 to 8 hits in its step), repeat over
several steps, last several steps, slower (every 2nd or 4th cycle), sometimes, or a spread rhythm
such as 3 hits over 8. A rest tile shows a pause icon; picking a sample on it fills that step. A
group tile holds its own steps, and its two icon buttons choose Fit in one step ([…]) or
One per cycle (<…>). Under each row the plus picker adds a sample, the pause button a rest
and the bracket button a group; Add layer adds a row that plays alongside, written after a
comma, and each layer can be removed from its label. Anything the controls cannot show, such as a
{…}%4 polymeter, stays as a text step. The Mini notation switch shows the whole line as text
under the steps, for editing by hand.

On a desktop pointer every sample picker, on a Beats track or a Samples step, opens a panel with a search field, the instrument families down the side (kicks, snares, hi-hats, claps, toms, cymbals, percussion, bass, keys, guitar and strings, voices, effects and other), and a grid of samples each with its family's icon and the kit it comes from. Typing narrows the grid across names, codes and kits; Enter picks the first match. A touch screen keeps the native list.

All of Strudel's visuals live in one Visualizer node: the visual itself, a list to pick its
type, and a toggle for whether it draws under the line (._punchcard()) or behind the
code (.punchcard()). Any visual call in the code, with or without the underscore, reads back as
a Visualizer with that type picked, and options such as { labels: 1 } written in the code are
kept. While the pattern plays the node draws the visual live: under the line it sits in the node,
and behind the code it fills the node's full width and height behind its controls, showing the
canvas every background visual shares. A visual only draws the pattern, so calls chained after it go on
an Effect node of their own rather than onto the Visualizer.
A sample line followed by .gain(.5).mask("<1 1 1 0>") reads as three nodes: the instrument, a
Gain node and a Mask node. A mask always gets its own node, whatever its argument: a plain
run of ones and zeros shows as switches, and anything else, such as "<1!40 0!8>" or a constant
named in the setup, is edited as text.
A call with no dedicated node, such as .sometimesBy(.2, x => x.ply(2)) or
.jux(rev), gets an Effect node of its own, wired after the node it follows in the code. No
other node holds calls: to chain one more, add an Effect node from the radial menu and wire it in.
Common ones get controls: a
step per cycle to switch on and off for struct, a knob for the chance of
sometimesBy, someCyclesBy and degradeBy, the amount and subdivision of swingBy, and knobs
for fast, slow, ply, late, early, velocity, speed, crush, shape and hpf. Any
other call, or one whose argument the controls cannot show (a pattern where a number goes), is
written as .name(argument) to edit in place. So is a dedicated call whose argument is a signal
or a slider, such as .lpf(sine.range(300, 3000)). Remove a call with its cross.
Each node header has a … menu with View code, which shows what the node writes, Go to
code, which switches to the code editor with the node's call selected, and Remove. An instrument also has a speaker button that mutes it with .hush(); muting every
instrument of a group writes the whole block as _$:. Drag a node by its header to arrange the
canvas. Connect an output dot to an input by dragging, or click the output and then the input.
Delete or Backspace removes a selected node and its cables. Every cable has a disconnect button on
its middle, faint until the cable is hovered or selected, which removes that cable alone. An instrument has no input, a pair of
nodes connects only once, an effect cannot feed an instrument, and a cable cannot close a loop.
Each connected group of nodes compiles to one $: <pattern> block. An instrument passes only
through the effects downstream of it: effects every instrument of the group shares are chained
once after a stack(...), and an effect only one instrument reaches stays on that instrument's
branch inside the stack. The tempo bar writes setcpm(<bpm>/<beats per cycle>) above the blocks.
A patch with no instrument, or one whose instrument makes no sound yet, says what to fix instead
of writing code.
The code is the source of truth, and the graph always shows it:
- Typing rebuilds the graph each time the code pauses on something that parses as JavaScript; while it has a syntax error the graph keeps its last good state.
- Every chained call has a place. Calls with a dedicated node get it, any other call gets an
Effect node of its own with its arguments kept verbatim, and a
stack(...)splits into its instruments. A flat sample line of up to sixteen steps, such ass("bd ~ [bd,cp] ~"), becomes Beats tracks; a richer one, with sub-sequences or euclidean rhythms, becomes a Samples node, andnote("…")becomes Notes.chord("…")becomes a Notes node too, drawn as chord names or mini notation. A line that plays a constant, such asnote(riff)orchord(drone), becomes the same node with the constant's notes written out: a string,silence, another constant, or anarrange(...)of those, unrolled one bar per cycle as<…>. A value built any other way, such as a song's ownplan(...)function, keeps the line a Code node. A head nothing reads, such asn(run(8)), becomes a Code node. - Statements that are not patterns, such as
samples('…')orconst cc = await midin('…'), are kept as setup lines and written back above the blocks. Without any$:block, the last expression is the pattern, as in Strudel. - Editing the canvas writes the compiled code into the editor and re-plays it if it is playing. Opening Flow never rewrites the code by itself.
The graph is also saved in local storage, so node positions survive a visit. Reset patch loads the starter Pad into Voice into Filter at 120 BPM.
Autocomplete
Typing in the editor lists what can come next, and Ctrl+Space opens the list anywhere. Up and down move through it, Enter writes the selected option, and Escape closes it. The list is narrow and tall, so the documentation beside it has room to be up to 800px wide. It drops under the list when the screen has no room beside it.

| Where the cursor is | What it offers |
|---|---|
a name, or straight after a . | every documented function and its synonyms, with its documentation |
inside s("…") or sound("…") | the sounds the engine has loaded |
inside .bank("…") | the banks among those sounds, such as RolandTR808 |
inside chord("…") | a root, then Strudel's chord symbols after it, such as ^7 and -7 |
inside .scale("…") | a root, then a scale name after the colon, written minor:pentatonic |
| a comment, or any other mini-notation | nothing |
Sounds load with the engine, so s("…") offers names only after the first Play.
Resting the pointer on a function's name in the code shows the same documentation in a tooltip,
whether it is written as a call, such as note(, or chained, such as .lpf(, and under any of
its synonyms. Names in comments and strings show nothing. A touch screen has no pointer to rest,
so on a phone the documentation shows only beside the completion list.

The documentation comes from Strudel itself. codeEditor/strudelDocumentation.json is generated from
the JSDoc comments in the installed @strudel/* and superdough sources, the same comments
strudel.cc builds its reference from. codeEditor/strudelDocumentation.test.ts regenerates it and fails
when it differs from the committed file, so upgrading a Strudel package without regenerating
fails the unit tests. To regenerate it:
pnpm vitest run src/views/Tools/StrudelEditor/codeEditor/strudelDocumentation.test.ts -u
Turning an MP3 into a pattern
Open the import tab and drop an audio file on it, or click to browse. Anything the browser can decode works: MP3, WAV, OGG, M4A, FLAC. The file never leaves the browser. It is decoded to mono, analysed in a Web Worker, and summarised as a tempo, a bar count and a chord progression, with the generated code folded under Code; open it to read it. The tab's own help sits under Turn music into Strudel code at the top and Read suggestions at the bottom, folded until you open them. Press Load to replace the editor's code with it and play it.

The generated pattern stacks up to three layers, leaving out any the audio did not have:
| Layer | Heard as | Played with |
|---|---|---|
| Drums | kick, snare and hi-hat on a sixteenth-note grid | the dirt-samples kit |
| Bass | the strongest note between 40 and 250 Hz at each onset | a filtered sawtooth |
| Chords | one major or minor triad per bar, or a rest when none matches | voicing() on triangle |
Bars that repeat collapse into the shortest loop, so a four-bar progression in a three-minute song comes out as four bars. Only the first 90 seconds, at most 64 bars, are analysed.
Treat the result as a sketch in the spirit of the track, not a copy. The melody is not transcribed, chords richer than a triad are reduced to one, and a dense mix confuses the drum classifier. Edit the code from there. How the analysis works and where it fails is in Transcribing audio into a pattern. Why the editor is assembled from parts rather than strudel.cc's ready-made one is in Embedding the strudel.cc editor.
Turning a MIDI file into a pattern
Drop a .mid file on the same import tab. Notes are read straight from the file instead of
heard, so the result is exact rather than a sketch:
| Layer | Read as |
|---|---|
| Drums | General MIDI percussion keys on the drum channel, folded to kick, snare and hi-hat |
| Bass | the lowest note that starts on each sixteenth step |
| Chords | the major or minor triad closest to every note held across the bar |
The tempo is the file's first tempo, and notes are placed by their ticks, so a tempo change inside the file never shifts them off the grid. Up to 64 bars are read. Load replaces the code, as with audio.
Turning a tab screenshot into a pattern
Drop a PNG, JPEG or WebP of a bass or guitar tab on the same import tab. The picture is read in a Web Worker with plain image processing, no model, and the file never leaves the browser. A staff of four lines is read as a bass and one of six as a guitar.
| Read | From |
|---|---|
| Notes | the fret numbers on each string line, named from the open strings |
| Lengths | the stems and beams under the staff, and a bracket for triplets |
| Ties | a stem with no number above it |
| Bars | the bar lines, so each bar is one cycle of the pattern |
It works best on a clean digital screenshot, dark or light, with the rhythm row visible. The
tempo comes from a marker such as "= 96" above the first staff; with none, or one it cannot
read, the code starts at 120 BPM and you change the number in setcps. A mark it cannot read, such as a slide sign, is skipped and listed in the console tab.
How it works and where it stops is in
Reading a tab screenshot without a model.
Turning a piano score into a pattern
Drop a PNG, JPEG or WebP of piano music in standard notation on the same import tab: a grand staff, a treble staff over a bass staff joined by bar lines. Five line staves taken in pairs are read as a score, anything else as a tab, so there is nothing to choose. As with a tab, the picture is read in a Web Worker with plain image processing and never leaves the browser.

| Read | From |
|---|---|
| Clef, key, metre | the start of each staff: the clef, the run of sharps or flats, C or digits |
| Pitch | each note head's line or space, with the key and any accidental in its bar |
| Lengths | filled or hollow heads, the beams or flags on the stem, dots, rests |
| Chords and voices | heads struck at the same moment, on one stem or on two |
| Tempo | a marker such as "quarter note = 65" above the first staff |
The code sets the tempo with one bar per cycle and writes the right hand and the left hand as two
$: blocks on gm_piano, so they play together. An opening pickup bar is filled with a rest in
front of its notes. Every bar is checked against the metre, and a bar that does not add up is
named in the console tab, as are bars where it skipped a mark it could not read.
It reads a clean digital engraving. Ties are played as a repeated note, grace notes, ornaments, dynamics, pedal marks and words are skipped, and a clef or metre change part way through, triplets and photographed or handwritten music are not read. On the sample it was built against, all fifteen left hand bars and ten of the fifteen right hand bars add up to the metre, and the first six bars match the printed notes; the right hand bars that do not are passages with two voices on one staff or a grace note. How it works and where it stops is in Reading a piano score without a model.
Several tabs and scores in one song
Drop several tab or score images at once, or one after another, and each becomes part of one song. A tab is one instrument; a piano score is two, its right hand and its left hand. The import tab lists the files in the order they arrived, named bass, guitar, then bass 2 for a second bass, or right hand and left hand for a score, each with a Remove button. An audio or MIDI file still stands alone and replaces the list.

The song plays at the first file's tempo, with one bar per cycle in the first file's metre. Each
instrument is its own $: block, so Strudel plays them together, and the flow view shows a Notes
node with its Voice for each one. Three kinds of warning go to the console tab and fold under a
count, such as 2 warnings, below the list:
- a file marked with another tempo, which still plays at the first one;
- a score counting another number of beats to the bar. Each bar fills one cycle, so a waltz in a song of four beats plays slower than marked;
- two files whose bar counts do not divide each other. Each block loops on its own, so a 20 bar bass and an 8 bar guitar line up again only every 40 bars. Nothing is padded or cut.
Load replaces the code, as before. Add keeps the code that is there
and appends the instruments as blocks, without a second tempo. Code that plays a single
unlabelled expression, such as one tab loaded on its own, gets $: in front of that expression
first, because Strudel stops playing it as soon as any labelled block appears.
A pianoroll under each instrument
The Draw a pianoroll per instrument box above the list is ticked by default. While it is
ticked, every instrument block a tab or score import
writes ends with ._pianoroll() on its own line, so each one draws its notes under its code as it
plays, and the flow view gains a Visualizer node on each instrument. A block that only rests stays
silence, with nothing to draw. Unticked, the code is exactly what the import wrote before, and
one file on its own writes exactly its single import code either way. The audio and MIDI import is
left alone: it writes one stack(...) of drums, bass and chords, where a pianoroll would draw the
drums too.
Instruments
The editor ships physically modelled instruments, built in your browser, so no audio files are downloaded. An instrument is a preset: a name, a kind and the kind's five knobs. A preset registers one sound per articulation, spelt <preset>_<articulation>, so one song can mix several presets.
$: note('a1 a1 c2 ds2').s('chainsaw_chord').cut(1)
$: s('blastkit_kick*4').clip(1)
| Kind | Articulations | Knobs |
|---|---|---|
| Electric guitar | chord (root, fifth, octave), mute (palm muted chord), note | drive, tone, bass, mids, sustain |
| Bass guitar | note, mute | drive, tone, attack, mids, sustain |
| Acoustic guitar | chord (strummed), mute, note | body, brightness, sustain, strum speed, width |
| Organ | note | body, brightness, percussion, drive, vibrato |
| Drum kit | kick, snare, tomhi, tommid, tomlow, hatclosed, hatopen, ride, crash | tune, decay, punch, drive, room |
A pitched articulation takes the note you give; electric guitar and acoustic chords play it as the root. Guitars are sampled down to a1 for drop A, the bass down to a0. Drums are unpitched, so they take no note. Every knob runs 0 to 1, and drive near 0 gives a clean guitar.
Each pitched preset is also one combined sound named after the preset, so a tab line or a melody plays it with the plain name: note("e2 g2 a2").s("chainsaw") plays single notes. A technique is picked by name, and the Synth tab lists the names of the selected preset: s("chainsaw:mute") is a palm mute and s("chainsaw:chord") a power chord on a guitar, :mute a muted note on a bass, and an organ has only the plain sound. The plain name is the single note, which :note also spells out. A number still works as the sample index, and a word that is no technique plays the single note. A drum kit has no combined sound, only its pieces. The _chord, _mute and _note names stay, and stay the right choice when a song fixes one technique for a whole part. Notes imported from a tab want the plain name, since _chord turns every note into a three-note power chord.
Eleven presets ship built in, so the example songs sound the same for everyone: stoner, seattle (a grunge fuzz), jangle (clean to crunch), chainsaw (death metal), fuzzbass, grungebass, deathbass, campfire (acoustic), doomorgan, garagekit (a roomy kit) and blastkit (a tight, clicky one).
The Synth tab selects a preset and shows the sliders of its kind. The tab shows one example for the selected preset: complete Strudel code that sets its own tempo with setcpm and plays one bar with $: lines, using the preset's combined sound and its techniques. Copy puts exactly that text on the clipboard, and pasting it into the editor sounds the same as the preview. The play button renders that same text offline and plays it; it turns into a stop button while it renders and plays. Download WAV saves the same render as <preset>-preview.wav, without rendering it again. Tweaks to a built-in preset are kept in this browser and Reset restores the shipped values. Duplicate makes a copy; Create makes a new preset of any kind; a preset you made can be renamed and deleted. Built-in presets cannot be renamed or deleted.
In flow mode every preset is in the pickers, rendered or not: a guitar, bass, acoustic or organ preset under the Voice node, as "Electric guitar: chainsaw" and so on, each listing the combined sound first, then "chainsaw palm mute" and "chainsaw power chord" as chainsaw:mute and chainsaw:chord, filed under its family (guitars under Guitar and strings), and a drum kit's pieces under the Samples and Beats pickers. So notes imported from a tab can be played on a preset by picking it on the Voice node they feed. A preset renders the first time it is previewed or played, which takes a second or two.

A name is lowercase letters and digits, starts with a letter, is at most 16 characters, is not used by another preset and does not collide with a sound Strudel already has (sawtooth, or the front of a drum machine such as rolandtr909). The tab says what to change.
A preset renders when it is selected, and as soon as code naming one of its sounds is loaded, typed or pasted, so Play does not wait for it. If Play comes first, the pattern waits for the render to finish. Nothing else is rendered, so an unused preset costs nothing. Moving a slider renders only that preset again, after a short pause. A preset's sounds appear in the Sounds tab under Kind: name once it has rendered. Deleting or renaming a preset does not unregister sounds already made; they go at the next reload.
The AI tone section turns a description such as "dry desert fuzz, scooped mids" into slider settings for the selected kind through OpenRouter. It uses the key and the Sound model set in the Settings tab (see AI settings); the assistant only moves the sliders, so you can still adjust them.
Exporting and importing presets as a file is not offered; presets live in this browser's local storage.
Why it is built this way, and how it was measured: Stoner guitar and Instrument kinds.
Composing with AI
The Compose tab sends a request in your own words, together with the code in the editor, to a model on OpenRouter. Three buttons say what to do with it:
- Compose writes a new piece from the request.
- Revise rewrites the code in the editor as the request asks, keeping what it does not mention.
- Review comments on the code and suggests changes, without writing any.
When the code in the editor fails to run, the tab shows the error and a Fix error button, which sends the code and the error back to the model to repair, keeping the music as it is. The answer is applied like any other.
The answer shows in the tab: for Compose and Revise the code, and under a collapsed Report the model's explanation. Apply puts that code in the editor, replacing what was there; Ctrl+Z in the editor brings the old code back. Apply stays available, so the answer can be put back after you edit the code. The tab's own hints sit under a collapsed About composing. With Auto apply ticked, the code goes into the editor as soon as it arrives. A pattern that is playing picks up the new code as it would after typing. Revise and Review need code in the editor; all three need a key.
The model is told how a song is written here: pattern strings in double quotes (a single-quoted string is plain JavaScript, so '<Am F>'.rootNotes(2) fails), the tempo with setcpm, one $: block per layer with its own sound, a chord plan written once as a const, sections with arrange, and the names of the instrument presets it can play. A request that runs while the drawer shows another tab still lands, and is still applied with Auto apply on.
Instruments the composer designs
Compose and Revise can design up to four new instrument presets for the piece, when an existing sound would not suit it. The Report then lists each one under the explanation: its name, its kind (electric guitar, bass guitar, acoustic guitar, organ or drum kit) and a sentence describing the sound. The code plays them like any preset, as <name>, <name>:mute and <name>:chord, or <name>_kick and the other pieces for a drum kit.
Nothing is made until the code is applied. Applying first creates each instrument as one of your own presets in the Synth tab, and asks the Sound model to turn its description into the kind's five knobs, the same as the Synth tab's AI tone; only then does the code go into the editor, so it never plays a preset that does not exist yet. Each row shows how that went:
- Ready: the preset exists with the knobs the Sound model chose.
- Already exists, kept as it is: a preset of that name was there before, built in or your own, and it is never overwritten; the code plays it as it is.
- Not made, with the reason: the name cannot be a preset name, for example because Strudel already has a sound called that. If only the Sound model failed, the preset is kept at its kind's starting knobs.
Untick Instruments (hover for its meaning) to keep the composer to the sounds and presets that already exist: it is then told to design none, and nothing is created on Apply. It is ticked until you untick it, and the choice is remembered in this browser.
Designed presets stay after the piece is replaced, saved and editable like any preset you made yourself, and can be renamed or deleted in the Synth tab.
AI settings
The AI section of the Settings tab holds what every AI feature shares:
- your OpenRouter key, kept only in this browser's local storage and sent only to OpenRouter. Forget key removes it. A key entered in the Synth tab before the AI section existed is still found;
- the Compose model, used by the Compose tab, Claude Sonnet 5.5 by default;
- the Sound model, used by the Synth tab's AI tone and for the instruments the composer designs, Claude Haiku 5.5 by default.
Both dropdowns list every OpenRouter model that answers in strict JSON. Type in the filter above them to narrow the list by name or id.
MIDI devices

On the midi tab, Connect MIDI devices asks the browser for Web MIDI access and lists the inputs and outputs it finds, following devices as they are plugged in. Three snippets load straight into the editor, already naming the first device found:
- Play a keyboard:
midikeysplays an input's notes through a Strudel synth while a pattern runs. - Turn knobs:
midinreads an input's control changes into a running pattern. - Drive a synth:
.midi("<output>")sends the pattern's notes to an output instead of the browser.
Exporting a WAV or MIDI file
The export tab saves the code on screen as a file. Choose the format, the cycle to start at
and how many cycles to export. Cycles fills itself in with the length of the whole song: the
fewest cycles after which every pattern has finished, every section of an arrange included, so
Stoner riff exports all sixteen bars and a one-bar sound such as Coin exports one cycle. The tab
measures when it opens and again shortly after the code changes, but never while the music
plays, since measuring evaluates the code and would stop it; it waits until you press Stop. A
count you type stays until the tab is closed. A song that does not repeat within
STRUDEL_MAX_SONG_CYCLES (64) cycles, such as one built on rand, keeps the count it has.
A pattern can also repeat inside a cycle, as Coin does with fast(2), so One repetition sets
the length to a single play of it, which can be a fraction of a cycle: Coin then exports as one
coin, half a cycle long. The file name defaults to the date. Playback stops while it renders, and Play works
again as soon as the file is saved.

| Format | Holds | Pick it for |
|---|---|---|
| WAV | the sound, exactly as it plays | a sound effect, a loop or a track to play as it is |
| MIDI | the notes and their timing | a melody to edit in a DAW, play on a synth or feed a game |
WAV renders offline, faster than real time, as a 16-bit stereo file at the chosen sample rate.
Why the editor renders through its own path rather than Strudel's renderPatternAudio is in
Strudel's published builds and their audio clocks.
MIDI is built from the same events the WAV would play: one track per sound, at the pattern's
tempo with four beats to a cycle. Pitched events keep their note, n with a scale, or
freq; drum samples with a General MIDI equivalent (bd, sd, hh, oh, cp and the rest of
STRUDEL_DRUM_MIDI_NOTES in config.ts) land on the drum channel. Other samples carry no note
and are left out, and no effect reaches a MIDI file.
scripts/strudel-export.mjs does the same from the command line, against a running dev server,
in a muted headless browser:
node scripts/strudel-export.mjs groove.strudel --out groove.wav --cycles 8
node scripts/strudel-export.mjs groove.strudel --out groove.mid --url http://localhost:5317
The format follows the extension; --start, --cycles and --rate set the range and the WAV
sample rate, and --once exports one repetition instead of a cycle count.
The flow editor follows Strudel Flow by xyflow, whose source is on GitHub under AGPL-3.0. The canvas, the flow tab and the welcome tab each link back to it.
The electro tunes are ported from strudel.cc repl tunes by Felix Roos under CC BY-NC-SA 4.0. The eight style songs were written for this editor.
The Strudel engine is AGPL-3.0-or-later while this repo is MIT, so a deployed build of this
view carries that obligation. The dependency stays isolated to
src/views/Tools/StrudelEditor/ for that reason.




