An experiment to play and learn Strudel with OpenCode.
A minimal, full-screen live coding environment for making music. Built for AI - exposes REST APIs so agents can compose and control music programmatically.
Strudel is a JavaScript port of Tidal Cycles for algorithmic music composition. Write code, make music, in real-time.
// Drums
$: s("bd*4, [~ cp]*2, hh*8").bank("RolandTR909")
// Bass
$: note("<c2 eb2 f2 g2>").s("sawtooth").lpf(400)- OpenCode installed
- Node.js 18+ for the server
1. Start the server
npm install
npm run dev2. Open OpenCode in the project folder
opencode2. Open an AI agent in the project folder
With OpenCode:
opencodeWith Claude Code:
claude3. Ask for any skill
"Teach me Strudel" → /tutorial
"Play me a techno set" → /dj-set
"Compose a synthwave track" → /compose
"Let's make music together" → /interactive
See Skills for AI Agents for more examples.
| Shortcut | Action |
|---|---|
Cmd+Enter |
Play / evaluate code |
Cmd+. |
Stop |
Capture your Strudel output to WAV:
- Start playback - Hit play or
Cmd+Enter - Click the red record button - It pulses and shows duration
- Click again to stop - A preview toast appears
- Listen, then Download or Discard
Recording is independent from playback - stop recording anytime without stopping the music.
The REST API allows AI agents to read and write Strudel code, enabling autonomous music composition. Real-time sync via Server-Sent Events means the browser updates instantly when you push code or trigger playback.
| Endpoint | Method | Description |
|---|---|---|
/api/code |
GET |
Get current code and playing state |
/api/code |
POST |
Push new code { "code": "..." } |
/api/play |
POST |
Start playback |
/api/stop |
POST |
Stop playback |
/api/status |
GET |
Get current state |
/api/events |
GET |
SSE stream for real-time updates |
# Push new code and play
curl -X POST http://localhost:3000/api/code \
-H "Content-Type: application/json" \
-d '{"code": "$: s(\"bd*4, cp*2\").bank(\"RolandTR909\")"}'
curl -X POST http://localhost:3000/api/playsrc/
├── app/
│ ├── api/ # REST API for agents
│ │ ├── code/ # GET/POST code
│ │ ├── events/ # SSE stream
│ │ ├── play/ # POST play
│ │ ├── stop/ # POST stop
│ │ ├── status/ # GET status
│ │ └── state.ts # Shared state + event emitter
│ ├── layout.tsx # Root layout
│ ├── page.tsx # Home page
│ └── globals.css # Styles + CodeMirror theme
├── components/
│ └── strudel-editor.tsx # Main editor
├── hooks/
│ ├── use-strudel.ts # Strudel lifecycle + SSE sync
│ └── use-audio-recorder.ts # Audio recording to WAV
└── lib/
├── constants.ts # Shared constants
├── utils.ts # Utilities
└── wav-encoder.ts # Pure JS WAV encoder
- Next.js
- Tailwind CSS
- Strudel REPL
The AI agent uses the say command for voice feedback. This only works on macOS.
By default, macOS uses basic voices like Daniel or Samantha, but you can enable much better Siri voices that sound way more natural:
- Open System Settings → Accessibility → Spoken Content
(or press
Cmd+Spaceand search "Spoken Content") - Click the ⓘ (info icon) next to System Voice
- In the voice dropdown, search for "Siri"
- Download a Siri voice you like
- Set it as your System Voice - this way all
saycommands use it automatically
Test it in Terminal:
say "Let's make some music"This REPL includes skills that teach AI agents how to make music. The /strudel and /api skills are loaded automatically - the agent already knows the syntax and how to control the app.
Try these:
"Teach me Strudel from the beginning"
"Explain how filters work"
"Show me how to make chord progressions"
"Teach me music theory basics"
"What's the difference between major and minor scales?"
"Play me a 5-minute live techno set"
"Create a deep house journey"
"Do a chill ambient set with voice narration"
"Play an indefinite acid house set until I stop you"
"Compose a 3-minute synthwave track"
"Create a full UK garage song"
"Make a lo-fi hip hop beat"
"Let's make music together"
"Help me create a beat"
"Guide me through making a song"
/visuals- Add visualizations (pianoroll, spiral, oscilloscope)/strudel- Syntax reference (loaded automatically)/api- REPL control (loaded automatically)
MIT - Free to use, copy, modify, and distribute.
Made in Blueberry 🫐
