๐ต AI-powered live coding music generation with Strudel patterns
Project description
๐ต strands-strudel
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 on your network
- ๐น 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 the server and open player
agent("Start strudel and open the browser")
# Play a beat
agent("Play a techno beat")
# Create custom pattern
agent("Play s('bd*4') with some hi-hats")
Direct Tool Usage
from strands_strudel import strudel
# Start server and open player in browser
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")
# Check status
strudel(action="status")
# List available styles
strudel(action="styles")
# Stop server
strudel(action="stop")
Actions
| Action | Description |
|---|---|
start |
Start WebSocket + HTTP servers, optionally open browser |
play |
Send pattern code or preset style to connected players |
hush |
Stop all playback |
stop |
Stop servers |
status |
Show server status and connected players |
styles |
List available preset styles |
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 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Configuration
Environment variables:
| Variable | Default | Description |
|---|---|---|
STRUDEL_WS_PORT |
9999 |
WebSocket server port |
STRUDEL_WS_HOST |
0.0.0.0 |
WebSocket bind address |
Strudel Pattern Syntax
Sound Sources
Samples (from dirt-samples):
s("bd") // bass drum
s("sd") // snare drum
s("hh") // hi-hat
s("cp") // clap
s("808") // 808 sounds
s("piano") // piano
s("bd:0 bd:1") // sample variations
Synthesizers (built-in):
note("c4").sound("sine") // sine wave
note("c4").sound("sawtooth") // sawtooth wave
note("c4").sound("triangle") // triangle wave
note("c4").sound("square") // square wave
note("c4").sound("supersaw") // detuned saws
Mini-Notation
"a b c d" // sequence (4 equal parts)
"[a b] c" // subdivide: a and b share one slot
"a*4" // repeat 4 times
"a/2" // play every 2 cycles
"~" // rest/silence
"a?" // 50% chance
"<a b c>" // one per cycle
"a,b,c" // play simultaneously (chord)
"a(3,8)" // Euclidean: 3 hits over 8 steps
Effects
.lpf(1000) // lowpass filter
.hpf(200) // highpass filter
.gain(0.8) // volume
.pan(0.5) // stereo position
.room(0.5) // reverb
.delay(0.5) // delay amount
.distort(2) // distortion
.speed(2) // playback speed
Example Patterns
Basic Beat:
stack(
s("bd*4"),
s("~ sd ~ sd"),
s("hh*8").gain(0.6)
)
Melodic:
n("0 2 4 <5 7>")
.scale("C:minor")
.sound("sawtooth")
.lpf(800)
Ambient:
note("<[c3,e3,g3] [d3,f3,a3]>")
.sound("triangle")
.lpf(sine.range(400, 2000).slow(8))
.room(0.8)
Links
- Strudel REPL - Browser-based live coding
- Strudel Docs - Full documentation
- TidalCycles - The original Haskell version
- Strands Agents - AI agent framework
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file strands_strudel-0.1.0.tar.gz.
File metadata
- Download URL: strands_strudel-0.1.0.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
222ce8d4331bda0e36332a7f0de60613e553a373b97e67ec4ab8ea5fa20b831d
|
|
| MD5 |
e2a9c1935058b4a737b44884617b5797
|
|
| BLAKE2b-256 |
b1f5f17182d1c799418139425f2af1d4a7a23812278a4c2e8f74fea2ab0fcff4
|
File details
Details for the file strands_strudel-0.1.0-py3-none-any.whl.
File metadata
- Download URL: strands_strudel-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c8e338795705764ccc4e145a50fc4bb6ef5017d54844ef2ce7f228ab6f92990
|
|
| MD5 |
69e4e59fa81db8330076ede346115f7b
|
|
| BLAKE2b-256 |
2f2a661f2fff1b4afedee4b80399ca46b55c0c3f3f8ead762e5e7ee1f19501ca
|