v0.7.0 — now on PyPI

Code is
the instrument

Write Python. Save the file. Hear it change.
Your code structure becomes music — in real time.

Get started Read manual GitHub
demo.py
SuperCollider output
cutoff
418 Hz
lfo rate
1.08 Hz
reverb
0.00
voices
1 voice
sample music
recorded with PyCodeDJ
0:00

Save a file. Change the music.

PyCodeDJ analyses the AST of your Python code and maps structural features to audio parameters — no music theory required.

Write Python
Any valid Python — functions, loops, comments
AST Analysis
Depth, control-flow count, function count, comment ratio
OSC Bridge
Parameters sent over UDP to SuperCollider
Sound
Real-time synthesis via scsynth
nesting depth
controls
Filter Cutoff
Deeper if/for nesting opens the filter. More structure = brighter sound.
if / for / while count
controls
LFO Rate
More control flow = faster modulation. Complexity becomes movement.
def count
controls
Voice Count
Each function is a voice. Four functions fill a chord.
comment ratio
controls
Reverb Depth
Whitespace becomes space. More comments = deeper reverb.

Up and running in minutes

Python 3.10+, SuperCollider, and one pip command.

terminal
$ pip install 'pycodedj[watch]'

# Evaluate a loop block once
$ pycodedj eval demo.py::bass

# Watch file — auto-reload on save
$ pycodedj watch demo.py
  1. Install SuperCollider Download from supercollider.github.io and boot the server
  2. Load the synths Open sc/synths.scd in the SC IDE → Ctrl+A → Ctrl+Enter. Wait for Ready.
  3. Install PyCodeDJ pip install 'pycodedj[watch]'
  4. Write code, hear sound Run pycodedj watch myfile.py and start editing

Every edit is a performance

Try changing these patterns — each one shifts the sound in a different direction.

# bright + fast cutoff ↑ lfo ↑
from pycodedj import dj, loop

@loop(synth="bass_acid", root="A1", scale="minor", beat=0.25)
def bass():
    dj.volume = 0.4
    dj.eq = "edm"
    dj.low = 1.3
    dj.pattern = "0 . 3 . 5 . 3 ."
# 4-voice chord voices = 4
from pycodedj import dj, loop

@loop(synth="chord_rave", root="A2", scale="minor", beat=0.5)
def chord():
    dj.volume = 0.2
    dj.eq = "classic"
    dj.pattern = "[0 2 4] . [3 5 7] ."
# deep space reverb ↑↑
from pycodedj import dj, loop

@loop(synth="pad_shimmer", root="A2", scale="minor", beat=0.5)
def pad():
    dj.volume = 0.15
    dj.eq = "ambient"
    dj.pattern = "[0 2 4] . . . [5 7 9] . . ."