1.0.0 release
This commit is contained in:
Vendored
+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 pure-value source conforming to DemandGenerator. Consumed by Demand.Audio / Demand.Control pullers — one value per ≤0→>0 trigger edge. Owned by exactly one puller. Provide nextValue(), reset(), and isExhausted.</string>
|
||||
<key>Summary</key>
|
||||
<string>Lyrebird Demand Generator (DemandGenerator conformer)</string>
|
||||
<key>SortOrder</key>
|
||||
<string>20</string>
|
||||
<key>AllowedTypes</key>
|
||||
<array>
|
||||
<string>public.swift-source</string>
|
||||
</array>
|
||||
<key>DefaultCompletionName</key>
|
||||
<string>MyDemand</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>DemandGenerator name:</string>
|
||||
<key>Description</key>
|
||||
<string>Name of the DemandGenerator class (also used as the file name).</string>
|
||||
<key>Type</key>
|
||||
<string>text</string>
|
||||
<key>Default</key>
|
||||
<string>MyDemand</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
//___FILEHEADER___
|
||||
|
||||
import Foundation
|
||||
import LyrebirdSynth
|
||||
|
||||
// MARK: - ___FILEBASENAMEASIDENTIFIER___
|
||||
|
||||
/// One-line description of ___FILEBASENAMEASIDENTIFIER___.
|
||||
///
|
||||
/// A `DemandGenerator` is a pull-based value source — it is **not** a `Generator`
|
||||
/// and does not appear in the audio graph itself. It is consumed by a demand
|
||||
/// puller (`Demand.Audio` or `Demand.Control`) which calls `nextValue()` on each
|
||||
/// `≤ 0 → > 0` trigger edge. Each instance is owned by exactly one puller.
|
||||
///
|
||||
/// ## Usage
|
||||
/// ```swift
|
||||
/// let demand = ___FILEBASENAMEASIDENTIFIER___()
|
||||
/// let pitchSeq = Demand.Control(
|
||||
/// trig: Impulse.Control(freq: 2.0),
|
||||
/// demand: demand
|
||||
/// )
|
||||
/// let osc = OscSin.Audio(freq: pitchSeq)
|
||||
/// ```
|
||||
public final class ___FILEBASENAMEASIDENTIFIER___: DemandGenerator {
|
||||
|
||||
// MARK: - State
|
||||
|
||||
/// Replace these stored properties with whatever state your value source needs
|
||||
/// (current step, RNG state, table indices, etc.). State is mutated only inside
|
||||
/// `nextValue()` and `reset()` — both run on the RT thread side of the demand
|
||||
/// puller, so keep everything allocation-free and lock-free.
|
||||
private var _step: Int = 0
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
public init() {
|
||||
// Initialise state. No allocation paths should run after this point on the
|
||||
// RT thread.
|
||||
}
|
||||
|
||||
// MARK: - DemandGenerator
|
||||
|
||||
/// `true` once this source has produced its final value. Returning `nil` from
|
||||
/// `nextValue()` is also acceptable — pullers stop pulling when either signals
|
||||
/// exhaustion.
|
||||
public var isExhausted: Bool {
|
||||
// TODO: return true when this source has no more values to produce.
|
||||
return false
|
||||
}
|
||||
|
||||
/// Returns the next value to emit, or `nil` if exhausted.
|
||||
public func nextValue() -> Double? {
|
||||
// TODO: produce the next value. Replace this body with your formula.
|
||||
let value: Double = Double(_step)
|
||||
_step += 1
|
||||
return value
|
||||
}
|
||||
|
||||
/// Reset internal state so the next `nextValue()` produces the source's first
|
||||
/// value again. Called by demand pullers when their trigger source resets.
|
||||
public func reset() {
|
||||
_step = 0
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user