> ## 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.

# Quickstart

> A metronome and a meow on the same logical clock.

## Metronome

junnu’s four-hit metronome — deterministic, no wall sleep:

```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
```

## Same idea, async spelling

`await (~d)` is the async form of `yield ~d`. Parentheses are required by Python’s `await` grammar. torq.py drives the coroutine; this is not `asyncio.run`.

```python theme={null}
from torq import Clock, ms, now, spork

clock = Clock()
hits = []

async def junnu_metro():
    for _ in range(4):
        hits.append(now())
        await (~(500 * ms))

with clock:
    spork(junnu_metro)
clock.run()
```

## Audio on the same clock

Laddu’s polite meow (needs `_audio` from a wheel or `torqpy[native]`):

```python theme={null}
from torq import Clock, Time, ms, spork
from torq.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)
```

## Next

* [Types & clock](https://torqpy.itsdote.tech/reference/types.md) — `Time`, `Dur`, arithmetic
* [Shreds](https://torqpy.itsdote.tech/reference/shreds.md) — join, cancel, groups
* [Shared](https://torqpy.itsdote.tech/reference/shared.md) — cross-domain values and events
* [Domains](https://torqpy.itsdote.tech/guides/domains.md) — audio / MIDI / sim / lab


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