You can make music with code using JavaScript — right now, in your browser — with a tool called Strudel. No DAW, no MIDI controller, no acoustic guitar required. Just type sound("hh") and you've already got a high hat looping on a cycle. From there, you can build full beats, add bass lines, shape sine waves, layer filters, and structure entire songs using nothing but JavaScript patterns and a surprisingly elegant mini notation system. If you've ever wanted to combine programming with music production, Strudel is the most approachable on-ramp that actually exists — and this breakdown covers exactly how to use it.
How Do You Make Music with JavaScript Code?
The core idea behind making music with code is that instead of clicking buttons in a DAW or plucking strings, you write expressions that describe patterns. Strudel is a JavaScript-based live coding environment that runs entirely in the browser. It takes those patterns and plays them back in real time, looping them on musical cycles.
The simplest possible sound you can make in Strudel looks like this:
- Type:
sound("hh") - Result: A high hat that loops forever, one hit per cycle.
From that single line, you can scale up to layered drums, melodic bass lines, reverb-drenched chords, and syncopated arrangements — all without ever leaving your text editor. The mental model is simple: Strudel runs on cycles, not an event loop. Think of it like a musical measure that repeats. Everything you write describes what happens inside that cycle.
This is the core insight that makes live coding music feel so natural for programmers: you're just describing a repeating pattern, the same way you'd describe any loop-driven system — except this one outputs sound instead of side effects.
What Is Strudel and How Does Live Coding Music Work?
Strudel is a JavaScript port of TidalCycles, a live coding music environment originally written in Haskell. The JavaScript version runs in the browser with zero installation, which makes it one of the lowest-friction ways to start making music with code that currently exists.
Live coding music means you write and modify code while it's playing. You hit save (or evaluate), the pattern updates, and the music changes in real time. It's closer to improvising on an instrument than it is to producing a track in Ableton — the feedback loop is immediate and the mistakes are part of the performance.
Strudel supports:
- Built-in drum and synth samples
- A mini notation system for rapid pattern writing
- Effects like reverb, delay, and low-pass filters
- Sine wave-based modulation for dynamic sound shaping
- Stacking multiple patterns and scheduling them with ranges
The catch — if you're a terminal-first, Vim-native developer — is that Strudel lives in a browser editor. And if your personality is Vim, typing music patterns into a browser text box feels like betrayal. Which leads us to the real engineering challenge here.
How to Control a Browser with Playwright from Vim
The solution to the "I use Vim and refuse to touch a browser editor" problem is to use Playwright as a bridge. Here's the architecture that actually works:
- Launch a local Bun server that has Playwright running and controlling the Strudel browser tab.
- From inside Vim, run a
curlcommand that sends the current file's contents to that local server. - The server receives the code, uses Playwright to write it into Strudel's editor, and triggers evaluation.
The result: you write Strudel patterns in a .js file inside Vim, hit your save/send keybind, and the music updates in the browser instantly. You never have to touch the browser editor. Your muscle memory stays intact. Your personality remains unchallenged.
This kind of browser automation as a developer productivity tool is underused in general. Playwright isn't just for testing — it's a programmable browser that can act as middleware between your preferred environment and any web-based tool that doesn't have a native API.
Why Build a Custom DSL for Music Programming?
Once you have Vim-to-Strudel working, the next natural move is to abstract away repetition with a custom DSL (domain-specific language). In this context, that means creating a separate file with reusable pattern definitions — bass lines, drum patterns, chord shapes — that you can import into your main composition file.
Instead of rewriting sound("bd sd bd sd") every time you want a kick-snare pattern, you define it once in your DSL file and reference it by name. When you save your main file and push it through to Strudel, all the imports resolve and the full pattern plays.
This is just good software engineering applied to music. Separation of concerns. Don't repeat yourself. The fact that the "code" is music patterns doesn't make the engineering principles any less relevant — if anything, it makes the payoff more satisfying because you can hear the abstraction working.
How Does Strudel Mini Notation Actually Work?
Mini notation is the compact pattern language built into Strudel (inherited from TidalCycles). It lets you describe complex rhythmic patterns in a single string. Here's a breakdown of the key concepts:
Basic Sequencing
Space-separated values inside a string play sequentially within one cycle. So sound("hh hh hh hh") gives you four evenly-spaced high hats per cycle.
Rests
Use a tilde (~) to insert silence. sound("hh ~ hh hh") plays three high hats with a gap on beat two.
Subgrouping
Wrap patterns in square brackets to create subdivisions within a single beat slot. Wrap them in carets to give each subgroup its own full cycle. This is where rhythmic complexity starts to emerge — you can nest patterns inside patterns and get polyrhythmic results without writing any loops.
Stacking
Use the stack() function to layer multiple patterns simultaneously — drums, bass, and melody all running in parallel on the same cycle grid.
The mini notation syntax feels cryptic for about ten minutes and then becomes intuitive. It's the kind of language that rewards experimentation: change one character and hear the result immediately.
How Do You Structure a Full Song with Code?
Here's where live coding music goes from interesting demo to actual composition tool. Strudel supports ranges, which let you schedule when specific patterns play relative to the overall cycle count. This gives you song structure — verses, builds, drops — without manually managing a timeline.
A practical example of how to sequence a song intro:
- Cycles 0–2: Play only the bass line.
- Cycles 2–4: Add the bass drum under the bass line.
- Cycles 4–8: Bring in the high hat on top of both.
This is equivalent to a traditional arrangement where elements are introduced progressively to build energy — except instead of dragging clips on a timeline, you're writing a few lines of JavaScript that describe the same structure declaratively.
From there, you can layer in effects that evolve over time. Low-pass filters that open up. Delay times that modulate based on a sine wave. Reverb tails that push sounds further back in the mix. All of it is code. All of it responds to change instantly. And all of it can be committed to a git repo, which is the most programmer-brained thing about this entire workflow and also completely correct.
Should Programmers Try Live Coding Music?
If you have any history with music — even a decade-old acoustic guitar phase you abandoned when you watched The Social Network and decided programming was the only thing that mattered — live coding music is worth trying. Strudel specifically has one of the lowest barriers to entry of any creative coding tool available right now.
The skills transfer is real. Pattern thinking, abstraction, DSL design, modular composition — these are programming concepts that map directly onto music theory concepts. Rhythm is just a loop. A melody is just a sequence. A song structure is just a scheduler. You already know how to think about this. You just need the right tool to hear it.
Start with sound("hh"). Add a bass drum. Build a DSL. Wire it to Vim. Make something that sounds like Doom and then iterate until it doesn't. The workflow is surprisingly fun — and unlike most side projects, this one makes noise.





