Live coding music with AI assistance β powered by Strudel.cc and Bun
Apfelstrudel combines the expressive power of Strudel's live coding environment with an AI agent that can help you create, modify, and understand music patterns in real time.
- π΅ Strudel Integration β Full Strudel.cc live coding environment
- π€ AI Assistant β Chat with an agent that understands music and patterns
- π Real-time Control β Agent can edit patterns, control playback, adjust tempo
- π¨ Dark Theme β Easy on the eyes for those late-night sessions
- β¨οΈ Keyboard Shortcuts β Ctrl+Enter to play, Ctrl+. to stop
- Bun v1.0 or later
- OpenAI API key (or Azure OpenAI credentials)
# Clone the repository
git clone https://github.com/rcarmo/apfelstrudel.git
cd apfelstrudel
# Install backend dependencies
make install
# Vendor frontend dependencies (Preact, HTM, Strudel)
make vendor
# Copy environment template
cp .env.example .env
# Edit .env with your API credentialsCreate a .env file with your LLM credentials:
# OpenAI
OPENAI_API_KEY=sk-...
# Or Azure OpenAI
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
AZURE_OPENAI_KEY=...
AZURE_OPENAI_DEPLOYMENT=gpt-4o-mini
# Optional settings
APFELSTRUDEL_PROVIDER=openai # or "azure"
APFELSTRUDEL_MODEL=gpt-4o-mini
APFELSTRUDEL_MAX_STEPS=16
PORT=3000# Development mode with hot reload
make dev
# Production mode
make startOpen http://localhost:3000 in your browser.
Write Strudel patterns using mini-notation:
// Basic drum pattern
s("bd sd:2 bd bd sd").bank("RolandTR808")
// Melodic pattern
note("c3 e3 g3 b3".fast(2)).sound("sawtooth")
.lpf(800).lpq(5)
// Stacked patterns
stack(
s("bd*4"),
s("~ hh*2"),
note("c2 g2".slow(2)).sound("sawtooth")
)Ask the assistant to help you:
- "Make a chill lo-fi beat"
- "Add some hi-hats to the pattern"
- "Make it faster"
- "Explain what this pattern does"
- "What samples are available?"
| Shortcut | Action |
|---|---|
Ctrl+Enter |
Play pattern |
Ctrl+. |
Stop |
Enter |
Send chat message |
Shift+Enter |
New line in chat |
# Run all checks (lint + typecheck + test)
make check
# Individual commands
make lint # Run biome linter
make format # Format code
make typecheck # TypeScript type checking
make test # Run tests
# Build for production
make build
# Clean build artifacts
make cleanapfelstrudel/
βββ src/
β βββ server/ # Bun HTTP + WebSocket server
β β βββ index.ts # Main server entry
β β βββ websocket.ts # WebSocket handlers
β βββ agent/ # LLM agent implementation
β β βββ runner.ts # Agentic loop
β β βββ llm.ts # LLM client (OpenAI/Azure)
β β βββ system-prompt.ts
β βββ tools/ # Agent tools
β β βββ pattern.ts # get/set/modify pattern
β β βββ transport.ts # play/stop/evaluate
β β βββ tempo.ts # tempo control
β β βββ reference.ts # strudel help & samples
β β βββ todo.ts # task management
β βββ shared/ # Shared types
β βββ types.ts
βββ public/ # Static frontend
β βββ index.html
β βββ styles.css
β βββ app.js
βββ SPEC.md # Detailed specification
βββ Makefile
βββ package.json
The AI assistant has access to these tools:
| Tool | Description |
|---|---|
get_pattern |
Read current pattern code |
set_pattern |
Replace pattern code |
modify_pattern |
Insert code before/after existing pattern |
play_music |
Start playback |
stop_music |
Stop playback |
strudel_evaluate |
Evaluate code without changing editor |
set_tempo |
Adjust BPM |
get_strudel_help |
Query Strudel documentation |
list_samples |
List available samples |
manage_todo |
Track tasks and ideas |
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Browser β
β βββββββββββββββββββββββ ββββββββββββββββββββββββββββββ β
β β Strudel Editor β β Chat Sidebar β β
β β (CodeMirror) β β (WebSocket messages) β β
β βββββββββββββββββββββββ ββββββββββββββββββββββββββββββ β
β β β β
βββββββββββββββΌβββββββββββββββββββββββββΌβββββββββββββββββββββ
β WebSocket β
βΌ βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Bun Server β
β βββββββββββββββββββββββ ββββββββββββββββββββββββββββββ β
β β Static Files β β WebSocket Handler β β
β βββββββββββββββββββββββ ββββββββββββββββββββββββββββββ β
β β β
β βΌ β
β ββββββββββββββββββββββββββββββ β
β β Agent Runner β β
β β (Agentic Loop + Tools) β β
β ββββββββββββββββββββββββββββββ β
β β β
ββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββ
β
βΌ
ββββββββββββββββββ
β OpenAI / Azure β
β LLM API β
ββββββββββββββββββ
Audio samples from the Dirt-Samples library (218 instruments, ~2000 files) are vendored in public/vendor/strudel/samples/dirt/ for offline convenience. These samples were created by the TidalCycles community and are redistributed here temporarily to enable fully offline operation.
Fonts (Inter by Rasmus Andersson, JetBrains Mono by JetBrains) are also vendored locally in public/vendor/fonts/.
If you are packaging or forking this project, please review the upstream licenses for these assets.
AGPL-3.0 β Required by Strudel.cc dependency.
See LICENSE for details.
- Strudel.cc by Felix Roos β The amazing live coding environment
- Dirt-Samples by the TidalCycles community β Audio samples
- Inter by Rasmus Andersson β UI typeface
- JetBrains Mono by JetBrains β Editor typeface
- Bun β Fast JavaScript runtime
- Inspired by rcarmo/steward β Tool harness pattern
Made with π₯§ and π΅
