torq.py
Strongly timed concurrent Python — logical musical time, sample-exact wakes, and an optional embedded audio graph on the same clock.
torq.py advances now only when shreds yield a duration (or you advance / run). It does not sleep on the wall clock. Audio UGens (first-party + embedded STK) tick inside the native graph; there is no external synth server.
| Brand | torq.py |
| PyPI | torqpy |
| Import | import torque |
Status: research package. PyPI name
torqpy(first publish: pure-Python wheel; native audio is optional and built locally).
Install
pip install torqpy
# or from this repo:
pip install -e .
Timing and shreds work with no native build. Audio (torque.audio) needs the optional extension:
# after pip install — sources ship inside the package:
bash "$(python -c 'import torque, pathlib; print(pathlib.Path(torque.__file__).parent / "native" / "build_audio.sh")')"
# from a git checkout:
bash torque/native/build_audio.sh
# needs: g++, python3-dev, portaudio19-dev
Then junnu can write:
import torque
from torque.audio import AudioEngine
Hello beep
Laddu wants one polite meow. junnu wires a sine, an envelope, and a shred that opens and closes it on logical time:
from torque import Clock, Time, ms, second, spork
from torque.audio import AudioEngine, write_wav
engine = AudioEngine(48_000)
osc = engine.SinOsc(440)
env = engine.ADSR(0.01, 0.1, 0.3, 0.2)
osc >> env >> engine.Gain(0.35) >> engine.dac
clock = Clock(sample_rate=48_000)
def laddu_meow():
env.keyOn()
yield 300 * ms
env.keyOff()
yield 300 * ms
with clock:
spork(laddu_meow)
buf = engine.render_while(clock, until=Time(0) + 600 * ms)
write_wav("beep.wav", buf, engine.sample_rate)
Timing without audio — junnu’s metronome:
from torque import Clock, ms, spork
clock = Clock()
hits = []
def junnu_metro():
for _ in range(4):
hits.append(clock.now)
yield 500 * ms
clock.spork(junnu_metro())
clock.run()
# hits at 0, 0.5s, 1s, 1.5s — deterministic, no wall sleep
Features
- Logical clock —
Time/Duras exact rationals;sampties to an integer sample rate - Shreds — generator or
async def+await (~d)on torq.py’s runner (notasyncio) - Ergonomics —
with clock:,spork/now,~d,t ^ d,Pat/p["x-x-"],@every - Audio graph — oscillators, Noise, ADSR, LPF/HPF, Delay, Pan, stereo render/WAV
- Embedded STK — Clarinet, BlowBotl, Plucked tick on torq.py’s sample clock
- Optional live I/O — PortAudio when a device exists; offline always works
Quick API
| Need | Start here |
|---|---|
| Types & clock | from torque import Clock, Time, Dur, second, ms, samp |
| Context helpers | spork, now, wait, every, Pat, p |
| Audio | from torque.audio import AudioEngine, write_wav, has_output_device |
| Connect UGens | src >> dst or src.to(dst) |
| Offline | engine.render_while(clock, until=...) |
| Live | has_output_device() then engine.play_while(...) |
Full surface: docs/api.md.
Docs
| Doc | Contents |
|---|---|
| docs/strongly-timed-python.md | Timing model & type rules |
| docs/torque-examples.md | Copy-paste timing snippets |
| docs/torque-audio.md | UGens, stereo, live, STK |
| docs/torque-ugen-roadmap.md | Coverage roadmap |
| docs/compare.md | Related systems |
| docs/api.md | Public API |
| llms.txt | Agent-oriented install & patterns |
Build (optional audio extension)
The published wheel is pure Python. Native sources (torque/native/, including vendored STK) are included so you can build _audio on the machine that will run audio:
bash "$(python -c 'import torque, pathlib; print(pathlib.Path(torque.__file__).parent / "native" / "build_audio.sh")')"
# or from a checkout: bash torque/native/build_audio.sh
# needs: g++, python3-dev, portaudio19-dev
Related work (peers)
See docs/compare.md for related systems and when each is a better fit. Peers include ChucK, Extempore, Tidal/Strudel, SuperCollider, pyo, and Python asyncio (wall-clock concurrency — different job).
License
torq.py is Apache-2.0. Vendored STK under torque/native/stk/ carries its own MIT-style license (Cook & Scavone).
Metadata
Release files for torqpy 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| torqpy-0.1.0.tar.gz | 80.8 kB | With provenance | Details for torqpy-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| torqpy-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for torqpy-0.1.0-py3-none-any.whl |
Total release size: 171.7 kB
Release files / torqpy-0.1.0.tar.gz
| Download URL | torqpy-0.1.0.tar.gz |
|---|---|
| Size | 80.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2427c85b936808bd3ea28bc510de1d6767505c677337fbfd5aaac8cee067b031
|
|
BLAKE2b-256 checksum How to use checksums |
ffc386d82d0162a71bf653f6c494f7e3b4e42ae15b5e96b33edf0a4bfbcea9e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / torqpy-0.1.0-py3-none-any.whl
| Download URL | torqpy-0.1.0-py3-none-any.whl |
|---|---|
| Size | 90.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a70d0f85714faf9b6a29ea13f34a8d680ca28970e8ba413ad6d2dafe63a90b5c
|
|
BLAKE2b-256 checksum How to use checksums |
4863054503792f5c0dfda42b5d2712cba07aa20f2dda106993a646ae333aea0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logSecurity for torqpy 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for torqpy-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.