v2.4.1 release: scratchpad polish + demo cleanup

Maintenance release, no framework API changes.

Scratchpad: Kill All Sound (⌘K) rename, mode-switch desync fix,
code-completion prefix filtering restored (⌃Space Show Completions).
Demos: GUIDemo voices + CLI EventPattern BlipVoice moved into
Synthesizers/, EventPattern demo split into makeLead/makeBass, GUIDemo
doc drift fixed (conductor default). LyrebirdScratch gains a SwiftPM
package so the workspace shows it like GUIDemo (.xcodeproj kept for
distribution). Linux live-coding scratchpad documented.
This commit is contained in:
2026-12-03 11:39:40 -08:00
parent 6da3615707
commit ec72bd3a4c
29 changed files with 510 additions and 110 deletions
@@ -22,6 +22,7 @@
C1A000000000000000000013 /* Lyrebird in Frameworks */ = {isa = PBXBuildFile; productRef = C1A000000000000000000012 /* Lyrebird */; };
C1A000000000000000000016 /* SineTone.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1A000000000000000000014 /* SineTone.swift */; };
C1A000000000000000000017 /* DelaySample.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1A000000000000000000015 /* DelaySample.swift */; };
C1A00000000000000000001B /* BlipVoice.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1A00000000000000000001A /* BlipVoice.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -40,6 +41,7 @@
C1A000000000000000000006 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
C1A000000000000000000014 /* SineTone.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SineTone.swift; sourceTree = "<group>"; };
C1A000000000000000000015 /* DelaySample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DelaySample.swift; sourceTree = "<group>"; };
C1A00000000000000000001A /* BlipVoice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlipVoice.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -95,6 +97,7 @@
035B00092FAB0000007F0001 /* General */ = {
isa = PBXGroup;
children = (
C1A00000000000000000001A /* BlipVoice.swift */,
C1A000000000000000000015 /* DelaySample.swift */,
C1A000000000000000000014 /* SineTone.swift */,
);
@@ -216,6 +219,7 @@
C1A000000000000000000016 /* SineTone.swift in Sources */,
035A2F472FAA6950007F6289 /* PercTimeStretch.swift in Sources */,
C1A000000000000000000017 /* DelaySample.swift in Sources */,
C1A00000000000000000001B /* BlipVoice.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -8,7 +8,7 @@ import Foundation
import LyrebirdSynth
/// Demonstrates ``EventPattern`` — Lyrebird's event-driven player: bound value patterns drive a
/// fresh self-freeing voice per event, played as a dur/legato-timed stream.
/// fresh self-freeing ``BlipVoice`` per event, played as a dur/legato-timed stream.
///
/// Also shows two patterns running together via ``ParallelEventPattern``: a lead phrase and a
/// bass line that enters a few beats in on the same beat grid, with a single
@@ -17,87 +17,55 @@ import LyrebirdSynth
final class EventPatternDemo: DemoProtocol {
private let engine: SynthesisEngine
private let tempoBPM: Double = 132.0
/// Beats the bass waits before its first note. Shared tempo means both parts share a beat
/// grid, so this is a plain offset on that grid.
private let leadInBeats: Double = 2.0
init(engine: SynthesisEngine) {
self.engine = engine
}
/// A gated voice (``EventGated``): a sine through an `EnvelopeGen` whose gate holds it at full
/// level while the note sounds, then plays a release and frees the voice via
/// `doneAction: .freeNode` when `EventPattern` closes the gate at the note's sustain. No
/// external removal, so the release is never hard-cut — nothing to tune, no click.
private final class BlipVoice: SynthesizerBase, EventGated {
/// Envelope release length in seconds — how long a note rings after its gate closes.
/// Exposed so the demo can let the final note's tail finish before stopping the engine.
nonisolated static let releaseSeconds: Double = 0.3
/// Envelope attack length in seconds.
nonisolated static let attackSeconds: Double = 0.01
@LiveParam var freq: Double = 440.0
@LiveParam var amp: Double = 0.2
@LiveParam var gate: Double = 1.0 // open by default so the attack fires on add
var eventGate: ParameterNode { $gate }
override func build() {
// `releaseNode: 1` holds at `levels[1]` (full) while the gate is open; when the gate
// drops to 0 the generator plays segment 1 (the release to 0) and then self-frees.
let envelope: Envelope = Envelope(
levels: [0.0, 1.0, 0.0],
durations: [BlipVoice.attackSeconds, BlipVoice.releaseSeconds],
curves: [.welch, .welch],
releaseNode: 1
)
let shaped: EnvelopeGen.Audio = EnvelopeGen.Audio(
envelope: envelope,
gate: $gate,
doneAction: .freeNode
)
let source: OscSin.Audio = OscSin.Audio(freq: $freq, mul: $amp)
output(bus: 0, source: source * shaped)
}
}
func runDemo() {
print("\n── EventPattern demo ──")
let tempoBPM: Double = 132.0
// Pattern 1 — the lead: a short A-minor-pentatonic phrase, written as named pitches rather
// than raw Hz (equivalent MIDI form: `Pitch.midi(69).frequency`, etc.), played three times.
/// The lead: a short A-minor-pentatonic phrase, written as named pitches rather than raw Hz
/// (equivalent MIDI form: `Pitch.midi(69).frequency`, etc.), played three times.
private func makeLead() -> EventPattern<BlipVoice> {
let phrase: [Pitch] = [
.named(.a, 4), .named(.c, 5), .named(.d, 5), .named(.e, 5),
.named(.g, 5), .named(.e, 5), .named(.d, 5), .named(.c, 5),
]
let leadFreqs: [Double] = phrase.compactMap(\.frequency)
let lead: EventPattern<BlipVoice> = EventPattern(make: { BlipVoice() })
.bind(\.freq, .sequence(leadFreqs, repeats: 1))
let freqs: [Double] = phrase.compactMap(\.frequency)
return EventPattern(make: { BlipVoice() })
.bind(\.freq, .sequence(freqs, repeats: 1))
.bind(\.amp, .uniformRandom(low: 0.15, high: 0.3))
.dur(.sequence([0.25, 0.25, 0.25, 0.5]))
.legato(0.8)
.tempo(tempoBPM)
.repeats(3)
}
// Pattern 2 — a bass line that enters `leadInBeats` after the lead and outlasts it.
// There is no cross-pattern clock: `ParallelEventPattern` launches both children from the
// one `play` call, so they share a start instant, and at the SAME tempo they share a beat
// grid. `addAfter(beats:)` staggers the bass's entry on that grid — the bass simply waits
// `leadInBeats` beats before its first note.
let leadInBeats: Double = 2.0
let bassPhrase: [Pitch] = [.named(.a, 2), .named(.a, 2), .named(.g, 2), .named(.e, 2)]
let bassFreqs: [Double] = bassPhrase.compactMap(\.frequency)
let bass: EventPattern<BlipVoice> = EventPattern(make: { BlipVoice() })
.bind(\.freq, .sequence(bassFreqs, repeats: 1))
/// The bass: one slow phrase at the same tempo, entered `leadInBeats` after the lead and
/// outlasting it. No cross-pattern clock — ``ParallelEventPattern`` launches both children
/// from the one `play` call, so they share a start instant and (at equal tempo) a beat grid.
private func makeBass() -> EventPattern<BlipVoice> {
let phrase: [Pitch] = [.named(.a, 2), .named(.a, 2), .named(.g, 2), .named(.e, 2)]
let freqs: [Double] = phrase.compactMap(\.frequency)
return EventPattern(make: { BlipVoice() })
.bind(\.freq, .sequence(freqs, repeats: 1))
.bind(\.amp, .uniformRandom(low: 0.2, high: 0.3))
.dur(.sequence([1.0]))
.legato(0.9)
.tempo(tempoBPM)
.repeats(1)
}
// Start both together, staggering the bass two beats in, and control them as one handle.
func runDemo() {
print("\n── EventPattern demo ──")
// Start both together, staggering the bass `leadInBeats` in, and control them as one handle.
let ensemble: ParallelEventPattern = ParallelEventPattern()
ensemble.add(lead)
ensemble.addAfter(beats: leadInBeats, eventPattern: bass)
ensemble.add(makeLead())
ensemble.addAfter(beats: leadInBeats, eventPattern: makeBass())
let handle: EventPatternHandle = ensemble.play(on: engine)
// `waitUntilComplete` blocks until EVERY child task has finished — so it waits for the
@@ -0,0 +1,45 @@
// BlipVoice.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
/// A gated voice (``EventGated``): a sine through an `EnvelopeGen` whose gate holds it at full
/// level while the note sounds, then plays a release and frees the voice via
/// `doneAction: .freeNode` when ``EventPattern`` closes the gate at the note's sustain. No
/// external removal, so the release is never hard-cut — nothing to tune, no click.
///
/// Used by ``EventPatternDemo`` for both the lead and the bass part.
final class BlipVoice: SynthesizerBase, EventGated {
/// Envelope release length in seconds — how long a note rings after its gate closes.
/// Exposed so a caller can let the final note's tail finish before stopping the engine.
nonisolated static let releaseSeconds: Double = 0.3
/// Envelope attack length in seconds.
nonisolated static let attackSeconds: Double = 0.01
@LiveParam var freq: Double = 440.0
@LiveParam var amp: Double = 0.2
@LiveParam var gate: Double = 1.0 // open by default so the attack fires on add
var eventGate: ParameterNode { $gate }
override func build() {
// `releaseNode: 1` holds at `levels[1]` (full) while the gate is open; when the gate
// drops to 0 the generator plays segment 1 (the release to 0) and then self-frees.
let envelope: Envelope = Envelope(
levels: [0.0, 1.0, 0.0],
durations: [BlipVoice.attackSeconds, BlipVoice.releaseSeconds],
curves: [.welch, .welch],
releaseNode: 1
)
let shaped: EnvelopeGen.Audio = EnvelopeGen.Audio(
envelope: envelope,
gate: $gate,
doneAction: .freeNode
)
let source: OscSin.Audio = OscSin.Audio(freq: $freq, mul: $amp)
output(bus: 0, source: source * shaped)
}
}
+10 -5
View File
@@ -27,8 +27,9 @@ so the controls, the oscilloscope, and the CPU meters are identical.
## Run it
```bash
swift run LyrebirdGUIDemo # vector oscillator (default)
LYREBIRD_DEMO=sine swift run LyrebirdGUIDemo # stereo sine tone
swift run LyrebirdGUIDemo # event conductor (default)
LYREBIRD_DEMO=vector swift run LyrebirdGUIDemo # vector oscillator
LYREBIRD_DEMO=sine swift run LyrebirdGUIDemo # stereo sine tone
```
- **macOS** — no extra setup; a native window opens with live audio via Core Audio.
@@ -47,12 +48,16 @@ LYREBIRD_DEMO=sine swift run LyrebirdGUIDemo # stereo sine tone
## What each demo shows
- **conductor** (default) — `ConductorDemoVoice` driven by an `EventConductor`:
start/stop the engine, then toggle a top and a bottom part, each entering on the
next beat and repeating while it runs, over a live oscilloscope. Showcases the
2.4.0 event system. Nothing plays until you start the engine and a part.
- **vector** — `VectorOscillatorUI`: an XY pad crossfades four corner wavetables
(sine / saw-ish / triangle / Hanning); frequency and amplitude knobs; a live
oscilloscope and CPU-load strip.
- **sine** — `SineToneUI`: a frequency slider, amplitude and pan knobs, a level
readout, the scope and CPU strip, and a static envelope plot.
Add a synth by dropping a `SynthesizerBase` subclass and a node-based view into
`LyrebirdGUIDemoKit`, then extend `DemoSelection` and the `demoContent()` switch
in `main.swift`.
Add a synth by dropping a `SynthesizerBase` subclass into
`LyrebirdGUIDemoKit/Synthesizers/` and a node-based view into `LyrebirdGUIDemoKit`,
then extend `DemoSelection` and the `demoContent()` switch in `main.swift`.
@@ -12,7 +12,7 @@
// • Linux — a GTK4 `App`/`WindowGroup` scene run by `GTK4Backend`.
//
// Run either with `swift run LyrebirdGUIDemo`. Pick the synth with
// `LYREBIRD_DEMO=vector` (default), `sine`, or `conductor`.
// `LYREBIRD_DEMO=conductor` (default), `vector`, or `sine`.
//
// `@ViewBuilder` and the window hosts come from SwiftUI on macOS and from
// SwiftOpenUI (re-exported through `LyrebirdUI`) on Linux — hence the single
@@ -11,7 +11,7 @@ import Foundation
/// selection so one binary covers every patch.
public enum DemoSelection: String, Sendable {
/// Vector oscillator with an XY blend pad (the default).
/// Vector oscillator with an XY blend pad.
case vector
/// Stereo sine tone with frequency / amplitude / pan controls.
@@ -19,9 +19,10 @@ public enum DemoSelection: String, Sendable {
/// Live event ensemble: engine start/stop plus top and bottom parts driven by an
/// ``EventConductor``. The view owns the engine, so nothing starts at launch.
/// This is the default — it showcases the headline event system.
case conductor
/// Resolve the selection from `LYREBIRD_DEMO` (defaults to `.vector`).
/// Resolve the selection from `LYREBIRD_DEMO` (defaults to `.conductor`).
public static func fromEnvironment() -> DemoSelection {
let raw: String = ProcessInfo.processInfo.environment["LYREBIRD_DEMO"]?.lowercased() ?? "conductor"
return DemoSelection(rawValue: raw) ?? .conductor
@@ -196,7 +196,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_HARDENED_RUNTIME = YES;
@@ -208,12 +208,13 @@
ENABLE_RESOURCE_ACCESS_PHOTO_LIBRARY = NO;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
INFOPLIST_FILE = LyrebirdScratch/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Lyrebird Scratch";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 15.0;
MARKETING_VERSION = 1.6.2;
MARKETING_VERSION = 2.4.1;
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.LyrebirdScratch;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -238,7 +239,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEAD_CODE_STRIPPING = YES;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_RESOURCE_ACCESS_AUDIO_INPUT = YES;
@@ -249,12 +250,13 @@
ENABLE_RESOURCE_ACCESS_PHOTO_LIBRARY = NO;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
INFOPLIST_FILE = LyrebirdScratch/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Lyrebird Scratch";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 15.0;
MARKETING_VERSION = 1.6.2;
MARKETING_VERSION = 2.4.1;
PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.LyrebirdScratch;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -13,7 +13,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.6.3</string>
<string>2.4.1</string>
<key>CFBundleVersion</key>
<string>3</string>
<key>LSMinimumSystemVersion</key>
+24
View File
@@ -0,0 +1,24 @@
{
"originHash" : "00d9a3997266cf2e38ebfa0f16e7978ca242180f4745b918a490a4758ba8e753",
"pins" : [
{
"identity" : "linenoise-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/andybest/linenoise-swift",
"state" : {
"revision" : "afc897c02b030af7333105c4fedcd843a8339238",
"version" : "0.0.3"
}
},
{
"identity" : "nimble",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Quick/Nimble.git",
"state" : {
"revision" : "e9d769113660769a4d9dd3afb855562c0b7ae7b0",
"version" : "7.3.4"
}
}
],
"version" : 3
}
+56
View File
@@ -0,0 +1,56 @@
// Package.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
// swift-tools-version: 6.0
import PackageDescription
// The live-coding scratchpad as a SwiftPM package, so the umbrella
// `Lyrebird.xcworkspace` shows it the same way as `LyrebirdGUIDemo` — a package,
// not a nested `.xcodeproj`. A sibling `LyrebirdScratch.xcodeproj` is kept on
// disk for distribution builds (custom app icon, entitlements, the module-
// staging run-script that makes an *exported* `.app` self-contained); the
// package form is the dev-run / in-workspace view.
//
// macOS only. The Linux scratchpad host is `LyrebirdScratchLinuxDemo` in the
// `LiveCompile/` sub-package (GTK4 / SwiftOpenUI); this executable is the AppKit
// (NSTextView + menu) counterpart.
//
// Dynamic products on purpose: the live-compile stack dlopens freshly compiled
// snippet dylibs that `import LyrebirdSynth` / `LyrebirdLiveCompile`. Linking the
// single shared `libLyrebirdDynamic` + `libLyrebirdLiveCompileUIDynamic` (rather
// than static-folding a second copy of LyrebirdSynth's ObjC classes into this
// executable) is what avoids duplicate class registration at dlopen time — the
// same reason the `LiveCompile` sub-package exists.
//
// Run: `swift build` first (so the …Dynamic dylibs exist in the build dir for
// the snippet link), then `swift run LyrebirdScratch`. As a bare SwiftPM
// executable there is no Hardened Runtime or App Sandbox, so the swiftc
// shell-out and the unsigned-snippet dlopen both work without entitlements (the
// `.xcodeproj` needs `disable-library-validation` only because an Xcode app
// target enables Hardened Runtime by default).
let package = Package(
name: "LyrebirdScratch",
platforms: [.macOS(.v15)],
dependencies: [
.package(name: "Lyrebird", path: "../.."),
.package(name: "LyrebirdLiveCompile", path: "../../LiveCompile"),
],
targets: [
.executableTarget(
name: "LyrebirdScratch",
dependencies: [
.product(name: "LyrebirdDynamic", package: "Lyrebird"),
.product(name: "LyrebirdLiveCompileUIDynamic", package: "LyrebirdLiveCompile"),
],
path: "LyrebirdScratch",
exclude: [
"Info.plist",
"LyrebirdScratch.entitlements",
"Assets.xcassets",
]
),
]
)