bugfixes, better MusicXML support and 1.1.0
This commit is contained in:
@@ -1,86 +0,0 @@
|
||||
# Live coding with `LyrebirdScratchView`
|
||||
|
||||
A SwiftUI scratchpad for hot-swapping snippets through `LyrebirdLiveCompile`.
|
||||
|
||||
## Overview
|
||||
|
||||
`LyrebirdScratchView` pairs an `NSTextView`-backed Swift editor with a `LiveSession`
|
||||
that owns the audio engine. Pressing **⌘↩** wraps the snippet body in the standard
|
||||
harness, shells out to `swiftc`, `dlopen`s the resulting dylib, and calls the
|
||||
snippet's `lyrebird_snippet_entry` with a `SnippetContext` bound to the session.
|
||||
Synthesizers played via `context.play(_:)` are tracked, so the next non-additive
|
||||
run replaces them. **⌘⇧↩** layers a new snippet on top of the prior ones.
|
||||
|
||||
Compile diagnostics from a failing snippet are parsed by `DiagnosticParser`
|
||||
and rendered beneath the editor with line numbers already remapped from the wrapped
|
||||
source back to the user's snippet coordinates.
|
||||
|
||||
The view is macOS-only — `LyrebirdLiveCompile` shells out to `swiftc`, which is
|
||||
unavailable on iOS. The nested `LiveCompile/` sub-package declares
|
||||
`platforms: [.macOS(.v15)]` and cannot be added to an iOS target.
|
||||
|
||||
## Hosting
|
||||
|
||||
```swift
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI // LyrebirdWindow
|
||||
import LyrebirdLiveCompile // LiveSession
|
||||
import LyrebirdLiveCompileUI // LyrebirdScratchView
|
||||
|
||||
let engine = SynthesisEngine(/* … */)
|
||||
try engine.start()
|
||||
|
||||
let session = LiveSession(engine: engine)
|
||||
let window = LyrebirdWindow(title: "Lyrebird Scratch", width: 640, height: 480)
|
||||
window.open {
|
||||
LyrebirdScratchView(session: session)
|
||||
}
|
||||
```
|
||||
|
||||
## Keyboard shortcuts
|
||||
|
||||
| Shortcut | Action |
|
||||
|----------|--------|
|
||||
| ⌘↩ | Compile + run. Removes synths from the previous run before executing. |
|
||||
| ⌘⇧↩ | Compile + run additively. Keeps previously played synths in the engine. |
|
||||
|
||||
The toolbar exposes both as buttons plus a `Clear Synths` button that calls
|
||||
`LiveSession.clearTracked()` directly.
|
||||
|
||||
## Snippet API surface
|
||||
|
||||
A snippet has one local in scope:
|
||||
|
||||
```swift
|
||||
context: SnippetContext
|
||||
```
|
||||
|
||||
`SnippetContext` is intentionally minimal in v1:
|
||||
|
||||
- `context.engine` — the host `SynthesisEngine`.
|
||||
- `context.play(_:)` — add a `Synthesizer` to the engine and register it for
|
||||
cleanup on the next non-additive run.
|
||||
- `context.reportMessage(_:)` — write back to the host (used by tests; handy for
|
||||
`print`-style probes during development).
|
||||
|
||||
## Threading
|
||||
|
||||
All UI is `@MainActor`-isolated. `LiveSession.compileAndRun` is invoked
|
||||
synchronously inside the button action, so the editor freezes for the duration
|
||||
of the `swiftc` invocation (≈ 1 second cold, much faster on warm cache). v1
|
||||
accepts that trade-off; an off-main compile path is on the polish list.
|
||||
|
||||
## Limitations
|
||||
|
||||
- macOS only.
|
||||
- No syntax highlighting, code completion, or line-number gutter (deferred).
|
||||
- Compiled dylibs are leaked by design — types in a loaded snippet may still be
|
||||
referenced by tracked synths; unloading is unsafe.
|
||||
- The host `.app` must not be sandboxed and must allow library validation to be
|
||||
disabled, since `swiftc` is invoked via `Process` and the resulting unsigned
|
||||
dylib is `dlopen`'d.
|
||||
|
||||
## Topics
|
||||
|
||||
- ``LyrebirdScratchView``
|
||||
- ``LyrebirdScratchModel``
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// LyrebirdUI/LiveCompile — Phase 145
|
||||
// LyrebirdUI/LiveCompile
|
||||
//
|
||||
// Backing model for `LyrebirdScratchView`. Owns the editable snippet text, the
|
||||
// most recent compile result, and the host `LiveSession`. Pulled out of the
|
||||
@@ -16,7 +16,11 @@
|
||||
import Foundation
|
||||
import CoreGraphics
|
||||
import LyrebirdSynth
|
||||
import LyrebirdLiveCompile
|
||||
// Re-exported so consumers that link only the `LyrebirdLiveCompileUI` product
|
||||
// (e.g. the LyrebirdScratchDemo app) get the `LyrebirdLiveCompile` API
|
||||
// (`LiveSession`, …) without separately linking the `LyrebirdLiveCompile`
|
||||
// dynamic product — which clashes in Xcode with the static target embed.
|
||||
@_exported import LyrebirdLiveCompile
|
||||
|
||||
/// Observable backing model for `LyrebirdScratchView`.
|
||||
///
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// LyrebirdUI/LiveCompile — Phase 145
|
||||
// LyrebirdUI/LiveCompile
|
||||
//
|
||||
// `LyrebirdScratchView` — SwiftUI scratchpad editor for live-coded snippets.
|
||||
// Wraps an `NSTextView` for the editor surface, drives a `LyrebirdScratchModel`
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// LyrebirdUI/LiveCompile — Phase 147
|
||||
// LyrebirdUI/LiveCompile
|
||||
//
|
||||
// Vertical line-number gutter for `ScratchEditor`'s `NSTextView`. Installed as
|
||||
// the scroll view's `verticalRulerView` so it tracks scroll position for free.
|
||||
|
||||
Reference in New Issue
Block a user