prep for 1.2.0 release updates

This commit is contained in:
2026-06-21 11:45:58 -07:00
parent 73191c958f
commit 032b7c39d3
286 changed files with 21116 additions and 121 deletions
@@ -0,0 +1,84 @@
# Triggers and Timing
@Metadata {
@PageKind(article)
}
Generators that detect, shape, delay, count, and step on trigger edges. A *trigger* is
a rising edge — a sample that crosses from `≤ 0` to `> 0`. These are the building blocks
of drum machines, arpeggiators, gate logic, and clock-driven sequencing.
Each generator provides an `.Audio` (sample-accurate) and a `.Control` (block-rate)
variant. The Control variants run the same state machine across the block but emit a flat
block-final value — trigger and counter outputs are discrete and are never smoothed/ramped.
For sending a trigger from the audio graph back to the language side, see ``SendTrigger``
(<doc:SendTrigger>). For latching and gating an arbitrary signal on a trigger, see
``Gate`` / ``SampleAndHold`` in <doc:SignalAnalysis>.
---
## Pulse Shaping
``Trig`` and ``Trig1`` stretch a momentary trigger into a gate of fixed duration.
``Trig`` holds the *input level* captured at the edge; ``Trig1`` holds unity (`1.0`).
A new edge during the hold restarts the timer.
```swift
Trig.Audio(input: impulse, dur: 0.1) // hold the trigger level for 100 ms
Trig1.Audio(input: impulse, dur: 0.05) // 50 ms unity gate on each edge
```
- `dur` — hold time in seconds (init-time scalar). Defaults to `0.1`.
## Trigger Delay and Counting
``TriggeredDelay`` re-fires a trigger after a delay (ignoring edges while counting);
``PulseCount`` accumulates a running count of rising edges with an optional reset.
```swift
TriggeredDelay.Audio(input: impulse, dur: 0.25) // echo the trigger 250 ms later
PulseCount.Audio(trig: clock, reset: bar) // count clocks, reset each bar
```
- `dur` — delay in seconds (init-time scalar). Defaults to `0.1`.
- `reset` — any ``ValidGeneratorInput``; a rising edge zeroes the count. Defaults to `0.0`.
## Stepping
``Stepper`` walks an integer counter by `step` on each trigger, wrapping inclusively in
`[min, max]`, with an optional reset to `resetval`. Ideal as a step-sequencer index.
```swift
Stepper.Audio(trig: clock, reset: 0.0, min: 0, max: 7, step: 1) // 0,1,…,7,0,…
```
- `min` / `max` / `step` / `resetval` — init-time `Int` scalars. `max >= min` required.
## Threshold Detection
``Schmidt`` is a Schmitt trigger with hysteresis: output goes to `1` when the input rises
above `hi`, back to `0` when it falls below `lo`, and holds in between.
```swift
Schmidt.Audio(input: sig, lo: -0.2, hi: 0.2) // hysteresis band [-0.2, 0.2]
```
- `lo` / `hi` — any ``ValidGeneratorInput``; switch-off and switch-on thresholds.
## Topics
### Pulse Shaping
- ``Trig``
- ``Trig1``
### Trigger Delay and Counting
- ``TriggeredDelay``
- ``PulseCount``
### Stepping and Thresholds
- ``Stepper``
- ``Schmidt``