iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🎛️

Live Coding with Python: Options for TidalCycles/SuperCollider Enthusiasts (Differences and How to Choose)

に公開

The Goal of This Article

For those who are currently using TidalCycles + SuperCollider (SuperDirt), I have compiled the architectural differences and practical options so that you don't get lost when asking:

  • "Can I do similar live coding in Python?"
  • "How are they different? Which one should I choose?"

This is a memo based on my own research into wanting to perform Python live coding.


Summary: Five Main Approaches

Even when saying "doing Tidal-like things in Python," the implementation differs significantly depending on where it takes place.

  1. Using a Python live coding environment (FoxDot, Sardine, etc.)
    → The "start coding in Python from the beginning" route.

  2. Keeping Tidal and using Python as an external controller (sending /ctrl)
    → The "don't throw away Tidal's strength in timing" route (recommended).

  3. Direct OSC transmission from Python to SuperDirt (/dirt/play)
    → The "flexible but difficult timing design" route.

  4. Using Python as a frontend for SuperCollider (scsynth) (Supriya, sc3nb, etc.)
    → The "want to build near the acoustic system" route.

  5. DSP in Python alone (pyo, etc.)
    → The "complete in Python without depending on SuperCollider" route.


Baseline: The Flow of Tidal + SuperDirt (Benchmark for Comparison)

In general, the basics of Tidal are as follows:

What is important here is timing.

  • The trigger from Tidal to SuperDirt is not just a simple OSC message, but is sent as a "bundle (with timestamp)" for look-ahead.
  • In other words, the reason it sounds clean is because of the design where "future events are sent together, and the receiving side lines them up accurately."

The character of each Python proposal changes based on where this "look-ahead scheduling" is handled.


1) Python Live Coding Environments: FoxDot / Sardine

What are the differences?

  • Imagine Python becoming the "pattern language + clock" instead of Tidal.
  • The audio is (in most cases) played on the SuperCollider side.

FoxDot (Python → SuperCollider)

Features:

  • Write in Python and play SuperCollider.
  • It comes with a dedicated IDE, making it the shortest path to the experience of "live coding in Python."

The super basic example from the README:

d1 >> play("x-o-")

Sardine (Python Live Coding Framework)

Features:

  • Treats Python as an instrument while handling SuperCollider (or MIDI/OSC) in the background.
  • Also designed with a strong awareness of "time and tempo."
  • Those who want to code in Python rather than Haskell.
  • Those who want to write algorithms in "Python-like code" (which can be easily linked to data processing/generation).

Points to Note

  • Syntax and practices differ depending on the tool (they are different from Tidal's mini-notation).
  • The long-term maintenance status and vitality of the ecosystem vary by project, so checking the update status before introducing them is recommended.

2) Keeping Tidal and using Python as an external controller (Recommended)

What are the differences?

  • Timing accuracy (look-ahead scheduling) is left to Tidal.
  • Python is dedicated to "creating and sending values" and "handling external logic or UI."

Tidal can receive external input via OSC. By default, it accepts /ctrl at 127.0.0.1:6010, allowing you to use keys and values like variables.

On the Tidal side (using received values)

-- Use an external control (float) named 'hello' for speed
d1 $ sound "bd" # speed (cF 1 "hello")

On the Python side (sending /ctrl)

# pip install python-osc
from pythonosc.udp_client import SimpleUDPClient

client = SimpleUDPClient("127.0.0.1", 6010)
client.send_message("/ctrl", ["hello", 0.4])
  • Those who love the "Tidal feel" and don't want to lose it.
  • Those who want to extend their performance using Python for:
    • Randomness/probability
    • External device input
    • Machine learning output
    • Image/sensor/network data

Benefits

  • "Python × Tidal" coexists at minimal cost.
  • Difficult to get stuck with timing issues (Tidal handles it).

3) Direct OSC transmission from Python to SuperDirt (/dirt/play)

What are the differences?

  • Python sends triggers directly to SuperDirt without going through Tidal.
  • While most flexible, you have to handle the "look-ahead scheduling" that Tidal usually does by yourself.

The image of the trigger Tidal sends is roughly like this (the original fills the /dirt/play message with name-value pairs):

  • s bd (which sample)
  • speed 2 (parameters)
  • Additionally, cps / cycle / delta / orbit, etc., are provided.

A minimal example of "triggering a sound" in Python (concept)

from pythonosc.udp_client import SimpleUDPClient

client = SimpleUDPClient("127.0.0.1", 57120)  # SuperDirt listening port

# Send name-value pairs to /dirt/play (formatted for compatibility)
client.send_message(
    "/dirt/play",
    [
        "cps", 0.5,
        "cycle", 0.0,
        "delta", 0.25,
        "orbit", 0,
        "s", "bd",
        "speed", 1.0
    ],
)
  • Those who want to build their own "pattern engine."
  • Those who only need the "control surface" to trigger SuperDirt from an external system.

Points to Note (The biggest pitfall)

  • Using time.sleep() to set events is prone to jitter.
  • To make it sound clean, the basic strategy is to move toward the design of:
    Sending look-ahead via OSC bundles with timestamps → Aligning on the receiving side.

4) Using Python as a front-end for SuperCollider (scsynth): Supriya / sc3nb

What are the differences?

  • The goal is not a "Tidal-like syntax," but rather manipulating the sound synthesis engine from Python.
  • It often leans toward non-real-time (score generation) in addition to real-time control.

Examples:

  • Supriya: Launches and controls scsynth from Python, with SynthDefs also composed on the Python side.
  • sc3nb: Makes it easier to handle SuperCollider from Python (especially Jupyter).
  • Those whose goal is "building sound systems in Python" or "research/visualization/data-driven performance" rather than live coding.
  • Those who want to connect existing Python assets (numerical computation, ML, visualization) directly to sound.

5) DSP in Python alone: pyo

What are the differences?

  • Everything from synthesis to processing is completed within Python without using SuperCollider.
  • It can be used for "live coding-like" performance, but usually requires building your own pattern language.
  • Those who want to reduce dependencies or stay entirely within Python.
  • Those whose main purpose is learning or experimenting with sound processing and synthesis algorithms.

Comparison Table (Summary)

Route Sound Engine Role of Python Timing Design Recommended For
1) FoxDot / Sardine Mainly SuperCollider Pattern + Clock + Control Handled by tools Want live coding in Python
2) Tidal + Python(/ctrl) SuperCollider External controller Tidal is strong Want to keep Tidal and extend it
3) Direct Python → SuperDirt SuperCollider Everything (pattern & clock) DIY Want a custom implementation
4) Supriya / sc3nb scsynth-focused Synthesis/Control/Gen DIY or library support Sound system-oriented
5) pyo Python-internal Synthesis/Processing/Ctrl DIY Want to finish everything in Python

Minimal Check on macOS (Assuming Tidal/SC)

Starting point is launching SuperDirt in SuperCollider and ensuring the log shows listening ... 57120.

SuperDirt.start;

If you have "no sound" issues, troubleshooting from here (checking if it launched correctly / port is open) is the easiest path.


Which one should you choose? (Practical recommendations)

  • Want to maintain the Tidal performance feel (timing accuracy)? → 2) Tidal + Python (/ctrl)
    Least likely to run into trouble and highly extensible.

  • Want to live code in Python from the start? → 1) FoxDot / Sardine
    Fastest path to the "performing in Python" experience.

  • Want to build everything yourself / Main focus on external system integration? → 3) Direct /dirt/play
    Just keep in mind that underestimating the timing design will lead to jitter.


Discussion