Create music with AI using natural language. Generate and live code music using Google Gemini and FoxDot, with real-time streaming, AI thinking visualization, and auto-execution in SuperCollider.
- Real-time Streaming - See AI responses stream in character by character
- Thinking Visualization - Watch the AI's reasoning process unfold
- Tool Call Indicators - Live function call execution with code preview
- Music State Panel - Live view of BPM, scale, root, and active layers
- Natural Language Interface - Describe music in plain English
- Genre Understanding - Knows house, techno, lo-fi, hip-hop, ambient, and more
- Intelligent Layering - AI maintains context of what's playing
- Continuous Evolution - Build and modify compositions layer by layer
- Global Environment - Shared FoxDot state like the original working code
- Auto-execution - Code runs immediately in SuperCollider (default ON)
- 50+ Synths - Full knowledge of FoxDot synthesizers
- Effects & Scales - Complete access to FoxDot's musical capabilities
pip install -r requirements.txt# Set environment variable
export GOOGLE_API_KEY="your-api-key-here"
# Or enter it directly in the Streamlit UIGet your API key from Google AI Studio.
Install SuperCollider:
- Download from supercollider.github.io
Start SuperCollider and run:
FoxDot.startWait for: FoxDot Quark ready! message
streamlit run src/ui/app.pyOr use the main.py launcher:
python main.py --uiOpen http://localhost:8501 and start creating music!
foxdot-composer/
โโโ main.py # Entry point (CLI)
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
โโโ .gitignore # Git ignore rules
โ
โโโ src/
โโโ core/ # Core logic
โ โโโ agent.py # Main agent
โ โโโ streaming_agent.py # Streaming support
โ โโโ session.py # Session management
โ โโโ executor.py # FoxDot execution
โ โโโ functions.py # Gemini function declarations
โ โโโ prompts.py # System prompts
โ โโโ knowledge.py # FoxDot knowledge base
โ
โโโ ui/
โโโ app.py # Streamlit UI (main interface)
- Enter your Google API key in the sidebar
- Select your preferred model (gemini-2.5-flash recommended)
- Enable auto-execute (default ON)
- Type natural language requests:
"Create a chill lo-fi beat at 80 BPM"
โ Sets tempo, creates drums and melody
"Add a deep bass line"
โ Adds bass layer while keeping existing music
"Make it more atmospheric"
โ Adds reverb pads, adjusts layers
"Make the drums more complex"
โ Modifies drum pattern with fills
- gemini-2.5-flash - Fast, balanced (recommended)
- gemini-2.5-flash-lite - Faster, lighter
- gemini-2.5-pro - Most capable, slower
The AI uses these functions to control music:
| Function | Description | Example |
|---|---|---|
play_synth |
Melodic layers (melody, bass, chords, pads) | p1 >> pluck([0, 2, 4, 7]) |
play_drums |
Drum/percussion patterns | d1 >> play("x-o-") |
set_tempo |
Change BPM (40-200) | Clock.bpm = 120 |
set_scale |
Musical scale | Scale.default = Scale.minor |
set_root |
Root note (C-B) | Root.default = "C" |
stop_player |
Stop specific layer | p1.stop() |
stop_all |
Stop everything | Clock.clear() |
Melody: pluck, charm, bell, keys, soft, glass, star
Bass: bass, sawbass, dub, jbass, fuzz, growl
Pads: pads, sinepad, space, soft
Drums: Use play() with pattern characters: x=kick, o=snare, -=hihat
- Natural Language Input - You describe music in plain English
- AI Thinking - Gemini reasons about the request (visible in UI)
- Function Calling - AI calls functions to build FoxDot code
- Code Generation - FoxDot Python code is created
- Auto-execution - Code runs in global FoxDot environment
- SuperCollider - Audio is generated in real-time
- Streaming Response - AI explains what it did
The UI updates in real-time showing thinking, tool calls, and responses as they stream in.
| Genre | BPM | Key Elements |
|---|---|---|
| House | 120-130 | Four-on-floor kick, offbeat hats, chord stabs |
| Techno | 125-150 | Driving kick, minimal melody, filter sweeps |
| Lo-Fi | 70-90 | Relaxed feel, bitcrush, room reverb, swing |
| Ambient | 60-90 | Long sustains, heavy reverb, sparse drums |
| Drum & Bass | 160-180 | Breakbeats, heavy sub bass, fast hats |
| Hip-Hop | 85-115 | Boom bap drums, swing, piano/keys |
"SynthDef not found" errors:
- Make sure you ran
FoxDot.startin SuperCollider - Wait for "FoxDot Quark ready!" message
- Restart SuperCollider if needed
No sound:
- Check SuperCollider is running
- Verify
FoxDot.startwas executed - Check audio output settings in SuperCollider
Streamlit errors:
- Make sure you're in the
foxdot-composer/directory - Use:
streamlit run src/ui/app.py
Contributions welcome! Areas of interest:
- Additional genre presets
- More function tools
- UI improvements
- Documentation
MIT โ see LICENSE.
Built with: Google Gemini โข FoxDot โข SuperCollider โข Streamlit
Co-authored-by: Claude (Anthropic)