3 Commits

32 changed files with 1045 additions and 2191 deletions
-1
View File
@@ -71,7 +71,6 @@ The `.githooks/pre-commit` hook calls `--check`. Skips silently when `~/.claude/
- Dev workflow / phase branches / build → `docs/tooling/workflow.md`
- Xcode project templates → `docs/tooling/xcode-templates.md`
- AUv3 plugin internals (`LyrebirdAudioUnit`, `LyrebirdAUVoicePoolBinding`, `AUInput`, preset codable, parameter slots) → `Sources/Lyrebird/Lyrebird.docc/AUv3.md`
- ShoeGaze guitar-pedalboard sub-package (`Pedal`, `PedalBoard`, `ShoeGaze`, built-in pedals, `.testLoop` vs `.liveInput`, `lyrebird new --template shoegaze` workflow) → `docs/stdlib/shoegaze.md`
**UI**
- LyrebirdUI / parameter binding → `docs/ui/gui-system.md`
+7 -9
View File
@@ -11,9 +11,8 @@ functionality in a backward-compatible way.
A minor release. Adds roughly forty SuperCollider-parity generators —
triggers, time-domain analysis, chaotic oscillators, resonator banks, dynamics,
waveshaping, routing/morph, and psychoacoustic metering — plus a `shoegaze`
guitar-pedalboard project template and an iOS path fix. Fully
backward-compatible; no changes to existing public API.
waveshaping, routing/morph, and psychoacoustic metering — plus an iOS path fix.
Fully backward-compatible; no changes to existing public API.
### New generators
@@ -59,12 +58,11 @@ gain lag).
### Tooling
- **`shoegaze` project template.** `lyrebird new MyRig --template shoegaze`
scaffolds a guitar-pedalboard app (macOS or iOS) that depends on the ShoeGaze
package — a set of effect "pedals" chained into boards, with knobs, bypass,
parallel routing, and recording. Ships with an Xcode "ShoeGaze Pedal" file
template for authoring custom pedals. ShoeGaze itself now lives in its own
repository rather than in-tree.
- **ShoeGaze moved out of tree.** The guitar-pedalboard framework and its
project/pedal scaffolding now live in a standalone ShoeGaze repository that
depends on Lyrebird as a package. Lyrebird's CLI no longer ships the
`shoegaze` / `shoegaze-ios` project templates or the "ShoeGaze Pedal" Xcode
file template.
### Fixes
@@ -117,6 +117,9 @@ import Synchronization
/// `invalidate()` uses a `.releasing` store; `isValid` uses an `.acquiring` load.
/// `LyrebirdBuffer` is safe to share across threads:
/// - The validity flag is protected by `Atomic<Bool>`.
/// - `loopLength` is likewise an `Atomic<Int>` (`.acquiring` load / `.releasing` store
/// via ``setLoopLength(_:)``) — read every sample by `PlayBuffer`-family generators,
/// written once (non-RT) after e.g. a looper pedal finishes recording a take.
/// - `channelCount` and `count` are `let` constants — freely readable on any thread.
/// - Sample data can be written from the RT thread by `RecordBuffer` via the internal
/// `write(_:frame:channel:)` method. The buffer is **not safe for concurrent non-RT
@@ -240,6 +243,45 @@ public final class LyrebirdBuffer: @unchecked Sendable {
return bufRate / engineSampleRate
}
/// Number of frames that `PlayBuffer`-family generators should wrap (looping) or
/// clamp (non-looping) against, distinct from `count` (the full allocated size).
///
/// Defaults to `count` at init, matching the historical full-buffer looping
/// behaviour. Narrow this after recording a take that is shorter than the
/// buffer's max-duration allocation — e.g. a looper pedal that pre-allocates
/// 60 seconds but records a shorter take — so playback wraps only over the
/// actually-recorded region without reallocating the buffer.
///
/// **RT contract.** Stored as an `Atomic<Int>` rather than behind `_writeLock`:
/// this value is read on every sample inside `PlayBuffer`'s per-sample read loop
/// (`lyrebirdBufferRead`), so a lock acquired every sample would be the wrong
/// tool. An atomic load costs nothing close to a lock and gives torn-free reads
/// of a single `Int`. Set from a non-RT thread via ``setLoopLength(_:)``, e.g.
/// once after recording stops.
private let _loopLength: Atomic<Int>
/// Current loop/clamp bound for `PlayBuffer`-family generators, in frames.
///
/// `1...count`, defaulting to `count`. Read with an `.acquiring` load — safe to
/// call from the RT thread inside a per-sample read loop.
public var loopLength: Int {
_loopLength.load(ordering: .acquiring)
}
/// Narrow (or restore) the frame count that `PlayBuffer`-family generators wrap
/// or clamp against.
///
/// Call from a non-RT thread — typically once, right after recording stops
/// (e.g. a looper pedal calling this with the frame count `RecordBuffer`
/// actually wrote, so playback loops over just the recorded take instead of
/// the full max-duration allocation).
///
/// - Parameter length: Desired loop length in frames. Clamped to `[1, count]`.
public func setLoopLength(_ length: Int) {
let clamped: Int = max(1, min(length, count))
_loopLength.store(clamped, ordering: .releasing)
}
/// Atomic validity flag. `true` after `init`, `false` after `invalidate()`.
private let _isValid: Atomic<Bool>
@@ -460,6 +502,7 @@ public final class LyrebirdBuffer: @unchecked Sendable {
_storage = UnsafeMutablePointer<Double>.allocate(capacity: total)
_storage.initialize(repeating: 0, count: total)
_isValid = Atomic<Bool>(true)
_loopLength = Atomic<Int>(count)
}
deinit {
@@ -10,10 +10,14 @@ import Synchronization
/// Interpolated read from `buffer` at a fractional frame `phase` for one `channel`.
///
/// - For `loop == true`: frames wrap modulo `buffer.count` (seamless looping). `wrappedFrame`
/// handles negative frame indices via `r += frameCount`, so backward reads across the loop
/// point are correct.
/// - For `loop == false`: frames are clamped to `[0, buffer.count − 1]` (hold at ends).
/// - For `loop == true`: frames wrap modulo `buffer.loopLength` (seamless looping).
/// `wrappedFrame` handles negative frame indices via `r += frameCount`, so backward
/// reads across the loop point are correct.
/// - For `loop == false`: frames are clamped to `[0, buffer.loopLength − 1]` (hold at ends).
///
/// `buffer.loopLength` defaults to `buffer.count` (full-buffer looping) but may be
/// narrowed at runtime — e.g. a looper pedal that recorded a take shorter than its
/// max-duration buffer allocation — to bound wrap/clamp to just the recorded region.
///
/// Used by `PlayBuffer.Audio` and `PlayBuffer.Control`; exposed as `internal` for reuse by
/// future buffer-reading generators (e.g. `BufferGrain`).
@@ -25,7 +29,7 @@ internal func lyrebirdBufferRead(
interpolation: TableInterpolation,
loop: Bool
) -> Double {
let frameCount: Int = buffer.count
let frameCount: Int = buffer.loopLength
@inline(__always)
func clampedFrame(_ f: Int) -> Int {
@@ -356,7 +360,7 @@ public enum PlayBuffer {
return _result
}
let bufferFrames: Double = Double(buffer.count)
let bufferFrames: Double = Double(buffer.loopLength)
@inline(__always)
func rateAt(_ i: Int) -> Double {
@@ -526,7 +530,7 @@ public enum PlayBuffer {
// Read one output value for this block.
let outputVal: Double
if let buffer: LyrebirdBuffer = _slot.load(engine: graph.engine), buffer.isValid, !_isDone {
let bufferFrames: Double = Double(buffer.count)
let bufferFrames: Double = Double(buffer.loopLength)
outputVal = lyrebirdBufferRead(
buffer, channel: 0, phase: _phase,
interpolation: interpolation, loop: loop
@@ -90,6 +90,27 @@ public enum RecordBuffer {
var _isDone: Bool = false
let _needsFree: Atomic<Bool> = Atomic(false)
/// Set by `requestReset()` on a non-RT thread, consumed once at the top of the
/// next `_computeSamples` call on the RT thread.
let _resetRequested: Atomic<Bool> = Atomic(false)
/// Block-rate snapshot of `writePos`, published once per audio block rather
/// than per sample to avoid extra atomic-store overhead in the hot per-sample
/// write loops. Updated at the end of every `_computeSamples` call.
let _writePosSnapshot: Atomic<Int> = Atomic(0)
/// Number of frames written to `buffer` so far, safe to read from a non-RT
/// thread.
///
/// `writePos` itself is a plain `var` mutated per-sample on the RT thread and
/// is not safe for concurrent non-RT reads. This snapshot is published once
/// per audio block (`.releasing` store at the end of `_computeSamples`) and
/// read here with an `.acquiring` load, so a caller can safely read "how many
/// frames were recorded" after stopping recording (e.g. setting `run = 0`) —
/// for example a looper pedal narrowing `buffer.loopLength` to the actually
/// recorded region once the take finishes.
public var recordedFrameCount: Int { _writePosSnapshot.load(ordering: .acquiring) }
/// `true` when `doneAction == .freeNode` and recording has completed.
///
/// Read from a non-RT context after `processBlock` returns and schedule
@@ -122,9 +143,42 @@ public enum RecordBuffer {
// MARK: - Shared
/// Requests that recording restart from frame 0 on the next processed block.
///
/// Safe to call from any non-RT thread at any time (e.g. a "reset" UI action on
/// a looper pedal). Sets an `Atomic<Bool>` flag consumed once at the top of the
/// next `_computeSamples` call — `writePos` is reset to `0`, `_isDone` cleared,
/// and any pending `.freeNode` completion (`needsFree`) is cleared so the same
/// instance can be reused for a fresh take. Because the flag is only checked at
/// block boundaries, the reset takes effect at the start of the next block, not
/// mid-block — acceptable for a user-triggered action.
///
/// Does **not** touch `buffer` contents or `buffer.loopLength`. Callers that want
/// a fully blank take should also call `buffer.clear()` and
/// `buffer.setLoopLength(buffer.count)` themselves before or after calling this.
public func requestReset() {
_resetRequested.store(true, ordering: .releasing)
}
/// Consumes a pending reset request, if any. Call once at the top of
/// `_computeSamples` before touching `writePos` / `_isDone`.
@inline(__always)
func _consumeResetIfRequested() {
let (exchanged, _): (Bool, Bool) = _resetRequested.compareExchange(
expected: true,
desired: false,
ordering: .acquiringAndReleasing
)
if exchanged {
writePos = 0
_isDone = false
_needsFree.store(false, ordering: .releasing)
}
}
func handleEndOfBuffer() {
_isDone = true
writePos = buffer.count - 1
writePos = buffer.loopLength - 1
switch doneAction {
case .nothing:
break
@@ -202,6 +256,10 @@ public enum RecordBuffer {
) -> [[Double]] {
_checkCount(count)
guard count > 0 else { return _result }
_consumeResetIfRequested()
// Publish `writePos` once per block (not per sample) for non-RT readers —
// see `recordedFrameCount` doc-comment.
defer { _writePosSnapshot.store(writePos, ordering: .releasing) }
let runSamples: [Double] = $run.calculatedSamples(graph: graph, count: count).first
?? _zeroFallback
@@ -212,7 +270,12 @@ public enum RecordBuffer {
let chCount: Int = channelCount
let bufferIsLive: Bool = buffer.isValid
let bufferCount: Int = buffer.count
// Wrap/overrun bound is the caller-narrowed `loopLength` (defaults to `count`), for
// both `loop == true` (a looping overdub recorder re-writes exactly the recorded
// take instead of the full allocated buffer) and `loop == false` (the overrun pins
// `writePos` to `loopLength - 1` via `handleEndOfBuffer()`, consistent with this bound
// regardless of when the caller narrows `loopLength`).
let bufferCount: Int = buffer.loopLength
let canRecord: Bool = bufferIsLive && !_isDone
let localLoop: Bool = loop
@@ -524,6 +587,10 @@ public enum RecordBuffer {
) -> [[Double]] {
_checkCount(count)
guard count > 0 else { return _result }
_consumeResetIfRequested()
// Publish `writePos` once per block (not per sample) for non-RT readers —
// see `recordedFrameCount` doc-comment.
defer { _writePosSnapshot.store(writePos, ordering: .releasing) }
// Evaluate params: advance ParameterNode state; use settled (last-sample) value.
let runSamples: [Double] = $run.calculatedSamples(graph: graph, count: count).first
@@ -551,7 +618,7 @@ public enum RecordBuffer {
let existing: Double = buffer[writePos, 0]
buffer.write(recVal * inputVal + preVal * existing, frame: writePos, channel: 0)
writePos += 1
if writePos >= buffer.count {
if writePos >= buffer.loopLength {
if loop { writePos = 0 }
else { handleEndOfBuffer() }
}
@@ -10,7 +10,9 @@ import Darwin
///
/// Accumulates samples into a ring buffer and re-evaluates every `hopSize` samples.
/// Between hops the output holds the previous result — frequency stabilises after
/// one or two hops (~46 ms at the default settings and 44100 Hz sample rate).
/// one or two hops (~46 ms at the default settings, `decimation: 1`, and 44100 Hz sample
/// rate). Settle time scales with `decimation` (each hop spans `decimation×` more
/// wall-clock time), so `decimation: 4` stabilises in ~184 ms.
///
/// ## Output
/// Returns a two-channel buffer:
@@ -19,10 +21,13 @@ import Darwin
///
/// ## Parameters
/// - `in`: signal to analyse (Audio-rate input evaluated per sample)
/// - `fftSize`: analysis window in samples (must be power of 2, set at init)
/// - `hopSize`: samples between re-analyses (set at init; default `fftSize / 2`)
/// - `fftSize`: analysis window in **decimated** samples (must be power of 2, set at init)
/// - `hopSize`: decimated samples between re-analyses (set at init; default `fftSize / 2`)
/// - `minFreq`: lower search bound in Hz (default 60.0)
/// - `maxFreq`: upper search bound in Hz (default 3000.0)
/// - `decimation`: keep only every Nth input sample before analysis (default `1`), lowering
/// the effective rate to `sampleRate / decimation` to reach lower fundamentals. Caller must
/// band-limit below the decimated Nyquist first. See the `init` doc for full detail.
///
/// ## Usage
/// ```swift
@@ -62,6 +67,7 @@ public final class FreqTracker: GeneratorBase, AudioGenerator {
private let _hopSize: Int
private let _minFreq: Double
private let _maxFreq: Double
private let _decimation: Int
// MARK: - Input
@@ -82,6 +88,11 @@ public final class FreqTracker: GeneratorBase, AudioGenerator {
private var _lastFreq: Double = 0.0
private var _lastConfidence: Double = 0.0
// Counts raw input samples toward the next decimated (stored) sample. Only every
// `_decimation`-th input sample is written into the ring; the ring/hop machinery then
// operates entirely in the decimated time base.
private var _decimationCounter: Int = 0
// MARK: - Output
// MARK: - Fan-out cache
@@ -89,18 +100,32 @@ public final class FreqTracker: GeneratorBase, AudioGenerator {
/// - Parameters:
/// - input: Signal to track.
/// - fftSize: Analysis window in samples. Power of 2 in [64, 512]. Default 512.
/// Larger values increase latency and YIN cost (O(halfSize²) per hop);
/// 512 gives ~5.8 ms at 44100 Hz and is the maximum RT-safe value.
/// - hopSize: Samples between analysis updates. Default `fftSize / 2`.
/// - fftSize: Analysis window in **decimated** samples. Power of 2 in [64, 512].
/// Default 512. Larger values increase latency and YIN cost (O(halfSize²)
/// per hop); 512 gives ~5.8 ms at 44100 Hz and is the maximum RT-safe value.
/// - hopSize: Decimated samples between analysis updates. Default `fftSize / 2`.
/// - minFreq: Minimum tracked frequency in Hz. Default 60.0.
/// - maxFreq: Maximum tracked frequency in Hz. Default 3000.0.
/// - decimation: Keep only every `decimation`-th input sample before analysis, lowering
/// the effective sample rate to `sampleRate / decimation`. Default `1` (no
/// decimation — original behaviour). A 512-sample window can then span
/// `decimation ×` more time, extending the **minimum** detectable frequency
/// down to roughly `sampleRate / (decimation × (fftSize/2 − 1))` while keeping
/// YIN's O(halfSize²) cost fixed — ideal for low-pitched monophonic sources
/// (bass, low guitar strings) where high-frequency resolution isn't needed.
/// **The caller must band-limit the input below the decimated Nyquist
/// (`sampleRate / (2 × decimation)`) first** — decimation does no anti-alias
/// filtering of its own. The `maxFreq` search bound must also stay below that
/// decimated Nyquist. Latency to a stable reading scales with `decimation`
/// (each hop spans `decimation×` more wall-clock time), so `decimation: 4`
/// settles in ~4× the undecimated hop-based time.
public init(
in input: any ValidGeneratorInput,
fftSize: Int = 512,
hopSize: Int? = nil,
minFreq: Double = 60.0,
maxFreq: Double = 3000.0
maxFreq: Double = 3000.0,
decimation: Int = 1
) {
precondition(fftSize >= 64 && fftSize <= 512 && (fftSize & (fftSize - 1)) == 0,
"FreqTracker: fftSize must be a power of 2 in [64, 512]; got \(fftSize). "
@@ -108,6 +133,8 @@ public final class FreqTracker: GeneratorBase, AudioGenerator {
+ "Reduce fftSize or implement background-thread YIN in a future phase.")
precondition(minFreq > 0 && maxFreq > minFreq,
"FreqTracker: minFreq must be > 0 and < maxFreq")
precondition(decimation >= 1,
"FreqTracker: decimation must be >= 1; got \(decimation).")
_fftSize = fftSize
_hopSize = hopSize ?? fftSize / 2
@@ -119,6 +146,7 @@ public final class FreqTracker: GeneratorBase, AudioGenerator {
+ "Larger values cause the YIN window to read stale data.")
_minFreq = minFreq
_maxFreq = maxFreq
_decimation = decimation
let resolvedInput: any ValidGeneratorInput = input._resolvedInput()
_input = resolvedInput
_inputRing = [Double](repeating: 0.0, count: fftSize)
@@ -135,16 +163,23 @@ public final class FreqTracker: GeneratorBase, AudioGenerator {
_checkCount(count)
let sr: Double = graph.engine.sampleRate
// Analysis runs in the decimated time base: the ring holds every `_decimation`-th
// input sample, so lag→frequency conversion uses the decimated effective rate.
let effectiveRate: Double = sr / Double(_decimation)
let inputSamples: [[Double]] = _input.calculatedSamples(graph: graph, count: count)
guard let ins: [Double] = inputSamples.first else {
// No input — advance ring with zeros, still fire hops so state advances correctly.
for _ in 0..<count {
_inputRing[_ringPos % _fftSize] = 0.0
_ringPos &+= 1
_samplesUntilHop -= 1
if _samplesUntilHop <= 0 {
_samplesUntilHop = _hopSize
_runYIN(sampleRate: sr)
_decimationCounter &+= 1
if _decimationCounter >= _decimation {
_decimationCounter = 0
_inputRing[_ringPos % _fftSize] = 0.0
_ringPos &+= 1
_samplesUntilHop -= 1
if _samplesUntilHop <= 0 {
_samplesUntilHop = _hopSize
_runYIN(sampleRate: effectiveRate)
}
}
}
for i: Int in 0..<count {
@@ -155,15 +190,21 @@ public final class FreqTracker: GeneratorBase, AudioGenerator {
}
for i: Int in 0..<count {
// Write incoming sample into ring buffer.
let sample: Double = Double(ins[i])
_inputRing[_ringPos % _fftSize] = sample
_ringPos &+= 1
// Write every `_decimation`-th incoming sample into the ring buffer. Naive
// decimation (take-every-Nth) is correct because the caller band-limits below
// the decimated Nyquist — see the `decimation` parameter docs.
_decimationCounter &+= 1
if _decimationCounter >= _decimation {
_decimationCounter = 0
let sample: Double = Double(ins[i])
_inputRing[_ringPos % _fftSize] = sample
_ringPos &+= 1
_samplesUntilHop -= 1
if _samplesUntilHop <= 0 {
_samplesUntilHop = _hopSize
_runYIN(sampleRate: sr)
_samplesUntilHop -= 1
if _samplesUntilHop <= 0 {
_samplesUntilHop = _hopSize
_runYIN(sampleRate: effectiveRate)
}
}
_result[0][i] = _lastFreq
_result[1][i] = _lastConfidence
@@ -0,0 +1,62 @@
// DbAmp.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
// MARK: - DbAmp
/// Converts a decibel value to a linear amplitude multiplier: `10^(dB / 20)`.
///
/// Control-rate only — intended for live gain knobs authored in dB (e.g. a pedal's
/// output-level control) that need to drive another generator's linear gain input
/// every block. Wraps the scalar ``dbToAmp(_:)`` helper so the conversion formula
/// lives in one place.
///
/// - Parameter signal: Input value in decibels.
public enum DbAmp {
public class _Base: GeneratorBase {
let inputSource: any ValidGeneratorInput
let _mulAdd: MulAddSpec
public init(
_ signal: any ValidGeneratorInput,
mul: any ValidGeneratorInput = 1.0,
add: any ValidGeneratorInput = 0.0
) {
let resolvedSignal: any ValidGeneratorInput = signal._resolvedInput()
inputSource = resolvedSignal
_mulAdd = MulAddSpec(mul: mul, add: add)
}
}
/// - Parameters:
/// - signal: Input value in decibels.
/// - mul: Output multiplier. Defaults to `1.0`.
/// - add: Output offset. Defaults to `0.0`.
public final class Control: _Base, ControlGenerator {
public var previousOutputValue: Double = 0.0
/// - Parameters:
/// - signal: Input value in decibels.
/// - mul: Output multiplier. Defaults to `1.0`.
/// - add: Output offset. Defaults to `0.0`.
public override init(
_ signal: any ValidGeneratorInput,
mul: any ValidGeneratorInput = 1.0,
add: any ValidGeneratorInput = 0.0
) { super.init(signal, mul: mul, add: add); _setupSubBlockBuffer() }
public func _computeSamples(
graph: SynthGraph,
count: Int
) -> [[Double]] {
_checkCount(count)
var target: Double = dbToAmp(inputSource.floatValue(graph: graph))
if !_mulAdd.isIdentity {
target = target * _mulAdd.mulInput.floatValue(graph: graph) + _mulAdd.addInput.floatValue(graph: graph)
}
fillScalarRampedResult(into: &_result, previousOutputValue: &previousOutputValue, target: target, count: count)
return _result
}
}
}
+2 -16
View File
@@ -18,13 +18,10 @@ public enum CLICommand: Equatable {
/// When `lyrebirdPath` is set, the generated `Package.swift` and (where
/// applicable) `.xcodeproj` reference Lyrebird as a local SPM package at
/// that absolute path instead of pulling from the published Git URL.
/// When `shoegazePath` is set (shoegaze template only), the ShoeGaze
/// package is wired as a local SPM dependency at that absolute path.
case new(
name: String,
template: ProjectTemplate,
lyrebirdPath: String?,
shoegazePath: String?
lyrebirdPath: String?
)
/// Run the current project with `swift run`.
case run(release: Bool)
@@ -76,21 +73,10 @@ public enum CLICommand: Equatable {
} else {
lyrebirdPath = nil
}
// Optional `--shoegaze-path <abs-path>` for shoegaze template only.
// Value must not be a flag token.
let shoegazePath: String?
if let sIdx: Array<String>.Index = arguments.firstIndex(of: "--shoegaze-path"),
sIdx + 1 < arguments.count,
!arguments[sIdx + 1].hasPrefix("-") {
shoegazePath = arguments[sIdx + 1]
} else {
shoegazePath = nil
}
return .new(
name: arguments[2],
template: template,
lyrebirdPath: lyrebirdPath,
shoegazePath: shoegazePath
lyrebirdPath: lyrebirdPath
)
case "run":
+4 -31
View File
@@ -25,8 +25,8 @@ struct LyrebirdCLIMain {
print("lyrebird \(lyrebirdVersion)")
case .help:
printHelp()
case .new(let name, let template, let lyrebirdPath, let shoegazePath):
runNew(name: name, template: template, lyrebirdPath: lyrebirdPath, shoegazePath: shoegazePath)
case .new(let name, let template, let lyrebirdPath):
runNew(name: name, template: template, lyrebirdPath: lyrebirdPath)
case .run(let release):
runProject(release: release)
case .export(let name, let toPath, let overwrite):
@@ -106,8 +106,7 @@ struct LyrebirdCLIMain {
private static func runNew(
name: String,
template: ProjectTemplate,
lyrebirdPath: String?,
shoegazePath: String? = nil
lyrebirdPath: String?
) {
let resolvedPath: String?
if let p: String = lyrebirdPath {
@@ -131,33 +130,11 @@ struct LyrebirdCLIMain {
""", stderr)
}
// Resolve ShoeGaze path (shoegaze template only).
let resolvedShoegazePath: String?
if let p: String = shoegazePath {
resolvedShoegazePath = URL(fileURLWithPath: p).standardizedFileURL.path
} else {
resolvedShoegazePath = nil
}
if template == .shoegaze || template == .shoegazeIOS {
if let path: String = resolvedShoegazePath {
print("ShoeGaze dependency: local checkout at \(path)")
} else {
fputs("""
note: --shoegaze-path not supplied; the generated project will use \
the placeholder URL \(ProjectScaffolder.shoegazePackageURL). \
Edit the project or re-run with --shoegaze-path <path to ShoeGaze checkout> \
until ShoeGaze is published at that URL.
""", stderr)
}
}
do {
try ProjectScaffolder.scaffold(
name: name,
template: template,
lyrebirdPath: effectivePath,
shoegazePath: resolvedShoegazePath
lyrebirdPath: effectivePath
)
print("Created \(name)/")
} catch ProjectScaffolder.Error.projectExists(let n) {
@@ -222,8 +199,6 @@ struct LyrebirdCLIMain {
SPM templates (open Package.swift in Xcode):
basic (default), demo, ui-demo, nrt, score
Xcode-project templates (build to .app or .appex):
shoegaze macOS guitar-pedalboard app (Xcode, .app)
shoegaze-ios iOS guitar-pedalboard app (Xcode, .app)
macos-ui-xcode macOS @UIParam synth app
ios-ui iOS @UIParam synth app
auv3 AUv3 host + .appex
@@ -240,8 +215,6 @@ struct LyrebirdCLIMain {
--template <t> Template name (see above)
--lyrebird-path <path> Use a local Lyrebird checkout instead of the
published remote package URL
--shoegaze-path <path> (shoegaze / shoegaze-ios) Use a local ShoeGaze
checkout instead of the placeholder remote URL
Run `lyrebird` with no arguments for an interactive shell.
""")
@@ -1,526 +0,0 @@
// ProjectScaffolder+ShoeGazeIOS.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import Foundation
// MARK: - shoegaze-ios template
extension ProjectScaffolder {
/// Write the full `shoegaze-ios` template tree at `projectRoot`.
///
/// Single iOS application target. SwiftUI `@main` entry point wired to
/// `iOSAudioDriver` via `AVAudioSession`. Lyrebird + LyrebirdUI +
/// LyrebirdShoeGaze + LyrebirdShoeGazeUI pulled in via SPM dependencies.
/// A default board (Overdrive → Delay → Reverb → Modulation) fed by the
/// built-in test loop is constructed at launch inside an `@Observable`
/// `AppModel`.
static func writeShoeGazeIOSFiles(
name: String,
projectRoot: String,
lyrebirdPath: String?,
shoegazePath: String?,
fm: FileManager
) throws {
let appGroupDir: String = (projectRoot as NSString).appendingPathComponent(name)
let xcodeprojDir: String = (projectRoot as NSString).appendingPathComponent("\(name).xcodeproj")
let schemeDir: String = (xcodeprojDir as NSString)
.appendingPathComponent("xcshareddata/xcschemes")
for dir: String in [appGroupDir, xcodeprojDir, schemeDir] {
do {
try fm.createDirectory(atPath: dir,
withIntermediateDirectories: true,
attributes: nil)
} catch {
try? fm.removeItem(atPath: projectRoot)
throw Error.fileSystemError(path: dir, reason: error.localizedDescription)
}
}
let files: [(String, String)] = [
((appGroupDir as NSString).appendingPathComponent("Info.plist"),
iOSAppInfoPlist(name: name)),
((appGroupDir as NSString).appendingPathComponent("\(name)App.swift"),
shoegazeIOSAppSwift(name: name)),
((appGroupDir as NSString).appendingPathComponent("\(name)AppModel.swift"),
shoegazeIOSAppModelSwift(name: name)),
((xcodeprojDir as NSString).appendingPathComponent("project.pbxproj"),
shoegazeIOSPBXProj(name: name,
lyrebirdPath: lyrebirdPath,
shoegazePath: shoegazePath)),
((schemeDir as NSString).appendingPathComponent("\(name).xcscheme"),
appScheme(name: name, productExtension: "app")),
]
try writeFiles(files, fm: fm, projectRoot: projectRoot)
}
// MARK: - Source files
/// `<name>App.swift` — SwiftUI `@main` entry point for the shoegaze-ios template.
///
/// Emitted source must not contain the Lyrebird MIT copyright header.
static func shoegazeIOSAppSwift(name: String) -> String {
"""
// \(name) — entry point
import SwiftUI
import LyrebirdShoeGazeUI
@main
struct \(name)App: App {
@State private var model: \(name)AppModel = \(name)AppModel()
var body: some Scene {
WindowGroup {
NavigationStack {
ScrollView {
ShoeGazeView(shoeGaze: model.shoeGaze)
.padding(.horizontal, 12)
}
.navigationTitle("\(name)")
}
.onAppear { model.start() }
.onDisappear { model.stop() }
}
}
}
"""
}
/// `<name>AppModel.swift` — `@Observable` model owning the engine and `ShoeGaze`.
///
/// Emitted source must not contain the Lyrebird MIT copyright header.
static func shoegazeIOSAppModelSwift(name: String) -> String {
let blockSize: Int = scaffoldDefaultBlockSize
let outputChannels: Int = scaffoldDefaultOutputChannels
return """
// \(name)AppModel.swift
import AVFoundation
import Observation
import LyrebirdSynth
import LyrebirdShoeGaze
/// Owns the `SynthesisEngine` and `ShoeGaze` manager for \(name).
///
/// Call `start()` when the root view appears and `stop()` when it disappears.
/// The engine uses the hardware sample rate from `AVAudioSession` so pitch
/// and timing are accurate on all iOS devices.
@Observable
@MainActor
final class \(name)AppModel {
private(set) var shoeGaze: ShoeGaze
private let engine: SynthesisEngine
init() {
// Activate the session before querying `sampleRate` so the
// hardware rate is known (iOS locks to 48 000 Hz on most devices
// regardless of the preferred rate).
let session: AVAudioSession = AVAudioSession.sharedInstance()
try? session.setCategory(.playback, mode: .default)
try? session.setActive(true)
let sampleRate: Double = session.sampleRate
let eng: SynthesisEngine = SynthesisEngine(
blockSize: \(blockSize),
sampleRate: sampleRate,
numOutputChannels: \(outputChannels),
numInputChannels: 0,
driver: iOSAudioDriver()
)
self.engine = eng
self.shoeGaze = ShoeGaze(engine: eng)
do {
let board: PedalBoard = try shoeGaze.addBoard()
try board.add(OverdrivePedal())
try board.add(DelayPedal())
try board.add(ReverbPedal())
try board.add(ModulationPedal())
try shoeGaze.finalizeBoard(board)
} catch {
print("[\(name)] board build failed: \\(error)")
}
}
/// Start the audio engine. Call from `.onAppear`.
func start() {
do {
try engine.start()
} catch {
print("[\(name)] engine.start failed: \\(error)")
}
}
/// Stop the audio engine. Call from `.onDisappear`.
func stop() {
engine.stop()
}
}
"""
}
// MARK: - pbxproj
/// `project.pbxproj` for the `shoegaze-ios` template.
///
/// Identical in structure to the `ios-ui` pbxproj but:
/// - Declares two source files (`<name>App.swift` + `<name>AppModel.swift`)
/// using the `sg`-prefixed UUID constants so they don't collide with the
/// `ios-ui` constants.
/// - References three SPM products: `LyrebirdUI`, `LyrebirdShoeGaze`, and
/// `LyrebirdShoeGazeUI` — the last two from a second package reference
/// pointing at the ShoeGaze package.
static func shoegazeIOSPBXProj(
name: String,
lyrebirdPath: String? = nil,
shoegazePath: String? = nil
) -> String {
let bundleID: String = "\(defaultBundleIdentifierPrefix).\(name)"
let lyrebirdRefLabel: String = pbxPackageReferenceLabel(lyrebirdPath: lyrebirdPath)
let lyrebirdRefSection: String = pbxPackageReferenceSection(lyrebirdPath: lyrebirdPath)
let shoegazeRefLabel: String = shoegazePackageReferenceLabel(shoegazePath: shoegazePath)
let shoegazeRefSection: String = shoegazePackageReferenceSection(shoegazePath: shoegazePath)
return """
// !$*UTF8*$!
{
\tarchiveVersion = 1;
\tclasses = {
\t};
\tobjectVersion = 60;
\tobjects = {
/* Begin PBXBuildFile section */
\t\t\(pbxSGAppFileBuild) /* \(name)App.swift in Sources */ = {isa = PBXBuildFile; fileRef = \(pbxSGAppFileRef) /* \(name)App.swift */; };
\t\t\(pbxSGAppModelBuild) /* \(name)AppModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = \(pbxSGAppModelRef) /* \(name)AppModel.swift */; };
\t\t\(pbxLyrebirdUIFrameworkBuild) /* LyrebirdUI in Frameworks */ = {isa = PBXBuildFile; productRef = \(pbxLyrebirdUIProductDep) /* LyrebirdUI */; };
\t\t\(pbxSGShoeGazeBuild) /* LyrebirdShoeGaze in Frameworks */ = {isa = PBXBuildFile; productRef = \(pbxSGShoeGazeDep) /* LyrebirdShoeGaze */; };
\t\t\(pbxSGShoeGazeUIBuild) /* LyrebirdShoeGazeUI in Frameworks */ = {isa = PBXBuildFile; productRef = \(pbxSGShoeGazeUIDep) /* LyrebirdShoeGazeUI */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
\t\t\(pbxAppProductRef) /* \(name).app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = \(name).app; sourceTree = BUILT_PRODUCTS_DIR; };
\t\t\(pbxInfoPlistRef) /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
\t\t\(pbxSGAppFileRef) /* \(name)App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \(name)App.swift; sourceTree = "<group>"; };
\t\t\(pbxSGAppModelRef) /* \(name)AppModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \(name)AppModel.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
\t\t\(pbxFrameworksPhase) /* Frameworks */ = {
\t\t\tisa = PBXFrameworksBuildPhase;
\t\t\tbuildActionMask = \(pbxBuildActionMask);
\t\t\tfiles = (
\t\t\t\t\(pbxLyrebirdUIFrameworkBuild) /* LyrebirdUI in Frameworks */,
\t\t\t\t\(pbxSGShoeGazeBuild) /* LyrebirdShoeGaze in Frameworks */,
\t\t\t\t\(pbxSGShoeGazeUIBuild) /* LyrebirdShoeGazeUI in Frameworks */,
\t\t\t);
\t\t\trunOnlyForDeploymentPostprocessing = 0;
\t\t};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
\t\t\(pbxMainGroup) = {
\t\t\tisa = PBXGroup;
\t\t\tchildren = (
\t\t\t\t\(pbxAppGroup) /* \(name) */,
\t\t\t\t\(pbxProductsGroup) /* Products */,
\t\t\t);
\t\t\tsourceTree = "<group>";
\t\t};
\t\t\(pbxProductsGroup) /* Products */ = {
\t\t\tisa = PBXGroup;
\t\t\tchildren = (
\t\t\t\t\(pbxAppProductRef) /* \(name).app */,
\t\t\t);
\t\t\tname = Products;
\t\t\tsourceTree = "<group>";
\t\t};
\t\t\(pbxAppGroup) /* \(name) */ = {
\t\t\tisa = PBXGroup;
\t\t\tchildren = (
\t\t\t\t\(pbxSGAppFileRef) /* \(name)App.swift */,
\t\t\t\t\(pbxSGAppModelRef) /* \(name)AppModel.swift */,
\t\t\t\t\(pbxInfoPlistRef) /* Info.plist */,
\t\t\t);
\t\t\tpath = \(name);
\t\t\tsourceTree = "<group>";
\t\t};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
\t\t\(pbxBlueprintIDApp) /* \(name) */ = {
\t\t\tisa = PBXNativeTarget;
\t\t\tbuildConfigurationList = \(pbxAppBuildConfigList) /* Build configuration list for PBXNativeTarget "\(name)" */;
\t\t\tbuildPhases = (
\t\t\t\t\(pbxSourcesPhase) /* Sources */,
\t\t\t\t\(pbxFrameworksPhase) /* Frameworks */,
\t\t\t\t\(pbxResourcesPhase) /* Resources */,
\t\t\t);
\t\t\tbuildRules = (
\t\t\t);
\t\t\tdependencies = (
\t\t\t);
\t\t\tname = \(name);
\t\t\tpackageProductDependencies = (
\t\t\t\t\(pbxLyrebirdUIProductDep) /* LyrebirdUI */,
\t\t\t\t\(pbxSGShoeGazeDep) /* LyrebirdShoeGaze */,
\t\t\t\t\(pbxSGShoeGazeUIDep) /* LyrebirdShoeGazeUI */,
\t\t\t);
\t\t\tproductName = \(name);
\t\t\tproductReference = \(pbxAppProductRef) /* \(name).app */;
\t\t\tproductType = "com.apple.product-type.application";
\t\t};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
\t\t\(pbxRootObject) /* Project object */ = {
\t\t\tisa = PBXProject;
\t\t\tattributes = {
\t\t\t\tBuildIndependentTargetsInParallel = 1;
\t\t\t\tLastSwiftUpdateCheck = 1600;
\t\t\t\tLastUpgradeCheck = 1600;
\t\t\t\tTargetAttributes = {
\t\t\t\t\t\(pbxBlueprintIDApp) = {
\t\t\t\t\t\tCreatedOnToolsVersion = 16.0;
\t\t\t\t\t};
\t\t\t\t};
\t\t\t};
\t\t\tbuildConfigurationList = \(pbxProjectBuildConfigList) /* Build configuration list for PBXProject "\(name)" */;
\t\t\tcompatibilityVersion = "Xcode 14.0";
\t\t\tdevelopmentRegion = en;
\t\t\thasScannedForEncodings = 0;
\t\t\tknownRegions = (
\t\t\t\ten,
\t\t\t\tBase,
\t\t\t);
\t\t\tmainGroup = \(pbxMainGroup);
\t\t\tpackageReferences = (
\t\t\t\t\(pbxRemoteSPMRef) /* \(lyrebirdRefLabel) */,
\t\t\t\t\(pbxSGShoeGazePackageRef) /* \(shoegazeRefLabel) */,
\t\t\t);
\t\t\tproductRefGroup = \(pbxProductsGroup) /* Products */;
\t\t\tprojectDirPath = "";
\t\t\tprojectRoot = "";
\t\t\ttargets = (
\t\t\t\t\(pbxBlueprintIDApp) /* \(name) */,
\t\t\t);
\t\t};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
\t\t\(pbxResourcesPhase) /* Resources */ = {
\t\t\tisa = PBXResourcesBuildPhase;
\t\t\tbuildActionMask = \(pbxBuildActionMask);
\t\t\tfiles = (
\t\t\t);
\t\t\trunOnlyForDeploymentPostprocessing = 0;
\t\t};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
\t\t\(pbxSourcesPhase) /* Sources */ = {
\t\t\tisa = PBXSourcesBuildPhase;
\t\t\tbuildActionMask = \(pbxBuildActionMask);
\t\t\tfiles = (
\t\t\t\t\(pbxSGAppFileBuild) /* \(name)App.swift in Sources */,
\t\t\t\t\(pbxSGAppModelBuild) /* \(name)AppModel.swift in Sources */,
\t\t\t);
\t\t\trunOnlyForDeploymentPostprocessing = 0;
\t\t};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
\t\t\(pbxAppDebugConfig) /* Debug */ = {
\t\t\tisa = XCBuildConfiguration;
\t\t\tbuildSettings = {
\t\t\t\tCODE_SIGN_STYLE = Automatic;
\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;
\t\t\t\tGENERATE_INFOPLIST_FILE = NO;
\t\t\t\tINFOPLIST_FILE = \(name)/Info.plist;
\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 18.0;
\t\t\t\tLD_RUNPATH_SEARCH_PATHS = (
\t\t\t\t\t"$(inherited)",
\t\t\t\t\t"@executable_path/Frameworks",
\t\t\t\t);
\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = \(bundleID);
\t\t\t\tPRODUCT_NAME = "$(TARGET_NAME)";
\t\t\t\tSWIFT_VERSION = 6.0;
\t\t\t\tTARGETED_DEVICE_FAMILY = "1,2";
\t\t\t};
\t\t\tname = Debug;
\t\t};
\t\t\(pbxAppReleaseConfig) /* Release */ = {
\t\t\tisa = XCBuildConfiguration;
\t\t\tbuildSettings = {
\t\t\t\tCODE_SIGN_STYLE = Automatic;
\t\t\t\tDEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
\t\t\t\tGENERATE_INFOPLIST_FILE = NO;
\t\t\t\tINFOPLIST_FILE = \(name)/Info.plist;
\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 18.0;
\t\t\t\tLD_RUNPATH_SEARCH_PATHS = (
\t\t\t\t\t"$(inherited)",
\t\t\t\t\t"@executable_path/Frameworks",
\t\t\t\t);
\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = \(bundleID);
\t\t\t\tPRODUCT_NAME = "$(TARGET_NAME)";
\t\t\t\tSWIFT_VERSION = 6.0;
\t\t\t\tTARGETED_DEVICE_FAMILY = "1,2";
\t\t\t};
\t\t\tname = Release;
\t\t};
\t\t\(pbxProjectDebugConfig) /* Debug */ = {
\t\t\tisa = XCBuildConfiguration;
\t\t\tbuildSettings = {
\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;
\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;
\t\t\t\tCOPY_PHASE_STRIP = NO;
\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;
\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;
\t\t\t\tENABLE_TESTABILITY = YES;
\t\t\t\tENABLE_USER_SCRIPT_SANDBOXING = YES;
\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu17;
\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;
\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;
\t\t\t\tONLY_ACTIVE_ARCH = YES;
\t\t\t\tSDKROOT = iphoneos;
\t\t\t\tSWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = "-Onone";
\t\t\t};
\t\t\tname = Debug;
\t\t};
\t\t\(pbxProjectReleaseConfig) /* Release */ = {
\t\t\tisa = XCBuildConfiguration;
\t\t\tbuildSettings = {
\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;
\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;
\t\t\t\tCOPY_PHASE_STRIP = NO;
\t\t\t\tDEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
\t\t\t\tENABLE_NS_ASSERTIONS = NO;
\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;
\t\t\t\tENABLE_USER_SCRIPT_SANDBOXING = YES;
\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu17;
\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;
\t\t\t\tSDKROOT = iphoneos;
\t\t\t\tSWIFT_COMPILATION_MODE = wholemodule;
\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = "-O";
\t\t\t};
\t\t\tname = Release;
\t\t};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
\t\t\(pbxAppBuildConfigList) /* Build configuration list for PBXNativeTarget "\(name)" */ = {
\t\t\tisa = XCConfigurationList;
\t\t\tbuildConfigurations = (
\t\t\t\t\(pbxAppDebugConfig) /* Debug */,
\t\t\t\t\(pbxAppReleaseConfig) /* Release */,
\t\t\t);
\t\t\tdefaultConfigurationIsVisible = 0;
\t\t\tdefaultConfigurationName = Release;
\t\t};
\t\t\(pbxProjectBuildConfigList) /* Build configuration list for PBXProject "\(name)" */ = {
\t\t\tisa = XCConfigurationList;
\t\t\tbuildConfigurations = (
\t\t\t\t\(pbxProjectDebugConfig) /* Debug */,
\t\t\t\t\(pbxProjectReleaseConfig) /* Release */,
\t\t\t);
\t\t\tdefaultConfigurationIsVisible = 0;
\t\t\tdefaultConfigurationName = Release;
\t\t};
/* End XCConfigurationList section */
\(lyrebirdRefSection)
\(shoegazeRefSection)
/* Begin XCSwiftPackageProductDependency section */
\t\t\(pbxLyrebirdUIProductDep) /* LyrebirdUI */ = {
\t\t\tisa = XCSwiftPackageProductDependency;
\t\t\tpackage = \(pbxRemoteSPMRef) /* \(lyrebirdRefLabel) */;
\t\t\tproductName = LyrebirdUI;
\t\t};
\t\t\(pbxSGShoeGazeDep) /* LyrebirdShoeGaze */ = {
\t\t\tisa = XCSwiftPackageProductDependency;
\t\t\tpackage = \(pbxSGShoeGazePackageRef) /* \(shoegazeRefLabel) */;
\t\t\tproductName = LyrebirdShoeGaze;
\t\t};
\t\t\(pbxSGShoeGazeUIDep) /* LyrebirdShoeGazeUI */ = {
\t\t\tisa = XCSwiftPackageProductDependency;
\t\t\tpackage = \(pbxSGShoeGazePackageRef) /* \(shoegazeRefLabel) */;
\t\t\tproductName = LyrebirdShoeGazeUI;
\t\t};
/* End XCSwiftPackageProductDependency section */
\t};
\trootObject = \(pbxRootObject) /* Project object */;
}
"""
}
// MARK: - ShoeGaze package reference helpers
/// pbxproj snippet for the ShoeGaze SPM package reference. Emits either an
/// `XCRemoteSwiftPackageReference` (when `shoegazePath == nil`) or an
/// `XCLocalSwiftPackageReference` pointing at the absolute path.
static func shoegazePackageReferenceSection(shoegazePath: String?) -> String {
if let path: String = shoegazePath {
let escaped: String = pbxQuoteEscape(path)
return """
/* Begin XCLocalSwiftPackageReference section */
\t\t\(pbxSGShoeGazePackageRef) /* XCLocalSwiftPackageReference "shoegaze" */ = {
\t\t\tisa = XCLocalSwiftPackageReference;
\t\t\trelativePath = "\(escaped)";
\t\t};
/* End XCLocalSwiftPackageReference section */
"""
} else {
return """
/* Begin XCRemoteSwiftPackageReference section */
\t\t\(pbxSGShoeGazePackageRef) /* XCRemoteSwiftPackageReference "shoegaze" */ = {
\t\t\tisa = XCRemoteSwiftPackageReference;
\t\t\trepositoryURL = "\(shoegazePackageURL)";
\t\t\trequirement = {
\t\t\t\tkind = upToNextMajorVersion;
\t\t\t\tminimumVersion = \(shoegazeMinimumVersion);
\t\t\t};
\t\t};
/* End XCRemoteSwiftPackageReference section */
"""
}
}
/// Comment label used in pbxproj for the ShoeGaze package reference.
static func shoegazePackageReferenceLabel(shoegazePath: String?) -> String {
shoegazePath == nil
? #"XCRemoteSwiftPackageReference "shoegaze""#
: #"XCLocalSwiftPackageReference "shoegaze""#
}
// MARK: - shoegaze-ios PBX UUID constants
//
// All UUIDs in the `0x03xx` range — no collision with ios-ui (`0x02xx`),
// macos-ui-xcode (`0x01xx`), or auv3 (`0x03Axx` / `0x03xx` note: auv3
// uses `0x03A0`–`0x03A8`, so shoegaze-ios uses `0x03B0`–`0x03B8`).
/// `<name>App.swift` file reference UUID.
static let pbxSGAppFileRef: String = "AABB000000000000000003B0"
/// `<name>App.swift` build file UUID.
static let pbxSGAppFileBuild: String = "AABB000000000000000003B1"
/// `<name>AppModel.swift` file reference UUID.
static let pbxSGAppModelRef: String = "AABB000000000000000003B2"
/// `<name>AppModel.swift` build file UUID.
static let pbxSGAppModelBuild: String = "AABB000000000000000003B3"
/// Package reference UUID for the ShoeGaze SPM package.
static let pbxSGShoeGazePackageRef: String = "AABB000000000000000003B4"
/// Product dependency UUID for `LyrebirdShoeGaze`.
static let pbxSGShoeGazeDep: String = "AABB000000000000000003B5"
/// Build file UUID for `LyrebirdShoeGaze` in Frameworks.
static let pbxSGShoeGazeBuild: String = "AABB000000000000000003B6"
/// Product dependency UUID for `LyrebirdShoeGazeUI`.
static let pbxSGShoeGazeUIDep: String = "AABB000000000000000003B7"
/// Build file UUID for `LyrebirdShoeGazeUI` in Frameworks.
static let pbxSGShoeGazeUIBuild: String = "AABB000000000000000003B8"
}
@@ -1,610 +0,0 @@
// ProjectScaffolder+ShoeGazeMacOS.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import Foundation
// MARK: - shoegaze (macOS Xcode app) template
extension ProjectScaffolder {
/// Write the full `shoegaze` macOS app template tree at `projectRoot`.
///
/// Single macOS application target. SwiftUI `@main` entry point wired to
/// `CoreAudioDriver`. Lyrebird + LyrebirdUI + LyrebirdShoeGaze +
/// LyrebirdShoeGazeUI pulled in via SPM dependencies. A default board
/// (Overdrive → Delay → Reverb → Modulation) fed by the built-in test loop
/// is constructed at launch inside an `@Observable` `AppModel`.
///
/// An **Audio** menu with **Mute ⌘M** is added via `.commands`. Quit ⌘Q is
/// standard in SwiftUI App and requires no extra code. Recording (Choose
/// Folder / Record / Stop) is already provided by `ShoeGazeView`.
static func writeShoeGazeMacOSFiles(
name: String,
projectRoot: String,
lyrebirdPath: String?,
shoegazePath: String?,
fm: FileManager
) throws {
let appGroupDir: String = (projectRoot as NSString).appendingPathComponent(name)
let xcodeprojDir: String = (projectRoot as NSString).appendingPathComponent("\(name).xcodeproj")
let schemeDir: String = (xcodeprojDir as NSString)
.appendingPathComponent("xcshareddata/xcschemes")
for dir: String in [appGroupDir, xcodeprojDir, schemeDir] {
do {
try fm.createDirectory(atPath: dir,
withIntermediateDirectories: true,
attributes: nil)
} catch {
try? fm.removeItem(atPath: projectRoot)
throw Error.fileSystemError(path: dir, reason: error.localizedDescription)
}
}
let files: [(String, String)] = [
((appGroupDir as NSString).appendingPathComponent("Info.plist"),
shoegazeMacOSInfoPlist(name: name)),
((appGroupDir as NSString).appendingPathComponent("\(name)App.swift"),
shoegazeMacOSAppSwift(name: name)),
((appGroupDir as NSString).appendingPathComponent("\(name)AppModel.swift"),
shoegazeMacOSAppModelSwift(name: name)),
((xcodeprojDir as NSString).appendingPathComponent("project.pbxproj"),
shoegazeMacOSPBXProj(name: name,
lyrebirdPath: lyrebirdPath,
shoegazePath: shoegazePath)),
((schemeDir as NSString).appendingPathComponent("\(name).xcscheme"),
appScheme(name: name, productExtension: "app")),
]
try writeFiles(files, fm: fm, projectRoot: projectRoot)
}
// MARK: - Source files
/// `Info.plist` for the shoegaze macOS app.
///
/// Extends the standard macOS plist with `NSMicrophoneUsageDescription`
/// (required when switching to `.liveInput`), `NSHighResolutionCapable`,
/// and `LSApplicationCategoryType` set to music.
static func shoegazeMacOSInfoPlist(name: String) -> String {
let bundleIdSetting: String = "$(PRODUCT_BUNDLE_IDENTIFIER)"
let bundleNameSetting: String = "$(PRODUCT_NAME)"
let executableNameSetting: String = "$(EXECUTABLE_NAME)"
let deploymentTargetSetting: String = "$(MACOSX_DEPLOYMENT_TARGET)"
return """
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>\(executableNameSetting)</string>
<key>CFBundleIdentifier</key>
<string>\(bundleIdSetting)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>\(bundleNameSetting)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.music</string>
<key>LSMinimumSystemVersion</key>
<string>\(deploymentTargetSetting)</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSMicrophoneUsageDescription</key>
<string>\(name) requires microphone access for live guitar and audio input.</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © \(currentYearString()) \(name). All rights reserved.</string>
</dict>
</plist>
"""
}
/// `<name>App.swift` — SwiftUI `@main` entry point for the shoegaze macOS template.
///
/// Emitted source must not contain the Lyrebird MIT copyright header.
static func shoegazeMacOSAppSwift(name: String) -> String {
"""
// \(name) — entry point
import SwiftUI
import LyrebirdShoeGazeUI
@main
struct \(name)App: App {
@State private var model: \(name)AppModel = \(name)AppModel()
var body: some Scene {
WindowGroup {
ShoeGazeView(shoeGaze: model.shoeGaze)
.frame(minWidth: 960, minHeight: 480)
.onAppear { model.start() }
.onDisappear { model.stop() }
}
.commands {
CommandMenu("Audio") {
Button(model.muted ? "Unmute" : "Mute") {
model.toggleMute()
}
.keyboardShortcut("m", modifiers: .command)
}
}
}
}
"""
}
/// `<name>AppModel.swift` — `@Observable` model owning the engine and `ShoeGaze`.
///
/// Emitted source must not contain the Lyrebird MIT copyright header.
static func shoegazeMacOSAppModelSwift(name: String) -> String {
let blockSize: Int = scaffoldDefaultBlockSize
let sampleRate: Double = 48_000.0
let outputChannels: Int = scaffoldDefaultOutputChannels
let audioBusCount: Int = 256
return """
// \(name)AppModel.swift
import Observation
import LyrebirdSynth
import LyrebirdShoeGaze
/// Owns the `SynthesisEngine` and `ShoeGaze` manager for \(name).
///
/// Call `start()` when the root view appears and `stop()` when it disappears.
/// `toggleMute()` stops and restarts the engine, providing a click-free
/// silence while parameters remain live.
@Observable
@MainActor
final class \(name)AppModel {
private(set) var shoeGaze: ShoeGaze
private(set) var muted: Bool = false
private let engine: SynthesisEngine
init() {
let eng: SynthesisEngine = SynthesisEngine(
blockSize: \(blockSize),
sampleRate: \(sampleRate),
numOutputChannels: \(outputChannels),
numInputChannels: 0,
numAudioBuses: \(audioBusCount),
driver: CoreAudioDriver()
)
self.engine = eng
self.shoeGaze = ShoeGaze(engine: eng)
do {
let board: PedalBoard = try shoeGaze.addBoard()
try board.add(OverdrivePedal())
try board.add(DelayPedal())
try board.add(ReverbPedal())
try board.add(ModulationPedal())
try shoeGaze.finalizeBoard(board)
} catch {
print("[\(name)] board build failed: \\(error)")
}
}
/// Start the audio engine. Call from `.onAppear`.
func start() {
guard !muted else { return }
do {
try engine.start()
} catch {
print("[\(name)] engine.start failed: \\(error)")
}
}
/// Stop the audio engine. Call from `.onDisappear`.
func stop() {
engine.stop()
}
/// Toggle mute by stopping/starting the engine.
func toggleMute() {
if muted {
muted = false
do {
try engine.start()
} catch {
print("[\(name)] engine.start (unmute) failed: \\(error)")
}
} else {
engine.stop()
muted = true
}
}
}
"""
}
// MARK: - pbxproj
/// `project.pbxproj` for the `shoegaze` macOS app template.
///
/// Structure mirrors `shoegazeIOSPBXProj` but uses `SDKROOT = macosx`,
/// `MACOSX_DEPLOYMENT_TARGET = 15.0`, macOS-style `LD_RUNPATH_SEARCH_PATHS`,
/// `ENABLE_HARDENED_RUNTIME`, `COMBINE_HIDPI_IMAGES`, and `DEAD_CODE_STRIPPING`.
/// UUIDs are in the `0x03Cxx` range — no collision with ios-ui (`0x02xx`),
/// macos-ui-xcode (`0x01xx`), auv3 (`0x03Axx`), or shoegaze-ios (`0x03Bxx`).
/// Depends on four SPM products: `Lyrebird`, `LyrebirdUI`, `LyrebirdShoeGaze`,
/// `LyrebirdShoeGazeUI`.
static func shoegazeMacOSPBXProj(
name: String,
lyrebirdPath: String? = nil,
shoegazePath: String? = nil
) -> String {
let bundleID: String = "\(defaultBundleIdentifierPrefix).\(name)"
let lyrebirdRefLabel: String = pbxPackageReferenceLabel(lyrebirdPath: lyrebirdPath)
let lyrebirdRefSection: String = pbxPackageReferenceSection(lyrebirdPath: lyrebirdPath)
let shoegazeRefLabel: String = shoegazeMacOSPackageReferenceLabel(shoegazePath: shoegazePath)
let shoegazeRefSection: String = shoegazeMacOSPackageReferenceSection(shoegazePath: shoegazePath)
return """
// !$*UTF8*$!
{
\tarchiveVersion = 1;
\tclasses = {
\t};
\tobjectVersion = 60;
\tobjects = {
/* Begin PBXBuildFile section */
\t\t\(pbxSGMacAppFileBuild) /* \(name)App.swift in Sources */ = {isa = PBXBuildFile; fileRef = \(pbxSGMacAppFileRef) /* \(name)App.swift */; };
\t\t\(pbxSGMacAppModelBuild) /* \(name)AppModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = \(pbxSGMacAppModelRef) /* \(name)AppModel.swift */; };
\t\t\(pbxSGMacLyrebirdBuild) /* Lyrebird in Frameworks */ = {isa = PBXBuildFile; productRef = \(pbxSGMacLyrebirdDep) /* Lyrebird */; };
\t\t\(pbxLyrebirdUIFrameworkBuild) /* LyrebirdUI in Frameworks */ = {isa = PBXBuildFile; productRef = \(pbxLyrebirdUIProductDep) /* LyrebirdUI */; };
\t\t\(pbxSGMacShoeGazeBuild) /* LyrebirdShoeGaze in Frameworks */ = {isa = PBXBuildFile; productRef = \(pbxSGMacShoeGazeDep) /* LyrebirdShoeGaze */; };
\t\t\(pbxSGMacShoeGazeUIBuild) /* LyrebirdShoeGazeUI in Frameworks */ = {isa = PBXBuildFile; productRef = \(pbxSGMacShoeGazeUIDep) /* LyrebirdShoeGazeUI */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
\t\t\(pbxAppProductRef) /* \(name).app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = \(name).app; sourceTree = BUILT_PRODUCTS_DIR; };
\t\t\(pbxInfoPlistRef) /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
\t\t\(pbxSGMacAppFileRef) /* \(name)App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \(name)App.swift; sourceTree = "<group>"; };
\t\t\(pbxSGMacAppModelRef) /* \(name)AppModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \(name)AppModel.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
\t\t\(pbxFrameworksPhase) /* Frameworks */ = {
\t\t\tisa = PBXFrameworksBuildPhase;
\t\t\tbuildActionMask = \(pbxBuildActionMask);
\t\t\tfiles = (
\t\t\t\t\(pbxSGMacLyrebirdBuild) /* Lyrebird in Frameworks */,
\t\t\t\t\(pbxLyrebirdUIFrameworkBuild) /* LyrebirdUI in Frameworks */,
\t\t\t\t\(pbxSGMacShoeGazeBuild) /* LyrebirdShoeGaze in Frameworks */,
\t\t\t\t\(pbxSGMacShoeGazeUIBuild) /* LyrebirdShoeGazeUI in Frameworks */,
\t\t\t);
\t\t\trunOnlyForDeploymentPostprocessing = 0;
\t\t};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
\t\t\(pbxMainGroup) = {
\t\t\tisa = PBXGroup;
\t\t\tchildren = (
\t\t\t\t\(pbxAppGroup) /* \(name) */,
\t\t\t\t\(pbxProductsGroup) /* Products */,
\t\t\t);
\t\t\tsourceTree = "<group>";
\t\t};
\t\t\(pbxProductsGroup) /* Products */ = {
\t\t\tisa = PBXGroup;
\t\t\tchildren = (
\t\t\t\t\(pbxAppProductRef) /* \(name).app */,
\t\t\t);
\t\t\tname = Products;
\t\t\tsourceTree = "<group>";
\t\t};
\t\t\(pbxAppGroup) /* \(name) */ = {
\t\t\tisa = PBXGroup;
\t\t\tchildren = (
\t\t\t\t\(pbxSGMacAppFileRef) /* \(name)App.swift */,
\t\t\t\t\(pbxSGMacAppModelRef) /* \(name)AppModel.swift */,
\t\t\t\t\(pbxInfoPlistRef) /* Info.plist */,
\t\t\t);
\t\t\tpath = \(name);
\t\t\tsourceTree = "<group>";
\t\t};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
\t\t\(pbxBlueprintIDApp) /* \(name) */ = {
\t\t\tisa = PBXNativeTarget;
\t\t\tbuildConfigurationList = \(pbxAppBuildConfigList) /* Build configuration list for PBXNativeTarget "\(name)" */;
\t\t\tbuildPhases = (
\t\t\t\t\(pbxSourcesPhase) /* Sources */,
\t\t\t\t\(pbxFrameworksPhase) /* Frameworks */,
\t\t\t\t\(pbxResourcesPhase) /* Resources */,
\t\t\t);
\t\t\tbuildRules = (
\t\t\t);
\t\t\tdependencies = (
\t\t\t);
\t\t\tname = \(name);
\t\t\tpackageProductDependencies = (
\t\t\t\t\(pbxSGMacLyrebirdDep) /* Lyrebird */,
\t\t\t\t\(pbxLyrebirdUIProductDep) /* LyrebirdUI */,
\t\t\t\t\(pbxSGMacShoeGazeDep) /* LyrebirdShoeGaze */,
\t\t\t\t\(pbxSGMacShoeGazeUIDep) /* LyrebirdShoeGazeUI */,
\t\t\t);
\t\t\tproductName = \(name);
\t\t\tproductReference = \(pbxAppProductRef) /* \(name).app */;
\t\t\tproductType = "com.apple.product-type.application";
\t\t};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
\t\t\(pbxRootObject) /* Project object */ = {
\t\t\tisa = PBXProject;
\t\t\tattributes = {
\t\t\t\tBuildIndependentTargetsInParallel = 1;
\t\t\t\tLastSwiftUpdateCheck = 1600;
\t\t\t\tLastUpgradeCheck = 1600;
\t\t\t\tTargetAttributes = {
\t\t\t\t\t\(pbxBlueprintIDApp) = {
\t\t\t\t\t\tCreatedOnToolsVersion = 16.0;
\t\t\t\t\t};
\t\t\t\t};
\t\t\t};
\t\t\tbuildConfigurationList = \(pbxProjectBuildConfigList) /* Build configuration list for PBXProject "\(name)" */;
\t\t\tcompatibilityVersion = "Xcode 14.0";
\t\t\tdevelopmentRegion = en;
\t\t\thasScannedForEncodings = 0;
\t\t\tknownRegions = (
\t\t\t\ten,
\t\t\t\tBase,
\t\t\t);
\t\t\tmainGroup = \(pbxMainGroup);
\t\t\tpackageReferences = (
\t\t\t\t\(pbxRemoteSPMRef) /* \(lyrebirdRefLabel) */,
\t\t\t\t\(pbxSGMacShoeGazePackageRef) /* \(shoegazeRefLabel) */,
\t\t\t);
\t\t\tproductRefGroup = \(pbxProductsGroup) /* Products */;
\t\t\tprojectDirPath = "";
\t\t\tprojectRoot = "";
\t\t\ttargets = (
\t\t\t\t\(pbxBlueprintIDApp) /* \(name) */,
\t\t\t);
\t\t};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
\t\t\(pbxResourcesPhase) /* Resources */ = {
\t\t\tisa = PBXResourcesBuildPhase;
\t\t\tbuildActionMask = \(pbxBuildActionMask);
\t\t\tfiles = (
\t\t\t);
\t\t\trunOnlyForDeploymentPostprocessing = 0;
\t\t};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
\t\t\(pbxSourcesPhase) /* Sources */ = {
\t\t\tisa = PBXSourcesBuildPhase;
\t\t\tbuildActionMask = \(pbxBuildActionMask);
\t\t\tfiles = (
\t\t\t\t\(pbxSGMacAppFileBuild) /* \(name)App.swift in Sources */,
\t\t\t\t\(pbxSGMacAppModelBuild) /* \(name)AppModel.swift in Sources */,
\t\t\t);
\t\t\trunOnlyForDeploymentPostprocessing = 0;
\t\t};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
\t\t\(pbxAppDebugConfig) /* Debug */ = {
\t\t\tisa = XCBuildConfiguration;
\t\t\tbuildSettings = {
\t\t\t\tCODE_SIGN_STYLE = Automatic;
\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;
\t\t\t\tDEAD_CODE_STRIPPING = YES;
\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;
\t\t\t\tENABLE_HARDENED_RUNTIME = YES;
\t\t\t\tGENERATE_INFOPLIST_FILE = NO;
\t\t\t\tINFOPLIST_FILE = \(name)/Info.plist;
\t\t\t\tLD_RUNPATH_SEARCH_PATHS = (
\t\t\t\t\t"$(inherited)",
\t\t\t\t\t"@executable_path/../Frameworks",
\t\t\t\t);
\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 15.0;
\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = \(bundleID);
\t\t\t\tPRODUCT_NAME = "$(TARGET_NAME)";
\t\t\t\tSWIFT_VERSION = 6.0;
\t\t\t};
\t\t\tname = Debug;
\t\t};
\t\t\(pbxAppReleaseConfig) /* Release */ = {
\t\t\tisa = XCBuildConfiguration;
\t\t\tbuildSettings = {
\t\t\t\tCODE_SIGN_STYLE = Automatic;
\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;
\t\t\t\tDEAD_CODE_STRIPPING = YES;
\t\t\t\tDEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
\t\t\t\tENABLE_HARDENED_RUNTIME = YES;
\t\t\t\tGENERATE_INFOPLIST_FILE = NO;
\t\t\t\tINFOPLIST_FILE = \(name)/Info.plist;
\t\t\t\tLD_RUNPATH_SEARCH_PATHS = (
\t\t\t\t\t"$(inherited)",
\t\t\t\t\t"@executable_path/../Frameworks",
\t\t\t\t);
\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 15.0;
\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = \(bundleID);
\t\t\t\tPRODUCT_NAME = "$(TARGET_NAME)";
\t\t\t\tSWIFT_VERSION = 6.0;
\t\t\t};
\t\t\tname = Release;
\t\t};
\t\t\(pbxProjectDebugConfig) /* Debug */ = {
\t\t\tisa = XCBuildConfiguration;
\t\t\tbuildSettings = {
\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;
\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;
\t\t\t\tCOPY_PHASE_STRIP = NO;
\t\t\t\tDEAD_CODE_STRIPPING = YES;
\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;
\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;
\t\t\t\tENABLE_TESTABILITY = YES;
\t\t\t\tENABLE_USER_SCRIPT_SANDBOXING = YES;
\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu17;
\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;
\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;
\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (
\t\t\t\t\t"DEBUG=1",
\t\t\t\t\t"$(inherited)",
\t\t\t\t);
\t\t\t\tONLY_ACTIVE_ARCH = YES;
\t\t\t\tSDKROOT = macosx;
\t\t\t\tSWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = "-Onone";
\t\t\t};
\t\t\tname = Debug;
\t\t};
\t\t\(pbxProjectReleaseConfig) /* Release */ = {
\t\t\tisa = XCBuildConfiguration;
\t\t\tbuildSettings = {
\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;
\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;
\t\t\t\tCOPY_PHASE_STRIP = NO;
\t\t\t\tDEAD_CODE_STRIPPING = YES;
\t\t\t\tDEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
\t\t\t\tENABLE_NS_ASSERTIONS = NO;
\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;
\t\t\t\tENABLE_USER_SCRIPT_SANDBOXING = YES;
\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu17;
\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;
\t\t\t\tSDKROOT = macosx;
\t\t\t\tSWIFT_COMPILATION_MODE = wholemodule;
\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = "-O";
\t\t\t};
\t\t\tname = Release;
\t\t};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
\t\t\(pbxAppBuildConfigList) /* Build configuration list for PBXNativeTarget "\(name)" */ = {
\t\t\tisa = XCConfigurationList;
\t\t\tbuildConfigurations = (
\t\t\t\t\(pbxAppDebugConfig) /* Debug */,
\t\t\t\t\(pbxAppReleaseConfig) /* Release */,
\t\t\t);
\t\t\tdefaultConfigurationIsVisible = 0;
\t\t\tdefaultConfigurationName = Release;
\t\t};
\t\t\(pbxProjectBuildConfigList) /* Build configuration list for PBXProject "\(name)" */ = {
\t\t\tisa = XCConfigurationList;
\t\t\tbuildConfigurations = (
\t\t\t\t\(pbxProjectDebugConfig) /* Debug */,
\t\t\t\t\(pbxProjectReleaseConfig) /* Release */,
\t\t\t);
\t\t\tdefaultConfigurationIsVisible = 0;
\t\t\tdefaultConfigurationName = Release;
\t\t};
/* End XCConfigurationList section */
\(lyrebirdRefSection)
\(shoegazeRefSection)
/* Begin XCSwiftPackageProductDependency section */
\t\t\(pbxSGMacLyrebirdDep) /* Lyrebird */ = {
\t\t\tisa = XCSwiftPackageProductDependency;
\t\t\tpackage = \(pbxRemoteSPMRef) /* \(lyrebirdRefLabel) */;
\t\t\tproductName = Lyrebird;
\t\t};
\t\t\(pbxLyrebirdUIProductDep) /* LyrebirdUI */ = {
\t\t\tisa = XCSwiftPackageProductDependency;
\t\t\tpackage = \(pbxRemoteSPMRef) /* \(lyrebirdRefLabel) */;
\t\t\tproductName = LyrebirdUI;
\t\t};
\t\t\(pbxSGMacShoeGazeDep) /* LyrebirdShoeGaze */ = {
\t\t\tisa = XCSwiftPackageProductDependency;
\t\t\tpackage = \(pbxSGMacShoeGazePackageRef) /* \(shoegazeRefLabel) */;
\t\t\tproductName = LyrebirdShoeGaze;
\t\t};
\t\t\(pbxSGMacShoeGazeUIDep) /* LyrebirdShoeGazeUI */ = {
\t\t\tisa = XCSwiftPackageProductDependency;
\t\t\tpackage = \(pbxSGMacShoeGazePackageRef) /* \(shoegazeRefLabel) */;
\t\t\tproductName = LyrebirdShoeGazeUI;
\t\t};
/* End XCSwiftPackageProductDependency section */
\t};
\trootObject = \(pbxRootObject) /* Project object */;
}
"""
}
// MARK: - ShoeGaze macOS package reference helpers
/// pbxproj snippet for the ShoeGaze SPM package reference in the macOS template.
/// Uses the macOS-specific `pbxSGMacShoeGazePackageRef` UUID so it doesn't
/// collide with the iOS template's `pbxSGShoeGazePackageRef`.
static func shoegazeMacOSPackageReferenceSection(shoegazePath: String?) -> String {
if let path: String = shoegazePath {
let escaped: String = pbxQuoteEscape(path)
return """
/* Begin XCLocalSwiftPackageReference section */
\t\t\(pbxSGMacShoeGazePackageRef) /* XCLocalSwiftPackageReference "shoegaze" */ = {
\t\t\tisa = XCLocalSwiftPackageReference;
\t\t\trelativePath = "\(escaped)";
\t\t};
/* End XCLocalSwiftPackageReference section */
"""
} else {
return """
/* Begin XCRemoteSwiftPackageReference section */
\t\t\(pbxSGMacShoeGazePackageRef) /* XCRemoteSwiftPackageReference "shoegaze" */ = {
\t\t\tisa = XCRemoteSwiftPackageReference;
\t\t\trepositoryURL = "\(shoegazePackageURL)";
\t\t\trequirement = {
\t\t\t\tkind = upToNextMajorVersion;
\t\t\t\tminimumVersion = \(shoegazeMinimumVersion);
\t\t\t};
\t\t};
/* End XCRemoteSwiftPackageReference section */
"""
}
}
/// Comment label used in pbxproj for the ShoeGaze package reference (macOS variant).
static func shoegazeMacOSPackageReferenceLabel(shoegazePath: String?) -> String {
shoegazePath == nil
? #"XCRemoteSwiftPackageReference "shoegaze""#
: #"XCLocalSwiftPackageReference "shoegaze""#
}
// MARK: - shoegaze macOS PBX UUID constants
//
// All UUIDs in the `0x03Cxx` range — no collision with ios-ui (`0x02xx`),
// macos-ui-xcode (`0x01xx`), auv3 (`0x03Axx`), or shoegaze-ios (`0x03Bxx`).
/// `<name>App.swift` file reference UUID.
static let pbxSGMacAppFileRef: String = "AABB000000000000000003C0"
/// `<name>App.swift` build file UUID.
static let pbxSGMacAppFileBuild: String = "AABB000000000000000003C1"
/// `<name>AppModel.swift` file reference UUID.
static let pbxSGMacAppModelRef: String = "AABB000000000000000003C2"
/// `<name>AppModel.swift` build file UUID.
static let pbxSGMacAppModelBuild: String = "AABB000000000000000003C3"
/// Package reference UUID for the ShoeGaze SPM package (macOS variant).
static let pbxSGMacShoeGazePackageRef: String = "AABB000000000000000003C4"
/// Product dependency UUID for `Lyrebird` (macOS shoegaze needs the core module).
static let pbxSGMacLyrebirdDep: String = "AABB000000000000000003C5"
/// Build file UUID for `Lyrebird` in Frameworks.
static let pbxSGMacLyrebirdBuild: String = "AABB000000000000000003C6"
/// Product dependency UUID for `LyrebirdShoeGaze`.
static let pbxSGMacShoeGazeDep: String = "AABB000000000000000003C7"
/// Build file UUID for `LyrebirdShoeGaze` in Frameworks.
static let pbxSGMacShoeGazeBuild: String = "AABB000000000000000003C8"
/// Product dependency UUID for `LyrebirdShoeGazeUI`.
static let pbxSGMacShoeGazeUIDep: String = "AABB000000000000000003C9"
/// Build file UUID for `LyrebirdShoeGazeUI` in Frameworks.
static let pbxSGMacShoeGazeUIBuild: String = "AABB000000000000000003CA"
}
@@ -17,14 +17,6 @@ extension ProjectScaffolder {
/// Lower bound on the Lyrebird version range — `upToNextMajorVersion`.
public static let lyrebirdMinimumVersion: String = "1.0.0"
/// SPM URL placeholder for the ShoeGaze package. Substituted into
/// generated `Package.swift` when `--shoegaze-path` is omitted.
/// Replace with the real published URL once ShoeGaze is released.
public static let shoegazePackageURL: String = "https://github.com/realizedsound/LyrebirdShoeGaze"
/// Lower bound on the ShoeGaze version range — `upToNextMajorVersion`.
public static let shoegazeMinimumVersion: String = "1.0.0"
/// Bundle identifier prefix used in `PRODUCT_BUNDLE_IDENTIFIER`. The
/// scaffolded value is `<prefix>.<name>`. Users typically rewrite this
/// to their own reverse-DNS before shipping.
+6 -137
View File
@@ -30,20 +30,6 @@ public enum ProjectTemplate: String, CaseIterable, Equatable {
/// AUv3 host `.app` + `aumu` plugin extension wrapping a Lyrebird synth.
/// Generates a full `<name>.xcodeproj` with two targets and entitlements files.
case auv3 = "auv3"
/// macOS guitar-pedalboard starter app built on `LyrebirdShoeGaze`.
/// Generates a full `<name>.xcodeproj` with a SwiftUI `@main App` entry
/// point, an `@Observable` app model wiring `CoreAudioDriver` + `ShoeGaze`,
/// a root `ShoeGazeView`, and an **Audio ▸ Mute ⌘M** menu command.
/// Requires `--shoegaze-path` (or a published ShoeGaze URL) in addition to
/// the normal `--lyrebird-path`.
case shoegaze = "shoegaze"
/// iOS guitar-pedalboard starter app built on `LyrebirdShoeGaze`.
/// Generates a full `<name>.xcodeproj` with a SwiftUI `@main App` entry
/// point, an `@Observable` app model wiring `iOSAudioDriver` +
/// `AVAudioSession` + `ShoeGaze`, and a root `ShoeGazeView`.
/// Requires `--shoegaze-path` (or a published ShoeGaze URL) in addition to
/// the normal `--lyrebird-path`.
case shoegazeIOS = "shoegaze-ios"
/// Case-insensitive init from a raw string. Accepts hyphen-free aliases too.
public init?(string: String) {
@@ -60,10 +46,6 @@ public enum ProjectTemplate: String, CaseIterable, Equatable {
self = .iosUI
case "auv3", "au-v3", "au_v3":
self = .auv3
case "shoegaze", "shoe-gaze", "shoe_gaze":
self = .shoegaze
case "shoegaze-ios", "shoegazeios", "shoegaze_ios":
self = .shoegazeIOS
default: return nil
}
}
@@ -77,7 +59,7 @@ public enum ProjectTemplate: String, CaseIterable, Equatable {
public var shipsXcodeProject: Bool {
switch self {
case .basic, .demo, .uiDemo, .nrt, .score: return false
case .shoegaze, .macosUIXcode, .iosUI, .auv3, .shoegazeIOS: return true
case .macosUIXcode, .iosUI, .auv3: return true
}
}
}
@@ -171,16 +153,12 @@ public enum ProjectScaffolder {
/// *before* calling this (see `LyrebirdCLI.runNew`), so default
/// scaffolds track current `main`; direct library callers get the
/// documented `nil` → remote behaviour.
/// - shoegazePath: Absolute path to a local ShoeGaze checkout. Only
/// consumed by the `shoegaze` template. `nil` → emit a remote-URL
/// placeholder in the generated `Package.swift`.
/// - Throws: `ProjectScaffolder.Error` on name validation failure or file system errors.
public static func scaffold(
name: String,
template: ProjectTemplate = .basic,
in parentDirectory: String = FileManager.default.currentDirectoryPath,
lyrebirdPath: String? = nil,
shoegazePath: String? = nil
lyrebirdPath: String? = nil
) throws {
try validateName(name)
@@ -205,14 +183,12 @@ public enum ProjectScaffolder {
template: template,
projectRoot: projectRoot,
lyrebirdPath: lyrebirdPath,
shoegazePath: shoegazePath,
fm: fm)
} else {
try scaffoldSwiftPackage(name: name,
template: template,
projectRoot: projectRoot,
lyrebirdPath: lyrebirdPath,
shoegazePath: shoegazePath,
fm: fm)
}
}
@@ -224,7 +200,6 @@ public enum ProjectScaffolder {
template: ProjectTemplate,
projectRoot: String,
lyrebirdPath: String?,
shoegazePath: String? = nil,
fm: FileManager
) throws {
let sourcesDir: String = (projectRoot as NSString)
@@ -252,8 +227,7 @@ public enum ProjectScaffolder {
packageManifest(
name: name,
template: template,
lyrebirdPath: lyrebirdPath,
shoegazePath: shoegazePath
lyrebirdPath: lyrebirdPath
)
),
(
@@ -294,7 +268,6 @@ public enum ProjectScaffolder {
template: ProjectTemplate,
projectRoot: String,
lyrebirdPath: String?,
shoegazePath: String? = nil,
fm: FileManager
) throws {
// Every xcode-bearing template ships an `<name>.xcworkspace` that
@@ -321,10 +294,6 @@ public enum ProjectScaffolder {
fm: fm, projectRoot: projectRoot)
switch template {
case .shoegaze:
try writeShoeGazeMacOSFiles(name: name, projectRoot: projectRoot,
lyrebirdPath: lyrebirdPath,
shoegazePath: shoegazePath, fm: fm)
case .macosUIXcode:
try writeMacOSUIXcodeFiles(name: name, projectRoot: projectRoot,
lyrebirdPath: lyrebirdPath, fm: fm)
@@ -334,10 +303,6 @@ public enum ProjectScaffolder {
case .auv3:
try writeAUv3Files(name: name, projectRoot: projectRoot,
lyrebirdPath: lyrebirdPath, fm: fm)
case .shoegazeIOS:
try writeShoeGazeIOSFiles(name: name, projectRoot: projectRoot,
lyrebirdPath: lyrebirdPath,
shoegazePath: shoegazePath, fm: fm)
case .basic, .demo, .uiDemo, .nrt, .score:
// Unreachable — shipsXcodeProject filters these out at dispatch.
try? fm.removeItem(atPath: projectRoot)
@@ -399,14 +364,10 @@ public enum ProjectScaffolder {
/// nil, falls back to the published Git URL (``lyrebirdPackageURL``).
/// Used by `lyrebird new --lyrebird-path` for users who don't yet
/// have access to the public repository.
/// - shoegazePath: When non-nil and template is `.shoegaze`, the
/// ShoeGaze package is declared as a local SPM dependency at this
/// absolute path. When nil, a remote-URL placeholder is emitted.
public static func packageManifest(
name: String,
template: ProjectTemplate = .basic,
lyrebirdPath: String? = nil,
shoegazePath: String? = nil
lyrebirdPath: String? = nil
) -> String {
// byName resolves only when the product name matches the package
// name (`Lyrebird`). Sibling products (`LyrebirdUI`) need the
@@ -418,7 +379,7 @@ public enum ProjectScaffolder {
targetDeps = #""Lyrebird""#
case .uiDemo:
targetDeps = #""Lyrebird", .product(name: "LyrebirdUI", package: "Lyrebird")"#
case .shoegaze, .macosUIXcode, .iosUI, .auv3, .shoegazeIOS:
case .macosUIXcode, .iosUI, .auv3:
// Xcode-bearing templates don't emit a `Package.swift` — dispatch
// never reaches this function for them. Defensive fallthrough.
targetDeps = #""Lyrebird", .product(name: "LyrebirdUI", package: "Lyrebird")"#
@@ -476,7 +437,7 @@ public enum ProjectScaffolder {
case .uiDemo: return mainSwiftUIDemo(name: name)
case .nrt: return mainSwiftNRT(name: name)
case .score: return mainSwiftScore(name: name)
case .shoegaze, .macosUIXcode, .iosUI, .auv3, .shoegazeIOS:
case .macosUIXcode, .iosUI, .auv3:
// Xcode-bearing templates don't emit a `main.swift` under
// `Sources/<name>/`. Dispatch never reaches this function for
// them. Defensive fallthrough to the basic skeleton.
@@ -806,98 +767,6 @@ public enum ProjectScaffolder {
"""
}
// MARK: shoegaze
private static func mainSwiftShoegaze(name: String) -> String {
"""
// \(name) — ShoeGaze guitar pedalboard
import AppKit
// Program entry runs on the main thread; assert main-actor isolation for the
// AppKit bootstrap rather than hopping asynchronously.
MainActor.assumeIsolated {
let app: NSApplication = NSApplication.shared
let delegate: AppDelegate = AppDelegate()
app.setActivationPolicy(.regular)
app.delegate = delegate
app.activate(ignoringOtherApps: true)
app.run()
}
"""
}
/// `AppDelegate.swift` content for a shoegaze project.
public static func shoegazeAppDelegateSwift(name: String) -> String {
let blockSize: Int = scaffoldDefaultBlockSize
let sampleRate: Double = 48_000.0
let outputChannels: Int = scaffoldDefaultOutputChannels
let inputChannels: Int = 0
let windowWidth: Int = 980
let windowHeight: Int = 520
return """
import AppKit
import LyrebirdSynth
import LyrebirdUI
import LyrebirdShoeGaze
import LyrebirdShoeGazeUI
/// Application delegate for \(name).
///
/// Builds a `SynthesisEngine`, a `ShoeGaze` manager, and a default board of
/// four pedals (Overdrive → Delay → Reverb → Modulation) fed by the built-in
/// test loop, then opens a `LyrebirdWindow` hosting `ShoeGazeView`.
@MainActor
final class AppDelegate: NSObject, NSApplicationDelegate {
private let engine: SynthesisEngine
private let shoeGaze: ShoeGaze
private let window: LyrebirdWindow
override init() {
let engine: SynthesisEngine = SynthesisEngine(
blockSize: \(blockSize),
sampleRate: \(sampleRate),
numOutputChannels: \(outputChannels),
numInputChannels: \(inputChannels),
driver: CoreAudioDriver()
)
self.engine = engine
self.shoeGaze = ShoeGaze(engine: engine)
self.window = LyrebirdWindow(
title: "\(name)",
width: \(windowWidth),
height: \(windowHeight)
)
super.init()
}
func applicationDidFinishLaunching(_ notification: Notification) {
do {
let board: PedalBoard = try shoeGaze.addBoard()
try board.add(OverdrivePedal())
try board.add(DelayPedal())
try board.add(ReverbPedal())
try board.add(ModulationPedal())
try shoeGaze.finalizeBoard(board)
} catch {
print("[\(name)] board build failed: \\(error)")
}
window.open {
ShoeGazeView(shoeGaze: shoeGaze)
}
}
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
true
}
func applicationWillTerminate(_ notification: Notification) {
engine.stop()
}
}
"""
}
// MARK: - ui-demo additional files
/// `AppDelegate.swift` content for a ui-demo project.
@@ -1,44 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTD/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Kind</key>
<string>Xcode.IDEKit.TextSubstitutionFileTemplateKind</string>
<key>Platforms</key>
<array>
<string>com.apple.platform.macosx</string>
<string>com.apple.platform.iphoneos</string>
</array>
<key>Description</key>
<string>A ShoeGaze guitar pedal subclassing Pedal. Override effect(_:) to build the processed mono signal and effectKnobs to publish its knobs; the base class handles wet/dry mix, click-free bypass, and output level. Add it to a PedalBoard with board.add(_:).</string>
<key>Summary</key>
<string>ShoeGaze Pedal (Pedal subclass)</string>
<key>SortOrder</key>
<string>13</string>
<key>AllowedTypes</key>
<array>
<string>public.swift-source</string>
</array>
<key>DefaultCompletionName</key>
<string>MyPedal</string>
<key>MainTemplateFile</key>
<string>___FILEBASENAME___.swift</string>
<key>Options</key>
<array>
<dict>
<key>Identifier</key>
<string>productName</string>
<key>Required</key>
<true/>
<key>Name</key>
<string>Pedal name:</string>
<key>Description</key>
<string>Name of the Pedal subclass (also used as the file name).</string>
<key>Type</key>
<string>text</string>
<key>Default</key>
<string>MyPedal</string>
</dict>
</array>
</dict>
</plist>
@@ -1,63 +0,0 @@
//___FILEHEADER___
import LyrebirdSynth
import LyrebirdUI
import LyrebirdShoeGaze
// MARK: - ___FILEBASENAMEASIDENTIFIER___
/// One-line description of the ___FILEBASENAMEASIDENTIFIER___ pedal.
///
/// Subclasses `Pedal`: reads a mono dry signal from its input bus, processes it
/// in `effect(_:)`, and lets the base class apply the wet/dry `mix`, click-free
/// `bypass`, and output `level`. Publish the effect's knobs via `effectKnobs`
/// so `PedalView` renders a control for each one.
///
/// ## Usage
/// ```swift
/// let board = try shoeGaze.addBoard()
/// try board.add(___FILEBASENAMEASIDENTIFIER___())
/// try shoeGaze.finalizeBoard(board)
/// ```
final class ___FILEBASENAMEASIDENTIFIER___: Pedal {
// MARK: - Parameters
/// Effect amount. Range [0, 1].
@UIParam var amount: Double = 0.5
// MARK: - Constants
/// Knob range for `amount`.
private let amountRange: ClosedRange<Double> = 0.0 ... 1.0
// MARK: - Init
init(
inputBus: Int = 0,
outputBus: Int = 0
) {
super.init(name: "___FILEBASENAMEASIDENTIFIER___", inputBus: inputBus, outputBus: outputBus)
}
// MARK: - Effect
/// Build and return the processed **mono** signal. Replace the passthrough below.
///
/// Fold any stereo generator (reverb, chorus) to mono with `SumChannels` before
/// returning. Do not pre-blend with the dry signal — the base class `mix` does that.
override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
// TODO: wire your DSP here, e.g.:
// return SoftClip.Audio(dry, drive: $amount * 10.0 + 1.0)
dry
}
// MARK: - UI knobs
/// Effect-specific knobs shown by `PedalView` before the common Mix / Level knobs.
override var effectKnobs: [PedalKnob] {
[
PedalKnob(label: "Amount", node: $amount, range: amountRange),
]
}
}
+8 -66
View File
@@ -47,27 +47,27 @@ struct CLICommandTests {
// MARK: - new
@Test func newSubcommandParsed() {
#expect(CLICommand.parse(["lyrebird", "new", "MySynth"]) == .new(name: "MySynth", template: .basic, lyrebirdPath: nil, shoegazePath: nil))
#expect(CLICommand.parse(["lyrebird", "new", "MySynth"]) == .new(name: "MySynth", template: .basic, lyrebirdPath: nil))
}
@Test func newWithTemplateDemoParsed() {
#expect(CLICommand.parse(["lyrebird", "new", "MySynth", "--template", "demo"])
== .new(name: "MySynth", template: .demo, lyrebirdPath: nil, shoegazePath: nil))
== .new(name: "MySynth", template: .demo, lyrebirdPath: nil))
}
@Test func newWithTemplateUIDemoParsed() {
#expect(CLICommand.parse(["lyrebird", "new", "MySynth", "--template", "ui-demo"])
== .new(name: "MySynth", template: .uiDemo, lyrebirdPath: nil, shoegazePath: nil))
== .new(name: "MySynth", template: .uiDemo, lyrebirdPath: nil))
}
@Test func newWithTemplateNRTParsed() {
#expect(CLICommand.parse(["lyrebird", "new", "MySynth", "--template", "nrt"])
== .new(name: "MySynth", template: .nrt, lyrebirdPath: nil, shoegazePath: nil))
== .new(name: "MySynth", template: .nrt, lyrebirdPath: nil))
}
@Test func newWithUnknownTemplateFallsBackToBasic() {
#expect(CLICommand.parse(["lyrebird", "new", "MySynth", "--template", "bogus"])
== .new(name: "MySynth", template: .basic, lyrebirdPath: nil, shoegazePath: nil))
== .new(name: "MySynth", template: .basic, lyrebirdPath: nil))
}
@Test func newWithoutNameParsesToHelp() {
@@ -89,8 +89,7 @@ struct CLICommandTests {
"--lyrebird-path", "/Users/josh/Documents/LyrebirdII"
]) == .new(name: "MyPiece",
template: .basic,
lyrebirdPath: "/Users/josh/Documents/LyrebirdII",
shoegazePath: nil))
lyrebirdPath: "/Users/josh/Documents/LyrebirdII"))
}
@Test func newWithTemplateAndLyrebirdPathParsed() {
@@ -100,70 +99,13 @@ struct CLICommandTests {
"--lyrebird-path", "/abs/path"
]) == .new(name: "MyApp",
template: .macosUIXcode,
lyrebirdPath: "/abs/path",
shoegazePath: nil))
lyrebirdPath: "/abs/path"))
}
@Test func newWithoutLyrebirdPathReportsNil() {
#expect(CLICommand.parse([
"lyrebird", "new", "MyPiece"
]) == .new(name: "MyPiece", template: .basic, lyrebirdPath: nil, shoegazePath: nil))
}
// MARK: - shoegaze template
@Test func newWithTemplateShoegaze() {
let cmd: CLICommand = CLICommand.parse(["lyrebird", "new", "MyRig", "--template", "shoegaze"])
#expect(cmd == .new(name: "MyRig", template: .shoegaze, lyrebirdPath: nil, shoegazePath: nil))
}
@Test func newWithShoegazePathParsed() {
let cmd: CLICommand = CLICommand.parse([
"lyrebird", "new", "MyRig",
"--template", "shoegaze",
"--lyrebird-path", "/abs/Lyrebird",
"--shoegaze-path", "/abs/ShoeGaze",
])
#expect(cmd == .new(
name: "MyRig",
template: .shoegaze,
lyrebirdPath: "/abs/Lyrebird",
shoegazePath: "/abs/ShoeGaze"
))
}
@Test func newShoegazeWithoutShoegazePathHasNilShoegazePath() {
let cmd: CLICommand = CLICommand.parse([
"lyrebird", "new", "MyRig",
"--template", "shoegaze",
"--lyrebird-path", "/abs/Lyrebird",
])
#expect(cmd == .new(
name: "MyRig",
template: .shoegaze,
lyrebirdPath: "/abs/Lyrebird",
shoegazePath: nil
))
}
@Test func shoegazePathValueNotConsumedWhenFlagToken() {
// `--shoegaze-path --lyrebird-path /abs/Lyrebird` — the value slot for
// `--shoegaze-path` is `--lyrebird-path` (starts with "-") → shoegazePath = nil.
// `firstIndex(of: "--lyrebird-path")` finds the first occurrence (index 6)
// whose next token is also "--lyrebird-path" (starts with "-") → lyrebirdPath = nil too.
let args: [String] = [
"lyrebird", "new", "MyRig",
"--template", "shoegaze",
"--shoegaze-path", "--lyrebird-path",
"--lyrebird-path", "/abs/Lyrebird",
]
let cmd: CLICommand = CLICommand.parse(args)
#expect(cmd == .new(
name: "MyRig",
template: .shoegaze,
lyrebirdPath: nil,
shoegazePath: nil
))
]) == .new(name: "MyPiece", template: .basic, lyrebirdPath: nil))
}
// MARK: - run
@@ -237,12 +237,6 @@ struct ProjectScaffolderTests {
#expect(ProjectTemplate(string: "iosui") == .iosUI)
#expect(ProjectTemplate(string: "auv3") == .auv3)
#expect(ProjectTemplate(string: "AUV3") == .auv3)
#expect(ProjectTemplate(string: "shoegaze") == .shoegaze)
#expect(ProjectTemplate(string: "shoe-gaze") == .shoegaze)
#expect(ProjectTemplate(string: "SHOEGAZE") == .shoegaze)
#expect(ProjectTemplate(string: "shoegaze-ios") == .shoegazeIOS)
#expect(ProjectTemplate(string: "shoegazeios") == .shoegazeIOS)
#expect(ProjectTemplate(string: "SHOEGAZE-IOS") == .shoegazeIOS)
}
@Test func shipsXcodeProjectClassification() {
@@ -251,244 +245,9 @@ struct ProjectScaffolderTests {
#expect(ProjectTemplate.uiDemo.shipsXcodeProject == false)
#expect(ProjectTemplate.nrt.shipsXcodeProject == false)
#expect(ProjectTemplate.score.shipsXcodeProject == false)
// shoegaze is now an Xcode-bearing template (macOS .app bundle).
#expect(ProjectTemplate.shoegaze.shipsXcodeProject == true)
#expect(ProjectTemplate.macosUIXcode.shipsXcodeProject == true)
#expect(ProjectTemplate.iosUI.shipsXcodeProject == true)
#expect(ProjectTemplate.auv3.shipsXcodeProject == true)
#expect(ProjectTemplate.shoegazeIOS.shipsXcodeProject == true)
}
// MARK: - shoegaze template (macOS Xcode app)
@Test func shoegazeMacOSScaffoldCreatesAllFiles() throws {
let fm: FileManager = FileManager.default
let tmp: String = fm.temporaryDirectory
.appendingPathComponent("LyrebirdScaffolderTest_\(UUID().uuidString)").path
try fm.createDirectory(atPath: tmp, withIntermediateDirectories: true, attributes: nil)
defer { try? fm.removeItem(atPath: tmp) }
try ProjectScaffolder.scaffold(name: "MyRig", template: .shoegaze, in: tmp)
let root: String = (tmp as NSString).appendingPathComponent("MyRig")
let expected: [String] = [
"MyRig.xcodeproj/project.pbxproj",
"MyRig.xcodeproj/xcshareddata/xcschemes/MyRig.xcscheme",
"MyRig.xcworkspace/contents.xcworkspacedata",
"MyRig/MyRigApp.swift",
"MyRig/MyRigAppModel.swift",
"MyRig/Info.plist",
]
for rel: String in expected {
let path: String = (root as NSString).appendingPathComponent(rel)
#expect(fm.fileExists(atPath: path),
"missing shoegaze macOS file: \(rel)")
}
}
@Test func shoegazeMacOSWorkspaceReferencesXcodeproj() throws {
let fm: FileManager = FileManager.default
let tmp: String = fm.temporaryDirectory
.appendingPathComponent("LyrebirdScaffolderTest_\(UUID().uuidString)").path
try fm.createDirectory(atPath: tmp, withIntermediateDirectories: true, attributes: nil)
defer { try? fm.removeItem(atPath: tmp) }
try ProjectScaffolder.scaffold(name: "MyRig", template: .shoegaze, in: tmp)
let workspacePath: String = (tmp as NSString)
.appendingPathComponent("MyRig/MyRig.xcworkspace/contents.xcworkspacedata")
let contents: String = try String(contentsOfFile: workspacePath, encoding: .utf8)
#expect(contents.contains("group:MyRig.xcodeproj"))
}
@Test func shoegazeMacOSAppSwiftContainsShoeGazeView() {
let src: String = ProjectScaffolder.shoegazeMacOSAppSwift(name: "MyRig")
#expect(src.contains("ShoeGazeView"))
#expect(src.contains("import LyrebirdShoeGazeUI"))
#expect(src.contains("@main"))
#expect(src.contains("toggleMute"))
#expect(src.contains(".keyboardShortcut"))
// Must not embed the Lyrebird copyright in emitted user source.
#expect(!src.contains("Joshua Parmenter"))
}
@Test func shoegazeMacOSAppSwiftSubstitutesName() {
let src: String = ProjectScaffolder.shoegazeMacOSAppSwift(name: "GuitarPedals")
#expect(src.contains("GuitarPedalsApp"))
#expect(src.contains("GuitarPedalsAppModel"))
}
@Test func shoegazeMacOSAppModelContainsEngineAndBoard() {
let src: String = ProjectScaffolder.shoegazeMacOSAppModelSwift(name: "MyRig")
#expect(src.contains("import LyrebirdShoeGaze"))
#expect(src.contains("CoreAudioDriver"))
#expect(src.contains("ShoeGaze(engine:"))
#expect(src.contains("OverdrivePedal"))
#expect(src.contains("DelayPedal"))
#expect(src.contains("ReverbPedal"))
#expect(src.contains("ModulationPedal"))
#expect(src.contains("@Observable"))
#expect(src.contains("toggleMute"))
// Must not embed the Lyrebird copyright in emitted user source.
#expect(!src.contains("Joshua Parmenter"))
}
@Test func shoegazeMacOSAppModelSubstitutesName() {
let src: String = ProjectScaffolder.shoegazeMacOSAppModelSwift(name: "GuitarPedals")
#expect(src.contains("GuitarPedalsAppModel"))
#expect(src.contains("GuitarPedals"))
}
@Test func shoegazeMacOSInfoPlistContainsMicrophoneKey() {
let plist: String = ProjectScaffolder.shoegazeMacOSInfoPlist(name: "MyRig")
#expect(plist.contains("NSMicrophoneUsageDescription"))
#expect(plist.contains("LSMinimumSystemVersion"))
#expect(plist.contains("NSHighResolutionCapable"))
#expect(plist.contains("public.app-category.music"))
#expect(plist.contains("NSPrincipalClass"))
}
@Test func shoegazeMacOSPBXProjReferencesMacOSXAndShoeGaze() {
let pbx: String = ProjectScaffolder.shoegazeMacOSPBXProj(name: "MyRig")
#expect(pbx.contains("SDKROOT = macosx"))
#expect(pbx.contains("MACOSX_DEPLOYMENT_TARGET = 15.0"))
#expect(pbx.contains("ENABLE_HARDENED_RUNTIME = YES"))
#expect(pbx.contains("LyrebirdShoeGaze"))
#expect(pbx.contains("LyrebirdShoeGazeUI"))
#expect(pbx.contains("LyrebirdUI"))
#expect(pbx.contains("Lyrebird"))
#expect(pbx.contains(ProjectScaffolder.shoegazePackageURL))
#expect(pbx.contains("MyRig.app"))
}
@Test func shoegazeMacOSPBXProjUsesLocalRefsWhenPathsSet() {
let pbx: String = ProjectScaffolder.shoegazeMacOSPBXProj(
name: "MyRig",
lyrebirdPath: "/abs/Lyrebird",
shoegazePath: "/abs/ShoeGaze"
)
#expect(pbx.contains("XCLocalSwiftPackageReference"))
#expect(pbx.contains(#"relativePath = "/abs/ShoeGaze""#))
#expect(pbx.contains(#"relativePath = "/abs/Lyrebird""#))
#expect(!pbx.contains("XCRemoteSwiftPackageReference"))
}
@Test func shoegazeMacOSPBXProjUsesRemoteRefsWhenPathsNil() {
let pbx: String = ProjectScaffolder.shoegazeMacOSPBXProj(name: "MyRig")
#expect(pbx.contains("XCRemoteSwiftPackageReference"))
#expect(pbx.contains(ProjectScaffolder.shoegazePackageURL))
#expect(pbx.contains(ProjectScaffolder.lyrebirdPackageURL))
}
// MARK: - shoegaze-ios template
@Test func shoegazeIOSScaffoldCreatesAllFiles() throws {
let fm: FileManager = FileManager.default
let tmp: String = fm.temporaryDirectory
.appendingPathComponent("LyrebirdScaffolderTest_\(UUID().uuidString)").path
try fm.createDirectory(atPath: tmp, withIntermediateDirectories: true, attributes: nil)
defer { try? fm.removeItem(atPath: tmp) }
try ProjectScaffolder.scaffold(name: "MyRig", template: .shoegazeIOS, in: tmp)
let root: String = (tmp as NSString).appendingPathComponent("MyRig")
let expected: [String] = [
"MyRig.xcodeproj/project.pbxproj",
"MyRig.xcodeproj/xcshareddata/xcschemes/MyRig.xcscheme",
"MyRig.xcworkspace/contents.xcworkspacedata",
"MyRig/MyRigApp.swift",
"MyRig/MyRigAppModel.swift",
"MyRig/Info.plist",
]
for rel: String in expected {
let path: String = (root as NSString).appendingPathComponent(rel)
#expect(fm.fileExists(atPath: path),
"missing shoegaze-ios file: \(rel)")
}
}
@Test func shoegazeIOSAppSwiftContainsShoeGazeView() {
let src: String = ProjectScaffolder.shoegazeIOSAppSwift(name: "MyRig")
#expect(src.contains("ShoeGazeView"))
#expect(src.contains("import LyrebirdShoeGazeUI"))
#expect(src.contains("@main"))
#expect(src.contains("NavigationStack"))
#expect(src.contains("ScrollView"))
// Must not embed the Lyrebird copyright in emitted user source.
#expect(!src.contains("Joshua Parmenter"))
}
@Test func shoegazeIOSAppSwiftSubstitutesName() {
let src: String = ProjectScaffolder.shoegazeIOSAppSwift(name: "GuitarPedals")
#expect(src.contains("GuitarPedalsApp"))
#expect(src.contains("GuitarPedalsAppModel"))
}
@Test func shoegazeIOSAppModelContainsEngineAndBoard() {
let src: String = ProjectScaffolder.shoegazeIOSAppModelSwift(name: "MyRig")
#expect(src.contains("import LyrebirdShoeGaze"))
#expect(src.contains("iOSAudioDriver"))
#expect(src.contains("AVAudioSession"))
#expect(src.contains("ShoeGaze(engine:"))
#expect(src.contains("OverdrivePedal"))
#expect(src.contains("DelayPedal"))
#expect(src.contains("ReverbPedal"))
#expect(src.contains("ModulationPedal"))
#expect(src.contains("@Observable"))
// Must not embed the Lyrebird copyright in emitted user source.
#expect(!src.contains("Joshua Parmenter"))
}
@Test func shoegazeIOSAppModelSubstitutesName() {
let src: String = ProjectScaffolder.shoegazeIOSAppModelSwift(name: "GuitarPedals")
#expect(src.contains("GuitarPedalsAppModel"))
#expect(src.contains("GuitarPedals"))
}
@Test func shoegazeIOSPBXProjReferencesIPhoneOSAndShoeGaze() {
let pbx: String = ProjectScaffolder.shoegazeIOSPBXProj(name: "MyRig")
#expect(pbx.contains("SDKROOT = iphoneos"))
#expect(pbx.contains("IPHONEOS_DEPLOYMENT_TARGET = 18.0"))
#expect(pbx.contains("TARGETED_DEVICE_FAMILY"))
#expect(pbx.contains("LyrebirdShoeGaze"))
#expect(pbx.contains("LyrebirdShoeGazeUI"))
#expect(pbx.contains("LyrebirdUI"))
#expect(pbx.contains(ProjectScaffolder.shoegazePackageURL))
#expect(pbx.contains("MyRig.app"))
}
@Test func shoegazeIOSPBXProjUsesLocalShoegazeRefWhenPathSet() {
let pbx: String = ProjectScaffolder.shoegazeIOSPBXProj(
name: "MyRig",
lyrebirdPath: "/abs/Lyrebird",
shoegazePath: "/abs/ShoeGaze"
)
#expect(pbx.contains("XCLocalSwiftPackageReference"))
#expect(pbx.contains(#"relativePath = "/abs/ShoeGaze""#))
#expect(pbx.contains(#"relativePath = "/abs/Lyrebird""#))
#expect(!pbx.contains("XCRemoteSwiftPackageReference"))
}
@Test func shoegazeIOSPBXProjUsesRemoteRefWhenPathsNil() {
let pbx: String = ProjectScaffolder.shoegazeIOSPBXProj(name: "MyRig")
#expect(pbx.contains("XCRemoteSwiftPackageReference"))
#expect(pbx.contains(ProjectScaffolder.shoegazePackageURL))
#expect(pbx.contains(ProjectScaffolder.lyrebirdPackageURL))
}
@Test func shoegazeIOSWorkspaceReferencesXcodeproj() throws {
let fm: FileManager = FileManager.default
let tmp: String = fm.temporaryDirectory
.appendingPathComponent("LyrebirdScaffolderTest_\(UUID().uuidString)").path
try fm.createDirectory(atPath: tmp, withIntermediateDirectories: true, attributes: nil)
defer { try? fm.removeItem(atPath: tmp) }
try ProjectScaffolder.scaffold(name: "MyRig", template: .shoegazeIOS, in: tmp)
let workspacePath: String = (tmp as NSString)
.appendingPathComponent("MyRig/MyRig.xcworkspace/contents.xcworkspacedata")
let contents: String = try String(contentsOfFile: workspacePath, encoding: .utf8)
#expect(contents.contains("group:MyRig.xcodeproj"))
}
// MARK: - Xcode-bearing templates: structure
@@ -37,13 +37,6 @@ struct TemplateInstallerTests {
#expect(names.contains("LyrebirdGenerator.xctemplate"))
}
@Test func availableTemplatesIncludesShoeGazePedal() throws {
let names: [String] = try TemplateInstaller.availableTemplates()
// The ShoeGaze Pedal template scaffolds a `Pedal` subclass for the
// guitar-pedalboard sample project.
#expect(names.contains("LyrebirdShoeGazePedal.xctemplate"))
}
// MARK: - Destination URL
@Test func destinationURLIsInHomeLibrary() {
@@ -185,28 +185,4 @@ struct WorkflowIntegrationTests {
#expect(try parseCheck(source: source, fileName: "main.swift"),
"nrt template main.swift must pass swiftc -parse")
}
@Test func shoegazeIOSAppSwiftIsValidSwiftSyntax() throws {
let source: String = ProjectScaffolder.shoegazeIOSAppSwift(name: "MyRig")
#expect(try parseCheck(source: source, fileName: "MyRigApp.swift"),
"shoegaze-ios App.swift must pass swiftc -parse")
}
@Test func shoegazeIOSAppModelSwiftIsValidSwiftSyntax() throws {
let source: String = ProjectScaffolder.shoegazeIOSAppModelSwift(name: "MyRig")
#expect(try parseCheck(source: source, fileName: "MyRigAppModel.swift"),
"shoegaze-ios AppModel.swift must pass swiftc -parse")
}
@Test func shoegazeMacOSAppSwiftIsValidSwiftSyntax() throws {
let source: String = ProjectScaffolder.shoegazeMacOSAppSwift(name: "MyRig")
#expect(try parseCheck(source: source, fileName: "MyRigApp.swift"),
"shoegaze macOS App.swift must pass swiftc -parse")
}
@Test func shoegazeMacOSAppModelSwiftIsValidSwiftSyntax() throws {
let source: String = ProjectScaffolder.shoegazeMacOSAppModelSwift(name: "MyRig")
#expect(try parseCheck(source: source, fileName: "MyRigAppModel.swift"),
"shoegaze macOS AppModel.swift must pass swiftc -parse")
}
}
@@ -114,6 +114,44 @@ struct PlayBufferTests {
engine.stop()
}
// MARK: - loopLength narrowing
@Test func narrowedLoopLengthWrapsWithinBoundNotFullBuffer() throws {
// 32-frame buffer, loopLength narrowed to 8 — loop:true should wrap every
// 8 frames instead of every 32.
let engine: SynthesisEngine = try makeEngine(blockSize: 16)
let graph: SynthGraph = makeSynthGraph(engine: engine)
let buf: LyrebirdBuffer = makeRampBuffer(frames: 32)
let narrowedLength: Int = 8
buf.setLoopLength(narrowedLength)
let player: PlayBuffer.Audio = PlayBuffer.Audio(buffer: buf, loop: true, interpolation: .none)
let out: [[Double]] = player.calculatedSamples(graph: graph, count: 16)
// Frames 0–7 then 0–7 again (loopLength == 8), not 0–15 (full buffer.count).
let expected: [Double] = [0,1,2,3,4,5,6,7, 0,1,2,3,4,5,6,7]
for i: Int in 0..<16 {
#expect(abs(out[0][i] - expected[i]) < 1e-9,
"sample \(i): expected \(expected[i]), got \(out[0][i])")
}
engine.stop()
}
@Test func narrowedLoopLengthClampsWithoutLoop() throws {
// 32-frame buffer, loopLength narrowed to 8, loop:false — non-interpolated reads
// must clamp to loopLength - 1 (frame 7), not buffer.count - 1 (frame 31).
let buf: LyrebirdBuffer = makeRampBuffer(frames: 32)
let narrowedLength: Int = 8
buf.setLoopLength(narrowedLength)
let result: Double = lyrebirdBufferRead(
buf, channel: 0, phase: 100.0, interpolation: .none, loop: false
)
#expect(abs(result - Double(narrowedLength - 1)) < 1e-9,
"clamped read should hold at loopLength-1 (\(narrowedLength - 1)), got \(result)")
}
// MARK: - doneAction
@Test func doneActionFreeNodeSetsNeedsFree() throws {
@@ -450,6 +450,148 @@ struct RecordBufferTests {
#expect(rec.buffer.channelCount == 1)
}
// MARK: - recordedFrameCount
@Test func recordedFrameCountReflectsWritePosAfterStoppingMidBuffer() throws {
// Record 8 frames into a 32-frame buffer, then stop (run = 0), then verify
// recordedFrameCount reflects the frames actually written (8), not the full
// buffer allocation (32) — mirrors a looper pedal reading "how many frames
// were recorded" after calling run = 0.
let engine: SynthesisEngine = try makeEngine(blockSize: 8)
let buf: LyrebirdBuffer = LyrebirdBuffer(count: 32)
let rec: RecordBuffer.Audio = RecordBuffer.Audio(input: 1.0, buffer: buf, loop: false)
#expect(rec.recordedFrameCount == 0, "no frames recorded before first block")
// Block 1: writes 8 frames.
do {
let graph: SynthGraph = makeSynthGraph(engine: engine)
_ = rec.calculatedSamples(graph: graph, count: 8)
}
#expect(rec.recordedFrameCount == 8,
"recordedFrameCount should equal writePos after one block")
advanceBlock(engine)
// Stop recording.
rec.run = 0.0
// Block 2: run ramps toward 0 across the block, so a few more frames may be
// written before the gate fully closes; regardless recordedFrameCount must
// track writePos exactly and stay well short of the full 32-frame buffer.
do {
let graph: SynthGraph = makeSynthGraph(engine: engine)
_ = rec.calculatedSamples(graph: graph, count: 8)
}
#expect(rec.recordedFrameCount > 8, "some frames should be written while run ramps down")
#expect(rec.recordedFrameCount < buf.count, "recording stopped short of the full buffer")
engine.stop()
}
@Test func recordedFrameCountControlVariantTracksWritePos() throws {
let engine: SynthesisEngine = try makeEngine(blockSize: 8)
let buf: LyrebirdBuffer = LyrebirdBuffer(count: 16)
let rec: RecordBuffer.Control = RecordBuffer.Control(input: 1.0, buffer: buf, loop: false)
for blockIdx: Int in 0..<3 {
let graph: SynthGraph = makeSynthGraph(engine: engine)
_ = rec.calculatedSamples(graph: graph, count: 8)
#expect(rec.recordedFrameCount == blockIdx + 1,
"block \(blockIdx): expected recordedFrameCount \(blockIdx + 1)")
advanceBlock(engine)
}
engine.stop()
}
// MARK: - requestReset
@Test func requestResetRestartsWritePosAtNextBlock() throws {
// Simulate a looper "reset" action: record a few frames of one value, call
// requestReset(), then record a new value — the second take must overwrite
// starting at frame 0, not continue from the mid-buffer writePos.
let engine: SynthesisEngine = try makeEngine(blockSize: 8)
let buf: LyrebirdBuffer = LyrebirdBuffer(count: 32)
let rec: RecordBuffer.Audio = RecordBuffer.Audio(input: 1.0, buffer: buf, loop: false)
// First take: 8 frames of 1.0.
do {
let graph: SynthGraph = makeSynthGraph(engine: engine)
_ = rec.calculatedSamples(graph: graph, count: 8)
}
#expect(rec.recordedFrameCount == 8, "first take should write 8 frames")
advanceBlock(engine)
rec.requestReset()
// recLevel is a ParameterNode-backed @LiveParam: it ramps toward its new target
// over one block. Block A (frames 0–7, writePos restarted at 0 by the reset)
// ramps recLevel 1.0→2.0 with varying values; Block B (frames 8–15) records
// with recLevel flat at 2.0 — mirrors the recLevelScalesNewSignal pattern above.
rec.recLevel = 2.0
do {
let graph: SynthGraph = makeSynthGraph(engine: engine)
_ = rec.calculatedSamples(graph: graph, count: 8)
}
#expect(rec.recordedFrameCount == 8,
"reset should restart writePos at 0, so this block again reaches frame count 8")
advanceBlock(engine)
do {
let graph: SynthGraph = makeSynthGraph(engine: engine)
_ = rec.calculatedSamples(graph: graph, count: 8)
}
#expect(rec.recordedFrameCount == 16,
"writePos should continue advancing normally after the reset settles")
for i: Int in 8..<16 {
#expect(abs(buf[i, 0] - 2.0) < 1e-9,
"frame \(i): expected fresh take value 2.0 after reset, got \(buf[i, 0])")
}
for i: Int in 16..<32 {
#expect(buf[i, 0] == 0.0,
"frame \(i): region never reached by either take should remain unwritten")
}
engine.stop()
}
@Test func requestResetClearsDoneAndNeedsFree() throws {
// A prior .freeNode completion (isDone == true, needsFree == true) must be
// fully cleared by requestReset() so the same instance can record again.
let engine: SynthesisEngine = try makeEngine(blockSize: 8)
let buf: LyrebirdBuffer = LyrebirdBuffer(count: 8)
let rec: RecordBuffer.Audio = RecordBuffer.Audio(
input: 1.0,
buffer: buf,
loop: false,
doneAction: .freeNode
)
do {
let graph: SynthGraph = makeSynthGraph(engine: engine)
_ = rec.calculatedSamples(graph: graph, count: 8)
}
#expect(rec.needsFree, "doneAction .freeNode should set needsFree once buffer fills")
advanceBlock(engine)
rec.requestReset()
do {
let graph: SynthGraph = makeSynthGraph(engine: engine)
_ = rec.calculatedSamples(graph: graph, count: 8)
}
// handleEndOfBuffer pins writePos at buffer.count - 1 (matches
// doneActionFreeNodeSetsNeedsFree convention above) rather than buffer.count.
#expect(rec.recordedFrameCount == buf.count - 1,
"recording should resume and refill the buffer after reset")
#expect(rec.needsFree, "recording to the end again should re-trigger needsFree")
engine.stop()
}
// MARK: - Fast-path coverage
/// Default-mode hot path: `recLevel == 1`, `preLevel == 0`, `run == 1`, `loop == true`.
@@ -285,6 +285,55 @@ struct FreqTrackerTests {
#expect(avgFreq > 800.0 && avgFreq < 960.0)
}
}
@Test func decimationEnablesLowFrequencyTracking() {
// Low-E guitar string (E2 ≈ 82.4 Hz). At 44100 Hz with fftSize 512 (halfSize 256),
// the undecimated tracker floors out around 173 Hz and cannot see this pitch. With
// 4× decimation the effective rate is ~11025 Hz, dropping the floor to ~43 Hz, so
// the fundamental is now trackable with the same (cheap) 256-lag YIN window.
let e2: Double = 82.41
let sine: OscSin.Audio = OscSin.Audio(freq: e2, mul: 0.8)
let tracker: FreqTracker = FreqTracker(
in: sine,
fftSize: 512,
hopSize: 256,
minFreq: 40.0,
maxFreq: 660.0,
decimation: 4
)
// Decimation means each hop needs 4× more input samples, so render longer.
let blocks: Int = (512 * 4 / engine.blockSize) + 60
let (freqs, _) = collect2ch(tracker, engine: engine, blocks: blocks)
let tail: [Double] = Array(freqs.suffix(engine.blockSize * 5))
let nonZero: [Double] = tail.filter { $0 > 0 }
#expect(!nonZero.isEmpty, "4× decimation should let FreqTracker detect an 82 Hz tone")
if !nonZero.isEmpty {
let avgFreq: Double = nonZero.reduce(0.0, +) / Double(nonZero.count)
#expect(avgFreq > 78.0 && avgFreq < 87.0, "Expected ~82 Hz, got \(avgFreq)")
}
}
@Test func decimationDefaultsToUnchangedBehaviour() {
// decimation: 1 (default) must reproduce the plain-A440 tracking result.
let sine: OscSin.Audio = OscSin.Audio(freq: 440.0, mul: 0.8)
let tracker: FreqTracker = FreqTracker(
in: sine,
fftSize: 512,
hopSize: 128,
minFreq: 60.0,
maxFreq: 3000.0,
decimation: 1
)
let warmUpBlocks: Int = (512 / engine.blockSize) + 10
let (freqs, _) = collect2ch(tracker, engine: engine, blocks: warmUpBlocks)
let tail: [Double] = Array(freqs.suffix(engine.blockSize * 5))
let nonZero: [Double] = tail.filter { $0 > 0 }
#expect(!nonZero.isEmpty, "decimation: 1 must still track A440 (regression guard)")
if !nonZero.isEmpty {
let avgFreq: Double = nonZero.reduce(0.0, +) / Double(nonZero.count)
#expect(avgFreq > 420.0 && avgFreq < 460.0)
}
}
}
// MARK: - LookAheadLimiter Tests
@@ -0,0 +1,39 @@
// DbAmpTests.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import Testing
import Foundation
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
@MainActor
@Suite("DbAmp")
struct DbAmpTests {
let engine: SynthesisEngine = makeTestEngine(blockSize: 8)
var graph: SynthGraph { makeSynthGraph(engine: engine) }
init() throws { try engine.start() }
@Test func zeroDbReachesUnityGain() {
let s: [[Double]] = DbAmp.Control(ConstantAudioGen(0.0)).calculatedSamples(graph: graph, count: 8)
#expect(abs(s[0][7] - 1.0) < 1e-10)
}
@Test func minusTwentyDbReachesOneTenth() {
let s: [[Double]] = DbAmp.Control(ConstantAudioGen(-20.0)).calculatedSamples(graph: graph, count: 8)
#expect(abs(s[0][7] - 0.1) < 1e-9)
}
@Test func mulAddAppliedAfterConversion() {
let mulValue: Double = 2.0
let addValue: Double = 0.5
let s: [[Double]] = DbAmp.Control(
ConstantAudioGen(0.0),
mul: mulValue,
add: addValue
).calculatedSamples(graph: graph, count: 8)
#expect(abs(s[0][7] - (1.0 * mulValue + addValue)) < 1e-10)
}
}
@@ -151,6 +151,40 @@ struct LyrebirdBufferTests {
#expect(!buffer.isValid)
}
// MARK: - loopLength
@Test("loopLength defaults to count")
func testLoopLengthDefaultsToCount() {
let bufferSize: Int = 64
let buffer: LyrebirdBuffer = LyrebirdBuffer(count: bufferSize)
#expect(buffer.loopLength == bufferSize)
}
@Test("setLoopLength narrows loopLength")
func testSetLoopLengthNarrows() {
let bufferSize: Int = 64
let narrowed: Int = 20
let buffer: LyrebirdBuffer = LyrebirdBuffer(count: bufferSize)
buffer.setLoopLength(narrowed)
#expect(buffer.loopLength == narrowed)
#expect(buffer.count == bufferSize)
}
@Test("setLoopLength clamps to [1, count]")
func testSetLoopLengthClamps() {
let bufferSize: Int = 32
let buffer: LyrebirdBuffer = LyrebirdBuffer(count: bufferSize)
buffer.setLoopLength(0)
#expect(buffer.loopLength == 1)
buffer.setLoopLength(-10)
#expect(buffer.loopLength == 1)
buffer.setLoopLength(bufferSize + 100)
#expect(buffer.loopLength == bufferSize)
}
// MARK: - Shared tables
@Test("SharedTables sineTable is valid and sized correctly")
@@ -0,0 +1,169 @@
---
name: lyrebird_external_review
description: Run a Lyrebird RT-safety and protocol-correctness review on an out-of-tree Swift package that depends on Lyrebird — custom Generators, Synthesizers, pedals, effects, or any code that runs on the audio render thread. Use this in projects that import Lyrebird but live OUTSIDE the Lyrebird repo (e.g. ShoeGaze, third-party extension packages). Invokes lyrebird_review_agent against the project's diff and the vendored Lyrebird checkout. Do not use inside the Lyrebird repo itself — use lyrebird_review there.
---
# Lyrebird External Review
Run a strict Lyrebird review of changes in an **out-of-tree** Swift package that depends on
the `Lyrebird` core module. This is the sibling of `lyrebird_review`, adapted for projects
that live outside the Lyrebird repository — they have no `main`-branch phase workflow, no
`docs/00-working-order.md`, and no agent/skill mirror to keep in sync, but they DO build
`Generator` / `Synthesizer` implementations that run on the real-time audio thread and must
obey the same hard constraints.
This review enforces the constraints that survive the repo boundary:
- No allocation, deallocation, locking, blocking, `print`, `String` construction, or
`is` / `as?` runtime type checks on the RT render thread
- No force unwraps (`!`, `try!`) in render-path code
- Correct `Generator` / `Synthesizer` / `GeneratorBase` protocol conformance
- Pre-allocated, never-resized buffers; `_checkCount(count)` as the first line of every
`_computeSamples`; no grow path
- Proper use of Lyrebird's shared RT-safe helpers instead of re-inlined boilerplate
- Input classification (generator vs scalar) at `init`, never on the RT thread
- Test coverage for every new public `Generator` (a deterministic input→output assertion,
not only an integration "not silent" check)
It deliberately does **not** enforce Lyrebird-internal repo conventions that cannot apply to
an external package: the `Sources/Lyrebird/` subfolder taxonomy, phase-history / working-order
docs, the agent/skill mirror sync, or Lyrebird's exact SPDX header text. Those are flagged (if
at all) as nits against the *project's own* conventions, never as blockers.
## Step 0: Confirm context and locate the Lyrebird reference checkout
This skill is for a package that **imports** Lyrebird, not the Lyrebird repo. Sanity-check:
```bash
# Should find a Lyrebird dependency, NOT be the Lyrebird package itself.
grep -RInE 'Lyrebird' Package.swift 2>/dev/null | head
test -f Package.swift && ! grep -qE 'name:\s*"Lyrebird"\s*,' Package.swift && echo "OK: external package" || echo "WARNING: looks like the Lyrebird repo — use lyrebird_review instead"
```
The architecture agent compares against canonical Lyrebird source. For SwiftPM projects this is
resolved under `.build/checkouts/Lyrebird/Sources/Lyrebird/`. Make sure it exists:
```bash
LYREBIRD_REF="$(pwd)/.build/checkouts/Lyrebird/Sources/Lyrebird"
if [ ! -d "$LYREBIRD_REF" ]; then
echo "Reference checkout missing — running 'swift build' to resolve dependencies..."
swift build >/dev/null 2>&1 || true
fi
test -d "$LYREBIRD_REF" && echo "Reference: $LYREBIRD_REF" || echo "No vendored Lyrebird checkout found — agent will review without canonical comparison."
```
If the project vendors Lyrebird differently (git submodule, sibling path, Xcode workspace),
ask the user for the path to the Lyrebird `Sources/Lyrebird` directory and pass that as the
reference instead.
## Step 1: Build the review diff
External repos do not follow Lyrebird's `main...` branch model — changes may be uncommitted,
untracked, or on an arbitrary branch. Capture everything under review.
- **If the user names a base ref** (branch, tag, commit), diff against it:
```bash
git diff --no-color <base> > review.diff
```
- **Otherwise** (default — review all local changes, committed-or-not, including new files):
```bash
# Intent-add untracked files so they appear in the diff as additions.
git add -N $(git ls-files --others --exclude-standard) 2>/dev/null || true
git diff --no-color HEAD > review.diff 2>/dev/null || git diff --no-color > review.diff
git reset -q 2>/dev/null || true # undo the intent-to-add; leaves working tree untouched
wc -l review.diff
```
If `review.diff` is empty, stop and report that there is nothing to review (the changes may
already be committed and merged — ask the user for a base ref to diff against).
## Step 2: Run the tests
Use the project's own test command. For a SwiftPM package that is `swift test`. If the suite
exercises multi-engine or multi-core paths it can hit Lyrebird's known parallel-teardown flake
(`_ContiguousArrayStorage retain count`) — add `--no-parallel` in that case.
```bash
swift test 2>&1 # or: swift test --no-parallel 2>&1
```
If tests fail, report the failures and stop — do not proceed to review until the suite is green.
## Step 3: Run reviews in parallel
Launch **both agents in a single message** (two Agent tool calls).
### Agent A — Lyrebird RT-safety / protocol review (`lyrebird_review_agent`)
Pass the diff path and the reference checkout path. Use a prompt of this shape (fill in the
real paths and branch name):
```
Working directory: <project root>. This is an OUT-OF-TREE Swift package that depends on the
Lyrebird core module — it is NOT the Lyrebird repository. The diff under review is at
<project root>/review.diff. Canonical Lyrebird source for comparison is at
<LYREBIRD_REF> (e.g. .build/checkouts/Lyrebird/Sources/Lyrebird) — read from it to verify
protocol shapes, helper signatures, and to compare new Generators against close analogs
(e.g. Generators/Analysis/ZeroCrossing.swift).
Read the FULL content of every changed file, not only the diff hunks. Review both changed and
unchanged portions of those files.
APPLY (blocking): RT thread safety in any _computeSamples / render path (no allocation, locks,
blocking, print, String construction, is/as? checks; no force unwraps; _checkCount first;
pre-allocated never-resized buffers; no grow path); input classification at init; correct
Generator/Synthesizer/GeneratorBase conformance and outputChannelCount; proper use of Lyrebird
shared RT-safe helpers instead of re-inlined boilerplate; bus memory rules; scheduling model
compliance; a deterministic input→output unit test for every new public Generator.
DO NOT flag as blocking (these are Lyrebird-internal repo rules that cannot apply to an
external package): the Sources/Lyrebird/ subfolder taxonomy, phase-history or working-order
docs, agent/skill mirror sync, or Lyrebird's exact SPDX header string. Header/file-org/style
conventions are the PROJECT's to set — mention deviations only as nits.
Generate a summary titled "Lyrebird External Review Results for '<project name>'".
```
### Agent B — Caveman line-level sweep (`general-purpose` agent)
```
You are doing a fast, terse code review of Swift changes in a package that depends on the
Lyrebird audio framework. Read the diff at <project root>/review.diff (or run
`git diff --no-color HEAD`). Pay special attention to any code that runs on the RT render
thread (_computeSamples, render callbacks).
Review every changed line. One line of output per finding. Format exactly:
L<line>: <severity> <problem>. <fix>.
Severity levels: bug, risk, nit, q
- bug = definite defect, wrong output, crash risk
- risk = potential issue under specific conditions
- nit = style, naming, minor clarity
- q = question / needs clarification
Skip praise. Skip obvious. Skip anything already correct.
If all changes look good, output exactly: LGTM
```
## Step 4: Present results
Two sections:
**Section 1 — Lyrebird External Review Results** — Agent A's summary, unmodified.
**Section 2 — Caveman Line Sweep** — Agent B's findings. If Agent B returned "LGTM", say so in
one line.
## Step 5: Resolve and re-run
If there are blocking findings, fix them and re-run this skill from Step 1 until the review is
clean. There is **no** memory-file or phase-doc bookkeeping for external packages — once the
review passes with no blocking findings, report the clean result and (optionally) suggest the
project record the change in its own CHANGELOG or release notes.
## Cleanup
Remove the temporary diff when done:
```bash
rm -f review.diff
```
+143
View File
@@ -0,0 +1,143 @@
#!/usr/bin/env bash
#
# prepare_release.sh — replicate the Lyrebird dev repo's committed tree into the
# public LyrebirdRelease (mooo) repo, minus the maintainer-only paths that never ship.
#
# Replaces the manual "export → hand-copy in Finder" step. Works from a clean
# `git archive HEAD` of the dev repo (so untracked build junk and Finder " 2"/" 3"
# duplicate cruft never leak in), strips the intentional exclusions, then rsyncs the
# result over the release working tree with --delete (cleaning stale files) while
# preserving the release repo's own .git and local .build.
#
# Dry-run by default. Pass --apply to actually modify the release working tree.
#
# Usage:
# prepare_release.sh [--dev PATH] [--release PATH] [--apply] [--allow-dirty]
#
# Defaults:
# --dev ~/Documents/src/Lyrebird
# --release ~/Documents/src/LyrebirdRelease
set -euo pipefail
DEV="${HOME}/Documents/src/Lyrebird"
RELEASE="${HOME}/Documents/src/LyrebirdRelease"
APPLY=0
ALLOW_DIRTY=0
# Paths that are git-tracked in dev but must NOT ship in the public release.
# (Verified: these exactly account for the dev↔release tracked-file delta.)
EXCLUSIONS=(
"legacy"
"PLAN.md"
".claude"
".githooks"
".swiftpm"
)
# Regex the release repo's origin URL must match — a guard so --apply can never
# nuke the wrong directory. Requires the mooo host AND the `Lyrebird` repo path
# (so a sibling mooo repo like ShoeGaze can't be mistaken for the release repo).
RELEASE_REMOTE_REGEX='realizedsound\.mooo\.com.*/Lyrebird(\.git)?/?$'
while [ $# -gt 0 ]; do
case "$1" in
--dev) DEV="$2"; shift 2 ;;
--release) RELEASE="$2"; shift 2 ;;
--apply) APPLY=1; shift ;;
--allow-dirty) ALLOW_DIRTY=1; shift ;;
-h|--help)
tail -n +2 "$0" | grep '^#' | sed 's/^# \{0,1\}//'
exit 0 ;;
*) echo "ERROR: unknown argument '$1'" >&2; exit 2 ;;
esac
done
fail() { echo "ERROR: $*" >&2; exit 1; }
# --- Validate repos ---------------------------------------------------------
[ -d "$DEV/.git" ] || fail "dev repo not a git repo: $DEV"
[ -d "$RELEASE/.git" ] || fail "release repo not a git repo: $RELEASE"
RELEASE_URL="$(git -C "$RELEASE" remote get-url origin 2>/dev/null || echo "")"
if [[ ! "$RELEASE_URL" =~ $RELEASE_REMOTE_REGEX ]]; then
fail "release origin ('$RELEASE_URL') is not the Lyrebird mooo release repo (must match /$RELEASE_REMOTE_REGEX/) — refusing to sync. Wrong --release path?"
fi
# --- Guard: dev working tree should be committed (we archive HEAD) -----------
if [ -n "$(git -C "$DEV" status --porcelain)" ]; then
if [ "$ALLOW_DIRTY" -eq 1 ]; then
echo "WARNING: dev repo has uncommitted changes — they will NOT ship (archiving HEAD). Continuing (--allow-dirty)."
else
fail "dev repo ($DEV) has uncommitted changes. Commit them first (only HEAD ships), or pass --allow-dirty to archive HEAD anyway."
fi
fi
DEV_HEAD="$(git -C "$DEV" rev-parse --short HEAD)"
echo "Dev HEAD: $DEV_HEAD ($(git -C "$DEV" log -1 --format=%s))"
echo "Release repo: $RELEASE (origin: $RELEASE_URL)"
echo "Mode: $([ "$APPLY" -eq 1 ] && echo APPLY || echo DRY-RUN)"
echo
# --- Stage a pristine tree from git archive ---------------------------------
STAGING="$(mktemp -d "${TMPDIR:-/tmp}/lyrebird-release-prep.XXXXXX")"
trap 'rm -rf "$STAGING"' EXIT
git -C "$DEV" archive --format=tar HEAD | tar -x -C "$STAGING"
# Strip the intentional exclusions from the staged tree.
echo "Excluding (maintainer-only, never shipped):"
for p in "${EXCLUSIONS[@]}"; do
if [ -e "$STAGING/$p" ]; then
echo " - $p"
rm -rf "$STAGING/$p"
fi
done
echo
# --- Sync staging → release -------------------------------------------------
# --delete removes release files not present in the staged tree (clears stale
# files + accumulated Finder duplicates). Excludes protect the release repo's own
# .git and local, non-shipped build/editor state from both transfer and deletion.
RSYNC_ARGS=(
-a -c --delete --itemize-changes
--exclude='.git/'
--exclude='.build/'
--exclude='.swiftpm/'
--exclude='.DS_Store'
--exclude='xcuserdata/'
--exclude='*.xcuserstate'
)
[ "$APPLY" -eq 1 ] || RSYNC_ARGS+=(--dry-run)
# Capture itemized output; filter to meaningful lines for display. rsync itemize
# codes: leading '>' = content transfer, 'c' = created dir/file, '*deleting' =
# removal. Leading '.' = metadata-only (mtime/perms) churn — harmless (git ignores
# it), so suppress it from the summary. Content is authoritative via -c (checksum).
ITEMS="$(rsync "${RSYNC_ARGS[@]}" "$STAGING/" "$RELEASE/")"
MEANINGFUL="$(printf '%s\n' "$ITEMS" | grep -E '^(\*deleting|[>c])' || true)"
echo "Content changes + deletions ($([ "$APPLY" -eq 1 ] && echo applied || echo would apply)):"
if [ -n "$MEANINGFUL" ]; then
printf '%s\n' "$MEANINGFUL" | sed 's/^/ /'
else
echo " (none — release tree already matches dev content)"
fi
META_COUNT="$(printf '%s\n' "$ITEMS" | grep -cE '^\.' || true)"
echo " [$META_COUNT files: mtime/perms normalized only — no content change, git-invisible]"
echo
if [ "$APPLY" -eq 1 ]; then
echo "Sync complete. Release working tree now mirrors dev HEAD ($DEV_HEAD) minus exclusions."
echo
echo "Release git status:"
git -C "$RELEASE" status --short | sed 's/^/ /'
echo
echo "Next (run in $RELEASE — pushes need your key/touch):"
echo " git -C \"$RELEASE\" add -A"
echo " git -C \"$RELEASE\" commit -m \"<release message>\""
echo " git -C \"$RELEASE\" tag -a vX.Y.Z -m \"vX.Y.Z: <summary>\""
echo " git -C \"$RELEASE\" push origin main && git -C \"$RELEASE\" push origin vX.Y.Z"
else
echo "Dry-run only. Re-run with --apply to modify the release working tree."
fi
@@ -0,0 +1,112 @@
---
name: lyrebird_release_prep
description: Prepare the public LyrebirdRelease (mooo) repo from the Lyrebird dev repo, replacing the manual "export → hand-copy in Finder" step. Syncs the dev repo's committed tree into the release working tree, excluding maintainer-only paths that never ship (legacy/, PLAN.md, .claude/, .githooks/, .swiftpm/) and cleaning accumulated Finder duplicate cruft. Dry-run first, then apply, then guides commit + tag + push to mooo. Use when cutting a new Lyrebird release (e.g. bumping to a new vX.Y.Z tag).
---
# Lyrebird Release Prep
Replicates the Lyrebird **dev** repo (`~/Documents/src/Lyrebird`, origin = bitbucket) into
the public **release** repo (`~/Documents/src/LyrebirdRelease`, origin = `realizedsound.mooo.com`)
that SwiftPM consumers resolve from — without the manual Finder export/hand-copy.
## What it does (and why it's safe)
Works from a clean `git archive HEAD` of the dev repo, so:
- only **committed, tracked** files ship (no `.build`, no editor state),
- accumulated Finder duplicate cruft (` 2`/` 3` suffixed dirs) never leaks in, and
- the release's own `.git` and local `.build` are preserved.
Then it strips the maintainer-only paths that are tracked in dev but must **not** ship
(verified to exactly account for the dev↔release tracked-file delta):
| Excluded | Why |
|---|---|
| `legacy/` | old pre-modernization reference code |
| `PLAN.md` | private planning doc |
| `.claude/` | agent working-copy mirror (release ships `claude/` installer source only) |
| `.githooks/` | dev-only pre-commit hooks |
| `.swiftpm/` | local Xcode package state |
The sync uses `rsync -a -c --delete` (checksum-based, so only real content differences
transfer; `--delete` clears stale files + Finder cruft on the release side). A moo-URL guard
on the release remote prevents `--apply` from ever touching the wrong directory.
`docs/` (including `00-working-order.md` / `01-completed-working-order.md`) **does** ship —
only top-level `PLAN.md` is excluded from the planning material.
## Steps
### 1. Pre-flight
Confirm the dev repo has the release commit already made (the script archives `HEAD` — uncommitted changes do **not** ship):
```bash
git -C ~/Documents/src/Lyrebird status --short # should be clean
git -C ~/Documents/src/Lyrebird log -1 --oneline
```
If dirty, commit first (or the maintainer may pass `--allow-dirty` to archive HEAD anyway).
### 2. Dry run
```bash
~/.claude/skills/lyrebird_release_prep/prepare_release.sh
```
Read the summary: it lists the excluded paths, the deletions (Finder cruft cleanup), and the
**content changes** (should match exactly the files changed since the last release). Metadata-
only (mtime/perms) churn is reported as a count and is git-invisible.
Stop and investigate if the content-change list contains anything unexpected.
### 3. Apply
```bash
~/.claude/skills/lyrebird_release_prep/prepare_release.sh --apply
```
This mirrors the dev tree into the release working tree. It prints the release repo's
`git status --short` afterward — this is the authoritative content diff.
### 4. Commit, tag, push (maintainer runs — push needs your key/touch)
The script prints these; fill in the version and message:
```bash
R=~/Documents/src/LyrebirdRelease
git -C "$R" add -A
git -C "$R" commit -m "vX.Y.Z release: <summary>"
git -C "$R" tag -a vX.Y.Z -m "vX.Y.Z: <summary>"
git -C "$R" push origin main && git -C "$R" push origin vX.Y.Z
```
Verify the tag landed:
```bash
git -C "$R" ls-remote --tags origin | grep vX.Y.Z
```
### 5. Point consumers at the new tag
For a downstream package pinned to a local `swift package edit` override during development
(e.g. ShoeGaze), drop the override and bump the dependency once the tag is live:
```bash
cd <consumer-pkg>
swift package unedit Lyrebird
swift package update Lyrebird # resolves to the new tag if Package.swift `from:` allows it
swift build && swift test
```
## Flags
- `--dev PATH` / `--release PATH` — override the default repo locations.
- `--apply` — actually modify the release working tree (default is dry-run).
- `--allow-dirty` — proceed even if the dev repo has uncommitted changes (still archives HEAD).
## Maintaining the exclusion list
If a new maintainer-only top-level path is added to the dev repo, add it to the `EXCLUSIONS`
array in `prepare_release.sh`. Sanity check: after a dry run, the release tracked-file count
plus the excluded tracked-file counts should equal the dev tracked-file count
(`git ls-files | wc -l` in each; `git ls-files <path> | wc -l` per exclusion).
+41
View File
@@ -131,6 +131,47 @@ Lyrebird 1.x:
them (`"atk.azimuth"`, not `"azimuth"`) to avoid collisions in user code that mixes
multiple extension packages.
## Reviewing your extension package — `lyrebird_external_review`
Out-of-tree packages run their custom `Generator` / `Synthesizer` code on the same real-time
audio thread as the core, under the same hard constraints (no allocation, locks, force unwraps,
or runtime type checks in `_computeSamples`; `_checkCount` first; pre-allocated, never-resized
buffers; input classification at `init`). The Lyrebird-internal `lyrebird_review` skill assumes
the Lyrebird repo's branch-and-phase workflow and `docs/00-working-order.md`, so it is the wrong
tool for an external package.
For that case there is a dedicated skill: **`lyrebird_external_review`**. It applies the same
RT-safety and protocol-correctness checks, but adapted for a package that merely *depends on*
Lyrebird:
- Builds a review diff from local changes (committed or not, including new untracked files),
or against a base ref you name — no `main`-branch assumption.
- Locates the vendored Lyrebird source (`.build/checkouts/Lyrebird/Sources/Lyrebird/`) and points
the reviewer at it, so new generators are compared against canonical analogs (e.g.
`ZeroCrossing`) and helper signatures are verified against the real API.
- Runs the project's own test suite (`swift test`, `--no-parallel` if multi-engine flakes appear).
- Invokes `lyrebird_review_agent` (RT safety, protocol conformance, shared-helper usage, unit-test
coverage for new generators) plus a terse line-level sweep, in parallel.
- Skips all Lyrebird-internal bookkeeping (phase history, working-order docs, the
`Sources/Lyrebird/` subfolder taxonomy, agent/skill mirror sync) and treats file-organisation
and header conventions as the *project's* to set — flagged as nits, never blockers.
**Usage** — from the root of the dependent package (e.g. a `ShoeGaze` checkout or any
`Lyrebird<Vendor>` extension repo):
```
/lyrebird_external_review
```
Optionally pass a base ref to scope the diff (`/lyrebird_external_review v0.3.0`). Fix any
blocking findings and re-run until clean.
The skill ships with Lyrebird at `claude/skills/lyrebird_external_review/` (installer source,
copied into a consuming project by `claude/install.sh`) and is mirrored at
`.claude/skills/lyrebird_external_review/` for auto-discovery when working inside this repo.
Install it into your extension package so contributors get the same pre-merge RT review you get
in-tree.
## See also
- [Writing Generators](writing-generators.md) — full generator-author guide.
-349
View File
@@ -1,349 +0,0 @@
# ShoeGaze — Guitar Pedalboard Framework
ShoeGaze is a nested SwiftPM sub-package (`ShoeGaze/`) that models a guitar-effect signal chain as a sequence of `Pedal` objects managed by a `PedalBoard`, all hosted by a `ShoeGaze` manager that owns the `SynthesisEngine`.
---
## Core Concepts
### `Pedal`
A `Pedal` is a `SynthesizerBase` subclass that reads a mono signal from its input bus, runs it through a subclass-supplied `effect(_:)` stage, blends wet/dry with an equal-power crossfade (`mix`), applies a click-free `bypass` crossfade, scales by `level`, and writes to its output bus. Each pedal exposes its knobs as `@UIParam` properties and publishes a `knobs: [PedalKnob]` list so `PedalView` (from `LyrebirdShoeGazeUI`) renders a control per parameter.
Eight built-in pedals (the signal chain is mono; stereo-native effects fold to mono internally):
| Type | Effect |
|---|---|
| `OverdrivePedal` | Soft-clip saturation → RBJ low-pass tone. Knobs: `drive`, `tone` |
| `DelayPedal` | Feedback delay line. Knobs: `time`, `feedback` |
| `ReverbPedal` | Freeverb (stereo, summed to mono). Knobs: `roomSize`, `damping` |
| `ModulationPedal` | Chorus (stereo, summed to mono). Knobs: `rate`, `depth` |
| `FuzzPedal` | High-gain `tanh` saturation (drive → square-up) → RBJ low-pass tone. Knobs: `fuzz`, `tone` |
| `TremoloPedal` | Unipolar sine LFO amplitude modulation. Knobs: `rate`, `depth` |
| `PhaserPedal` | Cascaded all-pass stages swept by a sine LFO. Knobs: `rate`, `feedback` |
| `CompressorPedal` | Feed-forward dynamic range compressor. Knobs: `threshold`, `ratio` |
Every pedal also inherits the common `mix`, `bypass`, and `level` controls from `Pedal`.
Write a custom pedal by subclassing `Pedal`, overriding `effect(_:)` to return a mono processed signal, and overriding `effectKnobs` to publish its `@UIParam` knobs. The base class handles wet/dry mixing, bypass, and output gain.
### `PedalBoard`
A `PedalBoard` is an ordered collection of pedals. Pedals are appended in signal-flow order with `board.add(pedal)`. A board must be finalised with `shoeGaze.finalizeBoard(board)` before audio flows through it — finalisation wires the signal chain and adds all pedals to the engine.
### `ShoeGaze`
`ShoeGaze` owns the `SynthesisEngine` and manages one or more `PedalBoard` instances. The engine lifecycle is caller-owned: `ShoeGaze` itself has no `start()` / `stop()` methods. `ShoeGazeView` provides Start/Stop transport buttons that call `engine.start()` / `engine.stop()`, or the app can drive the engine directly.
```swift
let shoeGaze = ShoeGaze(engine: engine)
let board = try shoeGaze.addBoard()
try board.add(OverdrivePedal())
try board.add(DelayPedal())
try shoeGaze.finalizeBoard(board)
```
### Input sources
Every `PedalBoard` has an `InputSource` that determines what feeds the first pedal in the chain:
| Source | Description |
|---|---|
| `.testLoop` (default) | Built-in synthesized test signal — no audio hardware input needed |
| `.liveInput(channel:)` | Routes a hardware input channel (zero-based; bus `numOutputChannels + channel`) from the microphone / audio interface |
The source is set on the `ShoeGaze` manager at init; every board it creates uses it:
```swift
let shoeGaze = ShoeGaze(engine: engine, inputSource: .liveInput(channel: 0))
let board = try shoeGaze.addBoard()
```
`liveInput` requires `numInputChannels > 0` in the `SynthesisEngine` init and the appropriate OS permission (microphone entitlement on macOS, `NSMicrophoneUsageDescription` in Info.plist for iOS).
### Recording
`ShoeGaze` can record the raw **input** and the overall **output** to timestamped WAV
files (via core `DiskOut.Audio`):
- `ShoeGaze.recordingFolder: URL?` — destination folder (set from the UI's folder picker).
- `ShoeGaze.startRecording() throws` — writes `output-<yyyyMMdd-HHmmss>.wav` (stereo hardware
output) and `input-<…>.wav` (the raw input: the hardware input channel for `.liveInput`,
or the first board's head bus for `.testLoop`). Throws `ShoeGazeError.recordingFolderNotSet`
if no folder is set; creates the folder if missing.
- `ShoeGaze.stopRecording()` — removes the taps and flushes/closes the files.
- `ShoeGaze.isRecording: Bool`.
The record taps are inserted `.after(engine.mainGroup)` so they capture each block's fully
processed bus values. `ShoeGazeView` provides a **Choose Folder…** button and a **Record/Stop**
button (disabled until a folder is chosen). For the cleanest tail of the file, stop the engine
before `stopRecording()` (engine node removal is asynchronous, so the last block or two may be
dropped otherwise).
### Board selection & crossfade
By default every board's output sums to the hardware output. To make only one board
audible at a time — switching between them without clicks — use:
- `ShoeGaze.selectBoard(_ board:, crossfadeSeconds:)` — solo `board`, crossfading the others out.
- `ShoeGaze.selectAllBoards(crossfadeSeconds:)` — restore the summed (all-audible) state.
- `ShoeGaze.activeBoardIndex: Int?` — the soloed board index, or `nil` when all are audible.
Each board's output master carries a lagged board-select gain (separate from the master
volume knob); `crossfadeSeconds` sets the lag time, so a switch is a click-free crossfade
of that duration (`0` = instant). `ShoeGazeView` exposes an "Active" board picker plus a
crossfade-seconds field driving these calls.
---
## Parallel routing (split / merge)
Two routing primitives let a signal fan out to two parallel paths and recombine:
- **`Splitter`** — one input bus → two branch buses, each gated by a click-free, lagged enable (`@UIParam branchAEnabled` / `branchBEnabled`). The `mode: SplitMode` convenience selects `.a` (branch A only), `.b` (branch B only), or `.both` (parallel). A/B switching is click-free.
- **`Merger`** — two branch buses → one output bus, each scaled by `@UIParam levelA` / `levelB`, summed.
Both are `SynthesizerBase` routing nodes (not `Pedal`s — multi-bus, no wet/dry). They power two layers:
### Intra-board: a parallel section inside one board
`PedalBoard.split()` inserts a splitter at the current chain tail and returns a `ParallelSection` with two `BranchChain`s; populate each branch, then `PedalBoard.merge(_:)` sums them back into the chain. Series pedals before and after compose normally.
```swift
let board = try shoeGaze.addBoard()
try board.add(OverdrivePedal()) // series pre
let section = try board.split() // → splitter
try section.branchA.add(DelayPedal()) // branch A
try section.branchB.add(FuzzPedal()) // branch B
try board.merge(section) // → merger
try board.add(ReverbPedal()) // series post
try shoeGaze.finalizeBoard(board)
section.splitter.mode = .both // run both branches
```
Branches use independent buses; the merge node is inserted after both branches so they evaluate first. Node-tree order: `pre → splitter → branch pedals → merger → post`.
### Inter-board: an A/B chain router
`ShoeGaze.makeChainRouter()` returns a `ChainRouter` that feeds one shared input through a splitter to **two whole boards** (`boardA` / `boardB`), then a merger + master to the hardware output. `router.mode` toggles which chain is audible (or both).
```swift
let router = try shoeGaze.makeChainRouter()
try router.boardA.add(OverdrivePedal())
try router.boardA.add(DelayPedal())
try router.boardB.add(FuzzPedal())
try router.boardB.add(ReverbPedal())
try router.finalize()
router.mode = .a // chain A live; toggle to .b / .both
```
The router owns its source, splitter, merger, and master (it does not use the per-board source/master of `addBoard`/`finalizeBoard`). `ChainRouter.teardown()` removes all nodes before releasing buses; `ShoeGaze.teardown()` tears down routers too.
---
## SwiftUI — `LyrebirdShoeGazeUI`
`LyrebirdShoeGazeUI` provides ready-made SwiftUI views:
| View | Description |
|---|---|
| `ShoeGazeView(shoeGaze:)` | Top-level view: transport controls + all boards |
| `PedalBoardView(board:)` | Horizontal scroll of `PedalView` tiles for one board |
| `PedalView(pedal:)` | Single pedal tile: bypass toggle + one knob per entry in `pedal.knobs` |
| `SplitterView(splitter:)` | 3-way A / B / Both mode selector + per-branch enable LEDs |
| `MergerView(merger:)` | Branch A / B level knobs |
| `ParallelSectionView(section:)` | Splitter + the two branch pedal rows for an intra-board section |
| `ChainRouterView(router:)` | Splitter + master knob, boards A/B, and the merger for an A/B chain router |
| `BoardEditorView(shoeGaze:boardIndex:versionStore:)` | Auto-laid-out board editor: wrap-to-fit pedal grid + save/load version toolbar |
| `FlowLayout` | A `Layout` that wraps subviews left-to-right to fit the available width (used by the editor) |
`PedalView` renders the descriptors a pedal publishes via its `knobs: [PedalKnob]` list (effect knobs, then the common `mix` and `level`). A custom pedal gets knobs by overriding `effectKnobs` — no view code is required.
---
## Board versions & auto-layout editor
`BoardEditorView(shoeGaze:boardIndex:versionStore:)` visualizes one board: its pedals are arranged by `FlowLayout`, a SwiftUI `Layout` that flows pedals left-to-right and wraps to the next row to fit the window width (a real pedalboard look). A toolbar saves and recalls **versions** of the board.
Backend:
- `PedalBoard.captureState() -> BoardState` snapshots a board (label + each pedal's type + knob/bypass values).
- `ShoeGaze.rebuildBoard(_:from:) throws -> PedalBoard` tears the board down and recreates it from a `BoardState` — recreating pedals via `PedalRegistry` and restoring knob values — **at the same index** in `boards` (unknown pedal types are skipped). Call with the engine stopped (same async-removal caveat as `teardown`).
- `BoardVersionStore` (`@Observable`) holds named `BoardVersion`s (`id`, `name`, `savedAt`, `state`) in memory and persists them as JSON:
- `capture(board, name:)` snapshots the current board.
- `writeAllToDisk(in:)` / `loadAllFromDisk(in:)` round-trip versions to a directory (`BoardVersionStore.defaultDirectory()` = `<Application Support>/LyrebirdShoeGaze/ShoeGazeVersions/`).
```swift
let store = BoardVersionStore()
store.capture(board, name: "Crunch rhythm") // snapshot current knobs
try store.writeAllToDisk(in: BoardVersionStore.defaultDirectory())
// later — recall, rebuilding the board from the saved version:
_ = try shoeGaze.rebuildBoard(board, from: store.versions[0].state)
```
In the UI, "Save Version" snapshots the live board, the Versions menu loads one (rebuilding in place), and Save/Load-to-disk persist the set. Because `ShoeGaze` and `BoardVersionStore` are `@Observable`, the editor re-renders automatically after a capture or rebuild.
---
## Demo apps
The package ships two in-repo demo apps in the workspace — a macOS app and an iOS app.
Both live under `ShoeGaze/Demo/` and share the same workspace:
```sh
open ShoeGaze/ShoeGaze.xcworkspace
```
The workspace contains three entries: the `ShoeGaze` SwiftPM package (library targets),
`Demo/ShoeGazeDemo.xcodeproj` (macOS), and `Demo/ShoeGazeiOSDemo.xcodeproj` (iOS). Xcode
resolves the two local package references (`..` for `LyrebirdShoeGaze`/`LyrebirdShoeGazeUI`,
`../..` for `Lyrebird`/`LyrebirdUI`) automatically when you first open the workspace.
### `ShoeGazeDemo` (macOS)
Showcases every feature via a mode picker (Boards / Editor / Parallel / Router), an input
dropdown, transport, and the board selector + crossfade. Build & Run produces `ShoeGazeDemo.app`
with a full menu bar — **Quit ⌘Q**, **Audio ▸ Mute ⌘M** (checkmark while muted):
```sh
open ShoeGaze/ShoeGaze.xcworkspace # select the "ShoeGazeDemo" scheme → Run
```
### `ShoeGazeiOSDemo` (iPhone + iPad)
A minimal iOS app wrapping `ShoeGazeView` in a `NavigationStack` + `ScrollView` so the
pedalboard scrolls on compact screens. Shows a default board (Overdrive → Delay → Reverb →
Modulation) fed by the built-in `.testLoop` source — no microphone permission required.
To run:
1. Open `ShoeGaze/ShoeGaze.xcworkspace` in Xcode.
2. Select the **ShoeGazeiOSDemo** scheme.
3. Pick an iPhone or iPad simulator (or a physical device with a provisioning profile).
4. Click **Run**.
The app uses `AVAudioSession` to read the hardware sample rate at launch, so pitch and timing
are accurate on all devices. To switch to live microphone input: set
`numInputChannels: 1` and `.playAndRecord` in `ShoeGazeiOSDemoAppModel.swift`, then pass
`.liveInput(channel: 0)` to the `ShoeGaze` init.
Note: the CLI `lyrebird new --template shoegaze` / `--template shoegaze-ios` (below) is still
the way to scaffold your OWN app project. The demo apps are in-repo only.
---
## `lyrebird new --template shoegaze` Workflow (macOS Xcode app)
```sh
lyrebird new MyRig --template shoegaze \
--lyrebird-path /path/to/LyrebirdII \
--shoegaze-path /path/to/LyrebirdII/ShoeGaze
```
Generates a full `.xcodeproj` macOS application (macOS 15+):
```
MyRig/
├── MyRig.xcodeproj/
│ ├── project.pbxproj
│ └── xcshareddata/xcschemes/MyRig.xcscheme
├── MyRig.xcworkspace/
│ └── contents.xcworkspacedata (references MyRig.xcodeproj)
└── MyRig/
├── Info.plist (NSMicrophoneUsageDescription pre-wired)
├── MyRigApp.swift (@main SwiftUI App — ShoeGazeView root + Mute menu)
└── MyRigAppModel.swift (@Observable model — engine + ShoeGaze)
```
Open `MyRig.xcworkspace` in Xcode and run. The generated app:
- Wires `CoreAudioDriver` at 48 000 Hz with 256 audio buses.
- Builds a default board (Overdrive → Delay → Reverb → Modulation) with the `.testLoop` input source.
- Exposes an **Audio ▸ Mute ⌘M** command (stops/starts the engine).
- Ships `NSMicrophoneUsageDescription` in `Info.plist` so switching to `.liveInput` doesn't require an extra plist edit.
- `ShoeGazeView` already provides Choose Folder / Record / Stop recording controls.
Key differences between the macOS and iOS shoegaze templates:
| | `shoegaze` (macOS Xcode) | `shoegaze-ios` (iOS Xcode) |
|---|---|---|
| Project type | `.xcodeproj` app bundle | `.xcodeproj` app bundle |
| Driver | `CoreAudioDriver` | `iOSAudioDriver` |
| Session | — | `AVAudioSession(.playback)` |
| Entry point | SwiftUI `@main App` | SwiftUI `@main App` |
| Window sizing | `.frame(minWidth:minHeight:)` | device-fill, no min size |
| Menu | Audio ▸ Mute ⌘M | — |
### `--shoegaze-path`
ShoeGaze is not yet published at a stable remote URL. Passing `--shoegaze-path <abs path to ShoeGaze/>` wires it as an `XCLocalSwiftPackageReference` in the generated `.xcodeproj`. If you omit the flag, the pbxproj uses a placeholder URL (`https://github.com/realizedsound/LyrebirdShoeGaze`) — edit `project.pbxproj` or re-generate once ShoeGaze is published.
The placeholder URL is stored in `ProjectScaffolder.shoegazePackageURL`.
### Live audio input on macOS
The generated template uses `.testLoop` and `numInputChannels: 0`. To switch to microphone or audio interface input:
1. Change `numInputChannels: 0` to the desired channel count in `MyRigAppModel.swift`.
2. Change `ShoeGaze(engine: eng)` to `ShoeGaze(engine: eng, inputSource: .liveInput(channel: 0))`.
3. `NSMicrophoneUsageDescription` is already in `Info.plist` — update the string to describe your use case.
4. If running under App Sandbox, add `com.apple.security.device.audio-input` to the `.entitlements` file. The `shoegaze` template is unsandboxed by default (Hardened Runtime without sandbox), so no entitlement file is needed in the common development workflow.
---
## `lyrebird new --template shoegaze-ios` Workflow (iOS)
```sh
lyrebird new MyRig --template shoegaze-ios \
--lyrebird-path /path/to/LyrebirdII \
--shoegaze-path /path/to/LyrebirdII/ShoeGaze
```
Generates a full `.xcodeproj` iOS application (iPhone + iPad, iOS 18+):
```
MyRig/
├── MyRig.xcodeproj/
│ ├── project.pbxproj
│ └── xcshareddata/xcschemes/MyRig.xcscheme
├── MyRig.xcworkspace/
│ └── contents.xcworkspacedata (references MyRig.xcodeproj)
└── MyRig/
├── Info.plist
├── MyRigApp.swift (@main SwiftUI App — ShoeGazeView root)
└── MyRigAppModel.swift (@Observable model — engine + ShoeGaze)
```
Open `MyRig.xcworkspace` in Xcode, select an iPhone/iPad simulator or device, and run. The generated app:
- Activates `AVAudioSession(.playback)` and queries the hardware sample rate at init so pitch and timing are accurate on all devices.
- Builds a default board (Overdrive → Delay → Reverb → Modulation) with the `.testLoop` input source.
- Wraps `ShoeGazeView` in a `NavigationStack` + `ScrollView` for compact-screen compatibility.
Key differences from the macOS `shoegaze` template:
| | `shoegaze` (macOS Xcode) | `shoegaze-ios` (iOS Xcode) |
|---|---|---|
| Project type | `.xcodeproj` app bundle | `.xcodeproj` app bundle |
| Driver | `CoreAudioDriver` | `iOSAudioDriver` |
| Session | — | `AVAudioSession(.playback)` |
| Entry point | SwiftUI `@main App` | SwiftUI `@main App` |
| Window sizing | `.frame(minWidth:minHeight:)` | device-fill, no min size |
| Menu | Audio ▸ Mute ⌘M | — |
### Live audio input on iOS
The generated template uses `.testLoop` and `numInputChannels: 0`. To switch to microphone input:
1. Change `numInputChannels: 0` to `numInputChannels: 1` in `MyRigAppModel.swift`.
2. Change `.playback` to `.playAndRecord` (mode: `.default`, options: `[.defaultToSpeaker]`) in the `AVAudioSession` setup.
3. Add `NSMicrophoneUsageDescription` to `Info.plist` (required for App Store submission and the system permission prompt).
4. Change `ShoeGaze(engine: eng)` to `ShoeGaze(engine: eng, inputSource: .liveInput(channel: 0))`.
---
## Extending the starter app
- Add more pedals in `applicationDidFinishLaunching` with additional `board.add(...)` calls.
- Create a second board with `shoeGaze.addBoard()` — `ShoeGazeView` shows all boards.
- Write a custom pedal: subclass `Pedal`, override `effect(_:)` (return a mono signal) and `effectKnobs`. The base class handles wet/dry, bypass, and level; `PedalView` picks up the knobs automatically.
- Switch to live audio: construct `ShoeGaze(engine:, inputSource: .liveInput(channel: 0))` and set `numInputChannels` ≥ 1 in the engine init (plus the microphone entitlement / `NSMicrophoneUsageDescription`).
+2 -14
View File
@@ -85,16 +85,12 @@ lyrebird new 1stPiece # error: not a valid Swift module name
**Templates** — `--template <name>`:
- SPM-only (open `Package.swift` in Xcode): `basic` (default), `demo`, `ui-demo`, `nrt`, `score`
- Xcode-project (ships `.xcodeproj` + `.xcworkspace`, builds to `.app` or `.appex`): `shoegaze`, `shoegaze-ios`, `macos-ui-xcode`, `ios-ui`, `auv3`
- Xcode-project (ships `.xcodeproj` + `.xcworkspace`, builds to `.app` or `.appex`): `macos-ui-xcode`, `ios-ui`, `auv3`
```sh
lyrebird new MyApp --template macos-ui-xcode # macOS .app
lyrebird new MyApp --template ios-ui # iOS .app
lyrebird new MyPlugin --template auv3 # AUv3 host + .appex
lyrebird new MyRig --template shoegaze \
--shoegaze-path /path/to/ShoeGaze # macOS guitar pedalboard (.xcodeproj, .app)
lyrebird new MyRig --template shoegaze-ios \
--shoegaze-path /path/to/ShoeGaze # iOS guitar pedalboard (.xcodeproj, .app)
```
**Local Lyrebird checkout** — `--lyrebird-path <abs-path>` makes the generated project depend on a local Lyrebird checkout (via `.package(name: "Lyrebird", path: ...)` in `Package.swift`, `XCLocalSwiftPackageReference` in `<name>.xcodeproj`). Use while the published repo URL isn't yet accessible:
@@ -104,15 +100,7 @@ lyrebird new MyApp --template macos-ui-xcode \
--lyrebird-path /Users/me/Documents/LyrebirdII
```
**Local ShoeGaze checkout** — `--shoegaze-path <abs-path>` (shoegaze / shoegaze-ios templates) wires the `LyrebirdShoeGaze` package as a local SPM dependency. Omitting this flag emits a placeholder remote URL in the generated project; edit it or re-run with `--shoegaze-path` once ShoeGaze is published. The placeholder URL is `ProjectScaffolder.shoegazePackageURL`.
```sh
lyrebird new MyRig --template shoegaze-ios \
--lyrebird-path /Users/me/Documents/LyrebirdII \
--shoegaze-path /Users/me/Documents/LyrebirdII/ShoeGaze
```
See `docs/tooling/project-system.md` for the layout each template emits. See `docs/stdlib/shoegaze.md` for the ShoeGaze package concepts and workflow.
See `docs/tooling/project-system.md` for the layout each template emits. Guitar-pedalboard app scaffolding lives in the standalone ShoeGaze repo, which depends on Lyrebird.
If the directory already exists, the command fails cleanly and leaves the filesystem unchanged.
-2
View File
@@ -48,11 +48,9 @@ Xcode-project templates (ship a real `.xcodeproj` for deliverables SwiftPM can't
| Template | Command | Description |
|---|---|---|
| `shoegaze` | `lyrebird new MyRig --template shoegaze --shoegaze-path <path>` | macOS guitar-pedalboard `.app` (Xcode, SwiftUI `@main`). Generates a full `.xcodeproj` with a `ShoeGazeView` root view, an `@Observable` app model wiring `CoreAudioDriver` + `ShoeGaze`, and an **Audio ▸ Mute ⌘M** menu command. `NSMicrophoneUsageDescription` pre-wired for `.liveInput`. Default board: Overdrive→Delay→Reverb→Modulation fed by the built-in test loop. Requires `--shoegaze-path` until `LyrebirdShoeGaze` is published |
| `macos-ui-xcode` | `lyrebird new MyApp --template macos-ui-xcode` | macOS `.app` (AppKit + SwiftUI), `@UIParam` synth, hardened runtime |
| `ios-ui` | `lyrebird new MyApp --template ios-ui` | iOS `.app` (SwiftUI + `iOSAudioDriver`), `AVAudioSession` activation, iPhone + iPad device family |
| `auv3` | `lyrebird new MyPlugin --template auv3` | AUv3 host `.app` + `aumu` `.appex` subclassing `LyrebirdAudioUnit`. Entitlements for both. Subtype + manufacturer pre-filled (manufacturer = `LYRB` placeholder — rewrite for distribution) |
| `shoegaze-ios` | `lyrebird new MyRig --template shoegaze-ios --shoegaze-path <path>` | iOS guitar-pedalboard `.app` (SwiftUI + `iOSAudioDriver`). Generates a full `.xcodeproj` with a `ShoeGazeView` root view and an `@Observable` app model wiring `AVAudioSession` + `ShoeGaze`. Default board: Overdrive→Delay→Reverb→Modulation fed by the built-in test loop. Adds `LyrebirdShoeGaze` + `LyrebirdShoeGazeUI` to the project's SPM deps. Requires `--shoegaze-path` until `LyrebirdShoeGaze` is published |
Each Xcode-project template lays out:
-11
View File
@@ -108,17 +108,6 @@ All six Tier 3 templates compile in projects depending on Lyrebird as a Swift
Package and are reported as `OK (external)` by the validator. None require
LyrebirdUI.
### Tier 4 — sample-project templates (ShoeGaze)
| Template | Generates | Use when |
|---|---|---|
| **ShoeGaze Pedal** | `final class <Name>: Pedal` with an `@UIParam` knob, a stubbed `effect(_:)` returning the processed mono signal, and an `effectKnobs` override publishing its knobs | Adding a new guitar pedal to a project using the ShoeGaze sample package. The base `Pedal` handles wet/dry `mix`, click-free `bypass`, and `level`; `PedalView` renders the published knobs. |
The ShoeGaze Pedal template requires the **LyrebirdShoeGaze** package (it imports
`LyrebirdShoeGaze` and `LyrebirdUI`), not just core Lyrebird. Use it inside a
project scaffolded with `lyrebird new --template shoegaze`, or any target that
depends on the ShoeGaze package. See [`../stdlib/shoegaze.md`](../stdlib/shoegaze.md).
Each template prompts for a name in Xcode's dialog. The name becomes both the file
name and the top-level identifier inside the file.