v1.4.0 release: live-coding scratch editor, interpreted Graph DSL, ClosureSynthesizer + SampleLoop
This commit is contained in:
+102
@@ -7,6 +7,108 @@ functionality in a backward-compatible way.
|
||||
|
||||
---
|
||||
|
||||
## 1.4.0 — Live-coding scratch editor, interpreted Graph DSL, `ClosureSynthesizer` + `SampleLoop`
|
||||
|
||||
A minor release. Fully backward-compatible — no changes to existing public API.
|
||||
Adds a live-coding editor and an interpreted graph language on the tooling side,
|
||||
two new core building blocks (`ClosureSynthesizer`, `SampleLoop`), and one
|
||||
real-time correctness fix in the disk recorder.
|
||||
|
||||
### New — `ClosureSynthesizer`: play a graph without a subclass
|
||||
|
||||
The shortest path from a generator graph to sound. Instead of declaring a
|
||||
`SynthesizerBase` subclass and overriding `build()`, hand a closure that returns
|
||||
the output graph:
|
||||
|
||||
```swift
|
||||
try engine.add(ClosureSynthesizer { OscSin.Audio(freq: 440, mul: 0.1) })
|
||||
try engine.add(ClosureSynthesizer(bus: 0) { Pan2(input: saw, pan: 0) })
|
||||
```
|
||||
|
||||
The closure runs once, inside `build()`, on the main thread when the synth is
|
||||
added — so each instance builds its own graph (the usual
|
||||
graph-copy-per-instance rule). A multi-channel source fans out across
|
||||
consecutive buses from `bus`, exactly as `output(bus:source:)` does. This is
|
||||
also the primitive the scratch editor's "play a bare graph" and Graph DSL paths
|
||||
build on.
|
||||
|
||||
### New — `SampleLoop`: inline per-sample DSP + single-sample feedback
|
||||
|
||||
The RT-safe escape hatch for custom sample-accurate DSP — including
|
||||
**single-sample feedback loops** (one-pole filters, waveguides, comb/allpass
|
||||
structures) — without declaring a whole new `Generator` type.
|
||||
|
||||
- **No per-block allocation.** `SampleLoop` owns its pre-allocated output buffer
|
||||
(inherited `_result`) and resolves its inputs once per block via the fan-out
|
||||
cache, then hands both to your closure to fill the whole block in one pass —
|
||||
unlike `Closure`, which allocates a fresh `[Double]` and evaluates one sample
|
||||
at a time.
|
||||
- **Typed `inout` feedback state.** State is built by `makeState(numChannels)`
|
||||
and passed `inout` to the body, so a filter can carry `y[n-1]` across samples
|
||||
and blocks correctly.
|
||||
- **Channel inference + broadcast.** Output width is inferred from the inputs
|
||||
(`max` of their channel counts, or `1` with none); each input is broadcast up
|
||||
to that width, so the same body scales to any channel count. Mismatched
|
||||
multi-row inputs precondition-trap at construction, matching
|
||||
`BinaryOpGenerator`'s policy.
|
||||
|
||||
### New — Live-coding scratch editor (`LyrebirdLiveCompile`, macOS)
|
||||
|
||||
An interactive scratch pad that compiles and plays Swift snippets against a
|
||||
running engine, with hot-swap and safety scaffolding built in:
|
||||
|
||||
- **Bare-graph & subclass play** — `context.play { … }` for a graph,
|
||||
`context.play(synth)` for a declared `Synthesizer`.
|
||||
- **Named slots (Pdef-style hot-swap)** — re-running a `play(slot:)` replaces
|
||||
just that voice in place; other slots keep playing. Swaps can quantize to the
|
||||
next beat/bar for glitch-free, on-grid transitions.
|
||||
- **Re-evaluation readiness** — a status badge (empty / dirty / compiling /
|
||||
clean / queued / failed) gates the Run controls.
|
||||
- **Syntax highlighting** and a line-number gutter.
|
||||
- **Code completion** via the toolchain's `sourcekit-lsp`: typing `.` resolves
|
||||
the real symbols the snippet would see at compile time — `LyrebirdSynth`
|
||||
generators (`OscSin.` → `Audio`, `Control`), the injected `context`, and the
|
||||
standard library.
|
||||
- **Fast first sound** — the module cache is prewarmed at launch, so the first
|
||||
⌘↩ is ~0.1 s instead of a ~2 s cold build.
|
||||
- **Snippet-memory safety** — each compiled snippet maps a dylib that can't be
|
||||
safely unloaded; the editor surfaces a live "snippets: N" count and nudges a
|
||||
restart (or a switch to the leak-free Graph DSL mode) past a threshold.
|
||||
|
||||
### New — Interpreted Graph DSL (`LyrebirdGraphDSL`, cross-platform)
|
||||
|
||||
A small text→graph language that plays **instantly — no swiftc, no dylib, no
|
||||
leak** — and is the structural answer to the snippet-dylib cost:
|
||||
|
||||
```
|
||||
bass = OscSawtooth.Audio(freq: 55, mul: 0.15)
|
||||
Pan2(input: OscSin.Audio(freq: 440, mul: 0.1), pan: 0)
|
||||
```
|
||||
|
||||
- **304 built-in generators**, code-generated from generator init signatures, so
|
||||
new generators appear automatically. Audio- and control-rate variants and
|
||||
buffer resources are supported.
|
||||
- **Paste-compatible** — the rate suffix is the exact Swift nested-class name
|
||||
(`OscSin.Control`), so a graph expression written in the editor pastes into a
|
||||
Lyrebird project unchanged.
|
||||
- A mode toggle in the scratch editor runs the buffer through this path on the
|
||||
same track/slot machinery as the Swift path, with errors in the same gutter.
|
||||
|
||||
### Fixed — `DiskOut` real-time data race
|
||||
|
||||
`DiskOut`'s ring buffer was a Swift `[[Float]]` shared between the real-time
|
||||
render thread (writer) and its background disk-writer thread (reader). Even at
|
||||
disjoint frame ranges, Swift `Array` access is not race-free — the subscript and
|
||||
`withUnsafeMutableBufferPointer` touch the array's shared storage pointer and
|
||||
copy-on-write / refcount bookkeeping, which the frame-counter atomics did not
|
||||
fence. Under load this corrupted the heap (surfacing as retain-count aborts).
|
||||
The ring is now backed by raw contiguous `UnsafeMutableBufferPointer<Float>`
|
||||
storage, so the existing release/acquire frame-counter fence alone makes the
|
||||
single-producer/single-consumer handoff correct. Confirmed with ThreadSanitizer;
|
||||
also eliminated the long-standing parallel-`swift test` teardown crash.
|
||||
|
||||
---
|
||||
|
||||
## 1.3.0 — Graceful-release fix, quickstart template, documentation accuracy pass
|
||||
|
||||
A minor release. Backward-compatible: one real-time behavior fix, one new
|
||||
|
||||
Reference in New Issue
Block a user