No project description provided
Project description
PyCodeDJ
日本語版 README はこちら · Full Manual (EN) · マニュアル (JA)
A live-coding environment that translates Python code structure into music in real time. Every save changes the performance.
Concept
PyCodeDJ connects "writing code" directly to "making sound."
Add more functions and the polyphony widens. Deepen nesting and the filter opens up. Fill in comments and the space grows. The structure of your code is the instrument.
Two things set it apart from existing Python ↔ SuperCollider bridges (sc3nb, supriya):
- Hot-reload performance — swap out a loop without stopping it. Saving a file becomes an immediate sound change.
- Audible code structure — structural features extracted via AST analysis (depth, branch count, function count, etc.) are automatically mapped to musical parameters.
Architecture
[Python engine] →OSC→ [SuperCollider] →audio out→ speakers
↓ OSC
[Hydra etc.] →video out→ screen
| Layer | Role | Technology |
|---|---|---|
| Control | Code analysis, scheduling, OSC dispatch | Python 3.10+, python-osc, watchdog |
| Audio | Real-time sound synthesis | SuperCollider (scsynth) |
| Visual | Music-synced visuals | Hydra or Pyxel |
BPM clock is held by SuperCollider's TempoClock. Python only sends parameter updates over OSC; timing accuracy is delegated to SuperCollider.
Code Structure → Music Parameter Mapping
| Code feature | Music parameter | Musical rationale |
|---|---|---|
| Max nesting depth | Filter Cutoff (200–4000 Hz) | Deep structure = complexity = brightness |
| Control-flow count (if/for/while) | LFO rate (0.1–5.0 Hz) | More branches = faster modulation |
| Function definition count | Polyphony voice count (1–4) | Functions = independent voices |
| Comment ratio | Reverb depth (0.0–0.8) | More whitespace = more space |
Tempo (BPM) and root pitch are controlled explicitly by the performer, to prevent the foundation of the piece from shifting on every save.
Installation
Requirements
- Python 3.10 or later
- SuperCollider (with scsynth available)
pip install 'pycodedj[watch]'
The [watch] extra enables the pycodedj watch command.
Development install:
git clone https://github.com/yourname/pycodedj
cd pycodedj
pip install -e ".[dev]"
Quick Start
1. Boot SuperCollider and load the synths
Open sc/synths.scd in the SuperCollider IDE and evaluate it.
2. Write a live-coding file
# @loop bass interval=2.0
def bass():
for i in range(8):
if i % 2 == 0:
pass
# @loop melody interval=0.5
def melody():
x = 1
y = 2
return x + y
# @loop pad interval=4.0
def pad():
# make space
# a little more
pass
3. Evaluate a block
pycodedj eval demo.py::bass
On success, feedback is printed immediately:
[pycodedj] bass cutoff=418Hz lfo=1.08Hz reverb=0.00 voices=1
Other loops keep playing without interruption.
4. Live-code with watch mode
Instead of running eval manually, use watch to re-evaluate all loops on every save:
pycodedj watch demo.py
From here, just write code and save.
Note on
interval(current MVP): Values likeinterval=2.0are parsed and stored, but are not yet sent over OSC. Loop repeat timing is managed by SuperCollider'sTempoClock. A mechanism to pass interval to SC is planned for a future release.
Example Files
| File | Contents |
|---|---|
examples/demo.py |
Intro demo with bass / melody / pad |
examples/club_set.py |
Club-style demo: sub_bass / hat_engine / neon_stab / acid_lead / warehouse_air |
Live-Coding Examples
Deeper nesting opens the filter
# @loop bass interval=2.0
def bass():
for i in range(4): # control flow +1
for j in range(4): # depth +1, control flow +1
if i == j: # depth +1, control flow +1
pass
More functions = more polyphony
# @loop chord interval=1.0
def voice_a(): pass
def voice_b(): pass
def voice_c(): pass
def voice_d(): pass
More comments = more space (reverb)
# @loop pad interval=4.0
# leave space here
# a little more
# silence is music
def pad(): pass
OSC Address Reference
Addresses used to communicate with SuperCollider.
| Address | Type | Range | Parameter |
|---|---|---|---|
/pycodedj/loop/<name>/cutoff |
float | 200–4000 Hz | Filter Cutoff |
/pycodedj/loop/<name>/lfo_rate |
float | 0.1–5.0 Hz | LFO rate |
/pycodedj/loop/<name>/reverb |
float | 0.0–0.8 | Reverb depth |
/pycodedj/loop/<name>/voice_count |
int | 1–4 | Polyphony voice count |
<name> is the loop name (e.g. bass, melody). Each loop has its own address namespace, so multiple loops never overwrite each other's parameters.
External visualisers such as Hydra can receive the same parameters on a separate port.
Requirements
- Recommended OS: macOS (low-latency Core Audio) or Linux (Raspberry Pi 5, etc.)
- Python: 3.10 or later
- SuperCollider: 3.12 or later
Roadmap
- Spec design and mapping design
- Phase 0: Listening validation of mapping hypotheses
- Phase 1: Python → SuperCollider OSC prototype
- Phase 2: Hot-reload live loop implementation (
pycodedj watch) - Phase 3: Hydra visualiser integration
License
MIT + Commons Clause — free to use, modify, and perform (including paid live performances). Selling or commercially distributing the software itself is not permitted. See LICENSE for details.
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 pycodedj-0.1.4.tar.gz.
File metadata
- Download URL: pycodedj-0.1.4.tar.gz
- Upload date:
- Size: 40.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3def92c9a4360c8ee05565b11ab1f096977773aecfc8c1015211b638dcd36d8f
|
|
| MD5 |
65bebdac809640785157dc69b09b491c
|
|
| BLAKE2b-256 |
7ac68ca932900783525b2c7c7447963fd3730ccdf1b4cba68f0ee3d16d37c218
|
Provenance
The following attestation bundles were made for pycodedj-0.1.4.tar.gz:
Publisher:
workflow.yml on kanekoyuichi/pycodedj
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycodedj-0.1.4.tar.gz -
Subject digest:
3def92c9a4360c8ee05565b11ab1f096977773aecfc8c1015211b638dcd36d8f - Sigstore transparency entry: 1461967601
- Sigstore integration time:
-
Permalink:
kanekoyuichi/pycodedj@aab539ba469a897d86c9212335bd4dd5dcdf6f5a -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/kanekoyuichi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@aab539ba469a897d86c9212335bd4dd5dcdf6f5a -
Trigger Event:
release
-
Statement type:
File details
Details for the file pycodedj-0.1.4-py3-none-any.whl.
File metadata
- Download URL: pycodedj-0.1.4-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
348c266772d667aa41d2ed3f0c50d0e431484d8f3505622bd6bf454b568ea6f7
|
|
| MD5 |
c87bad320b1551fd23e0540e2dcf3750
|
|
| BLAKE2b-256 |
74f354689edfa801f2c554eae40da6a2b034b3e80029d3160768eb97dfd2be29
|
Provenance
The following attestation bundles were made for pycodedj-0.1.4-py3-none-any.whl:
Publisher:
workflow.yml on kanekoyuichi/pycodedj
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycodedj-0.1.4-py3-none-any.whl -
Subject digest:
348c266772d667aa41d2ed3f0c50d0e431484d8f3505622bd6bf454b568ea6f7 - Sigstore transparency entry: 1461967622
- Sigstore integration time:
-
Permalink:
kanekoyuichi/pycodedj@aab539ba469a897d86c9212335bd4dd5dcdf6f5a -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/kanekoyuichi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@aab539ba469a897d86c9212335bd4dd5dcdf6f5a -
Trigger Event:
release
-
Statement type: