Skip to content

Strands Strudel: Live Coding Music with AI 🎡

PyPI

Live coding music with real-time WebSocket playback using Strudel patterns.

A Strands Agents tool for algorithmic music composition with a beautiful mobile-friendly player UI.

Features

  • 🎧 Real-time WebSocket streaming - Send patterns to connected players instantly
  • πŸ“± Mobile-friendly player - Glass morphism UI accessible from any device
  • 🎹 13 preset styles - Techno, ambient, DnB, house, acid, lofi, and more
  • πŸ“œ Pattern history - Timeline of all played patterns with one-click replay
  • πŸ”Œ Multi-client support - Broadcast to multiple players simultaneously

Installation

pip install strands-strudel

Quick Start

With Strands Agent

from strands import Agent
from strands_strudel import strudel

agent = Agent(tools=[strudel])

# Start server and open player
agent("Start strudel and open the browser")

# Play a beat
agent("Play a techno beat")

# Custom pattern
agent("Play s('bd*4') with some hi-hats")

Direct Usage

from strands_strudel import strudel

# Start server
strudel(action="start", open_browser=True)

# Play by style
strudel(action="play", style="techno")

# Play custom code
strudel(action="play", code='s("bd sd hh sd")')

# Stop playback
strudel(action="hush")

# Stop server
strudel(action="stop")

Available Styles

Style Description
techno Four-on-the-floor kick with classic drums
ambient Atmospheric pads with reverb and delay
dnb Fast drum and bass patterns (140 BPM feel)
house Classic house groove with bass
acid 303-style acid basslines with filter sweeps
lofi Lo-fi hip hop beats
minimal Sparse minimal techno
breakbeat Syncopated breakbeat patterns
dub Dubby rhythms with heavy delay
trance Uplifting trance with supersaw
jungle Fast jungle/breakcore patterns
chillout Relaxed downtempo vibes
industrial Distorted industrial sounds

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     WebSocket      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Strands Agent  β”‚ ────────────────▢  β”‚  Browser Player β”‚
β”‚                 β”‚    Port 9999       β”‚  (Strudel.js)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                              β”‚
                          HTTP                β”‚
                        Port 10000            β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Mobile / Other Browsers   β”‚
                    β”‚  http://<your-ip>:10000    β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Actions

Action Description
start Start WebSocket + HTTP servers
play Send pattern code or preset style
hush Stop all playback
stop Stop servers
status Show server status
styles List available styles

Strudel Pattern Syntax

Samples

s("bd")           // bass drum
s("sd")           // snare
s("hh")           // hi-hat
s("cp")           // clap
s("bd:0 bd:1")    // sample variations

Synthesizers

note("c4").sound("sine")
note("c4").sound("sawtooth")
note("c4").sound("supersaw")

Mini-Notation

"a b c d"       // sequence
"[a b] c"       // subdivide
"a*4"           // repeat
"a?"            // random

Make music with your AI agent. 🎡