> ## Documentation Index
> Fetch the complete documentation index at: https://torqpy.itsdote.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# torq.py

> Strongly timed concurrent Python on one logical clock — audio, MIDI/DMX, sim, and lab.

**torq.py** is a multi-domain strongly timed library. Audio/synth, MIDI/DMX cues, deterministic sim ticks, and lab protocols share the same rational `Time` / `Dur` timeline.

`now` advances only when shreds yield a duration (or you `advance` / `run` / `SimClock.step` / `frame`). Logical waits never call wall-clock sleep.

| | |
| - | - |
| Brand | **torq.py** |
| PyPI | `pip install torqpy` |
| Import | `import torq` |

> [card] [Install](https://torqpy.itsdote.tech/install.md)
>
> Pure-Python timing out of the box; optional native wheels for audio.

> [card] [Quickstart](https://torqpy.itsdote.tech/quickstart.md)
>
> Four-hit metronome and a meow on the same clock.

> [card] [API reference](https://torqpy.itsdote.tech/reference/overview.md)
>
> Types, clock, shreds, Shared, operators, and every domain.

> [card] [Domains](https://torqpy.itsdote.tech/guides/domains.md)
>
> How audio, MIDI/DMX, sim, and lab share one timeline.

## Mental model

* One logical `now` (`Time`) across domains.
* Concurrent shreds are ordinary Python generators or `async def` driven by torq.py — not `asyncio.run`.
* Cross-domain coordination uses a thin `Shared` value/event bus and shared patching operators (`>>`, `@`, `.to`, `.send`).
* Prefer shred ergonomics (`join`, `cancel` / `unspork`, `ShredGroup`) over a second process API.

```python theme={null}
from torq 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
```

> [!NOTE]
>
> Status: research / alpha. APIs may evolve. The next planned PyPI cut is **0.4.0** — not published from this docs work.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.