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 Lyrebird Generator with both Audio-rate and Control-rate variants. Subclasses GeneratorBase and conforms to AudioGenerator / ControlGenerator. Includes the canonical _Base shared-state class, _checkCount guard, MulAddSpec wiring, and the sub-block linear-ramp pattern for the Control variant.</string>
<key>Summary</key>
<string>Lyrebird Generator (Audio + Control)</string>
<key>SortOrder</key>
<string>10</string>
<key>AllowedTypes</key>
<array>
<string>public.swift-source</string>
</array>
<key>DefaultCompletionName</key>
<string>MyGenerator</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>Generator name:</string>
<key>Description</key>
<string>Name of the Generator (also used as the file name).</string>
<key>Type</key>
<string>text</string>
<key>Default</key>
<string>MyGenerator</string>
</dict>
</array>
</dict>
</plist>
@@ -0,0 +1,132 @@
//___FILEHEADER___
import Foundation
@_spi(LyrebirdExtensions) import LyrebirdSynth
// MARK: - ___FILEBASENAMEASIDENTIFIER___
/// One-line description of ___FILEBASENAMEASIDENTIFIER___.
///
/// Longer explanation: what the generator does, formula, edge cases.
///
/// ## Usage
/// ```swift
/// let g = ___FILEBASENAMEASIDENTIFIER___.Audio(signal)
/// let g = ___FILEBASENAMEASIDENTIFIER___.Control(signal)
/// ```
public enum ___FILEBASENAMEASIDENTIFIER___ {
/// Shared state between Audio and Control variants.
///
/// Holds input references + MulAddSpec. Stored properties live here so the
/// two final classes share the same field layout (and the same designated init).
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
) {
inputSource = signal
_mulAdd = MulAddSpec(mul: mul, add: add)
// GeneratorBase.init() allocates _result with one mono row of
// lyrebirdDefaultResultBufferSize. Multi-channel generators call
// super.init(channels: N) instead.
}
}
/// Per-sample transform shared by Audio + Control. Replace this with the
/// generator's actual formula.
@inline(__always)
static func _transform(_ value: Double) -> Double {
// TODO: implement.
return value
}
/// Audio-rate ___FILEBASENAMEASIDENTIFIER___.
///
/// - Parameters:
/// - signal: Input signal.
/// - mul: Output multiplier. Defaults to `1.0`.
/// - add: Output offset. Defaults to `0.0`.
public final class Audio: _Base, AudioGenerator {
/// - Parameters:
/// - signal: Input signal.
/// - 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)
}
public func _computeSamples(
graph: SynthGraph,
count: Int
) -> [[Double]] {
_checkCount(count)
let block = inputSource.calculatedSamples(graph: graph, count: count).first ?? []
let n = block.count
for i: Int in 0..<count {
_result[0][i] = ___FILEBASENAMEASIDENTIFIER___._transform(i < n ? block[i] : 0.0)
}
_mulAdd.applyIfNeeded(to: &_result, graph: graph, count: count)
return _result
}
}
/// Control-rate ___FILEBASENAMEASIDENTIFIER___. Output is linearly interpolated
/// toward the block target.
///
/// - Parameters:
/// - signal: Input signal.
/// - 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 signal.
/// - 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 = ___FILEBASENAMEASIDENTIFIER___._transform(
inputSource.floatValue(graph: graph)
)
if !_mulAdd.isIdentity {
target = target * _mulAdd.mulInput.floatValue(graph: graph)
+ _mulAdd.addInput.floatValue(graph: graph)
}
guard count > 0 else { return _result }
let rampStart: Double = previousOutputValue
previousOutputValue = target
let step = (target - rampStart) / Double(count)
for i: Int in 0..<count {
_result[0][i] = rampStart + step * Double(i + 1)
}
return _result
}
}
}
extension ___FILEBASENAMEASIDENTIFIER___: GeneratorEnum {
public typealias AudioType = ___FILEBASENAMEASIDENTIFIER___.Audio
public typealias ControlType = ___FILEBASENAMEASIDENTIFIER___.Control
}