1.0.0 release
This commit is contained in:
+44
@@ -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 LyrebirdTask factory function — emits a closure-bodied LyrebirdTask that schedules Synthesizer events on a background thread, with pause/resume/stop support. Use the LyrebirdRoutineContext to add nodes and wait between events.</string>
|
||||
<key>Summary</key>
|
||||
<string>Lyrebird Task (scheduling factory)</string>
|
||||
<key>SortOrder</key>
|
||||
<string>12</string>
|
||||
<key>AllowedTypes</key>
|
||||
<array>
|
||||
<string>public.swift-source</string>
|
||||
</array>
|
||||
<key>DefaultCompletionName</key>
|
||||
<string>MyTask</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>Task name:</string>
|
||||
<key>Description</key>
|
||||
<string>Name of the task factory (also used as the file name). The factory function is named make<Name>().</string>
|
||||
<key>Type</key>
|
||||
<string>text</string>
|
||||
<key>Default</key>
|
||||
<string>MyTask</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
Vendored
+61
@@ -0,0 +1,61 @@
|
||||
//___FILEHEADER___
|
||||
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
|
||||
// MARK: - ___FILEBASENAMEASIDENTIFIER___
|
||||
|
||||
/// Factory for a `LyrebirdTask` that runs a scheduled-event loop on its own
|
||||
/// background thread.
|
||||
///
|
||||
/// The task body receives a `LyrebirdRoutineContext` providing:
|
||||
/// - `add(_:)` — attach a Synthesizer to the engine
|
||||
/// - `wait(seconds:)` — sleep, respecting `pause()` / `stop()`
|
||||
/// - `wait(beats:tempo:)` — tempo-aware sleep
|
||||
///
|
||||
/// Throwing `LyrebirdRoutineError.stopped` (raised internally by `wait` when
|
||||
/// `stop()` is called) exits cleanly.
|
||||
///
|
||||
/// ## Usage
|
||||
/// ```swift
|
||||
/// let task = make___FILEBASENAMEASIDENTIFIER___()
|
||||
/// task.start(engine: engine)
|
||||
///
|
||||
/// task.pause() // freeze event stream
|
||||
/// task.resume() // continue from where it stopped
|
||||
/// task.stop() // exit the loop cleanly
|
||||
/// ```
|
||||
public func make___FILEBASENAMEASIDENTIFIER___() -> LyrebirdTask {
|
||||
LyrebirdTask { ctx in
|
||||
// Replace this with whatever event sequence the task should run.
|
||||
// The example below schedules one short Synthesizer every 250 ms
|
||||
// until `stop()` is called.
|
||||
while true {
|
||||
let note: ExampleNote = ExampleNote()
|
||||
ctx.add(note)
|
||||
try ctx.wait(seconds: 0.25)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Example Synthesizer used by the task
|
||||
|
||||
/// Minimal Synthesizer scheduled by `make___FILEBASENAMEASIDENTIFIER___`.
|
||||
/// Replace with your own Synthesizer type and remove this stub.
|
||||
private final class ExampleNote: SynthesizerBase {
|
||||
|
||||
@LiveParam var frequency: Double = 440.0
|
||||
|
||||
override func build() {
|
||||
let env = EnvelopeGen.Audio(
|
||||
envelope: Envelope(
|
||||
levels: [0.0, 1.0, 0.0],
|
||||
durations: [0.005, 0.2],
|
||||
curves: [.lin, .exponential]
|
||||
),
|
||||
doneAction: .freeNode
|
||||
)
|
||||
let osc = OscSin.Audio(freq: $frequency)
|
||||
output(bus: 0, source: osc * env * 0.2)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user