1.0.0 release

This commit is contained in:
2026-06-01 18:27:40 -07:00
parent b1ab0f102c
commit 1f20fcab20
1151 changed files with 230703 additions and 14 deletions
@@ -0,0 +1,44 @@
<?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 LyrebirdProcess factory function. Returns a configured process with an envelope-governed lifetime, an async body closure that adds synths and waits, and optional onRelease / onFinished callbacks. Equivalent to SuperCollider's ProcMod.</string>
<key>Summary</key>
<string>Lyrebird Process (envelope-governed audio process)</string>
<key>SortOrder</key>
<string>34</string>
<key>AllowedTypes</key>
<array>
<string>public.swift-source</string>
</array>
<key>DefaultCompletionName</key>
<string>MyProcess</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>Process name:</string>
<key>Description</key>
<string>Name of the process factory function (also used as the file name).</string>
<key>Type</key>
<string>text</string>
<key>Default</key>
<string>MyProcess</string>
</dict>
</array>
</dict>
</plist>
@@ -0,0 +1,90 @@
//___FILEHEADER___
import Foundation
import LyrebirdSynth
// MARK: - ___FILEBASENAMEASIDENTIFIER___
/// Factory for a self-contained `LyrebirdProcess`. The process allocates a
/// private route bus, spawns an envelope-driven synth that mixes from that
/// bus to `procOut`, and runs the `body` closure on an async task.
///
/// Lyrebird equivalent of SuperCollider's `ProcMod`.
///
/// ## Lifecycle
/// 1. `play(engine:)` — allocate resources, start the envelope + body task.
/// 2. While running — add synths via `ctx.add(_:)`, wait via `ctx.wait(_:)`,
/// mutate `amp` from any thread.
/// 3. `release()` — open the envelope gate; tail plays out, process auto-frees.
/// (Only meaningful when the envelope has a `releaseNode`.)
/// 4. `kill()` — force teardown regardless of envelope state.
///
/// ## Usage
/// ```swift
/// let factory = ___FILEBASENAMEASIDENTIFIER___()
/// let proc = factory.createProcess()
/// proc.play(engine: engine)
/// // …
/// proc.release() // graceful — runs the envelope tail
/// // or: proc.kill() // immediate
/// ```
public struct ___FILEBASENAMEASIDENTIFIER___: LyrebirdProcessFactory {
public init() {}
public func createProcess() -> LyrebirdProcess {
LyrebirdProcess(
id: "___FILEBASENAMEASIDENTIFIER___",
envelope: Envelope(
// 4-point envelope: attack → sustain → release → silence.
// releaseNode index 2 means "hold at level[2] until release() is called",
// then continue from there to the end.
levels: [0.0, 1.0, 0.6, 0.0],
durations: [0.05, 0.5, 1.5],
curves: [.sine, .exponential, .exponential],
releaseNode: 2
),
amp: 0.8,
ampLag: 0.02,
numChannels: 2,
procOut: 0, // hardware output; overridden by a parent EventList
target: .tail,
body: { ctx in
// The process body runs as an async Task. Schedule synths and
// wait between events. The task is cancelled on `release()` /
// `kill()` — `ctx.wait` re-throws CancellationError, which the
// surrounding LyrebirdProcess infrastructure handles cleanly.
//
// Replace the starter body below with your event sequence.
let synth: ExampleNote = ExampleNote()
ctx.add(synth)
await ctx.wait(0.1) // let the attack settle
},
onRelease: { ctx in
// Optional. Called on main thread when release() is invoked,
// before the envelope tail begins. Use to mutate / remove synths
// before the fade.
_ = ctx
},
onFinished: {
// Optional. Called on main thread after the group and route bus
// are freed. Resources are already gone — no context available.
}
)
}
}
// MARK: - Example Synthesizer used by the process body
/// Replace this stub with your own Synthesizer. The body closure above adds
/// one instance; rewrite the body to schedule whatever pattern fits your
/// process.
private final class ExampleNote: SynthesizerBase {
@LiveParam var frequency: Double = 440.0
override func build() {
let osc = OscSin.Audio(freq: $frequency)
output(bus: 0, source: osc * 0.5)
}
}