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 noise generator extending NoiseBase. Inherits rngState and _mulAdd, and uses the xorshift64 PRNG. Audio variant draws one sample per output sample; Control variant draws once per audio block and emits a linear ramp.</string>
<key>Summary</key>
<string>Lyrebird Noise Generator (NoiseBase subclass)</string>
<key>SortOrder</key>
<string>14</string>
<key>AllowedTypes</key>
<array>
<string>public.swift-source</string>
</array>
<key>DefaultCompletionName</key>
<string>MyNoise</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>Noise name:</string>
<key>Description</key>
<string>Name of the noise enum (also used as the file name).</string>
<key>Type</key>
<string>text</string>
<key>Default</key>
<string>MyNoise</string>
</dict>
</array>
</dict>
</plist>
@@ -0,0 +1,138 @@
//___FILEHEADER___
//
// In-tree template — drop this file under Sources/Lyrebird/Generators/Noise/.
// Extends `NoiseBase`, whose designated init is module-internal, so this
// template is not usable from a project that depends on Lyrebird as a package.
// External users should start from the basic `LyrebirdGenerator` template and
// declare rngState + xorshift64 inline.
// MARK: - ___FILEBASENAMEASIDENTIFIER___
/// One-line description of ___FILEBASENAMEASIDENTIFIER___.
///
/// Extends `NoiseBase` so `rngState: UInt64` and `_mulAdd` are inherited.
/// Use `xorshift64Next(&rngState)` to draw a `[-1, 1]` sample per call.
///
/// Each instance is independently seeded — concurrent instances produce
/// uncorrelated output.
///
/// ## Usage
/// ```swift
/// let n = ___FILEBASENAMEASIDENTIFIER___.Audio()
/// let n = ___FILEBASENAMEASIDENTIFIER___.Audio(seed: 42) // deterministic for tests
/// ```
public enum ___FILEBASENAMEASIDENTIFIER___ {
/// Shared PRNG state and output buffer for both rate variants.
public class _Base: NoiseBase {
override init(
initialRngState: UInt64,
mul: any ValidGeneratorInput = 1.0,
add: any ValidGeneratorInput = 0.0
) {
super.init(initialRngState: initialRngState, mul: mul, add: add)
}
/// Draw one sample in `[-1, 1]`. Replace this body with any
/// distribution-shaping logic — clip, fold, threshold, etc.
func nextSample() -> Double { xorshift64Next(&rngState) }
}
/// Audio-rate ___FILEBASENAMEASIDENTIFIER___.
///
/// - Parameters:
/// - seed: PRNG seed. Defaults to a time-derived value for unique instances.
/// Pass an explicit seed for reproducible test output.
/// - mul: Output multiplier applied after synthesis. Defaults to `1.0`.
/// - add: Offset added after multiplier. Defaults to `0.0`.
public final class Audio: _Base, AudioGenerator {
/// - Parameters:
/// - seed: PRNG seed.
/// - mul: Output multiplier.
/// - add: Output offset.
public init(
seed: UInt64? = nil,
mul: any ValidGeneratorInput = 1.0,
add: any ValidGeneratorInput = 0.0
) {
// Pick a unique mix constant so this Audio variant doesn't correlate
// with sibling Control / sibling generators when both default-seed
// within the same nanosecond.
let audioMixConstant: UInt64 = 0xA110_AAAA_5A5A_3C3C
let initialRngState = lyrebirdSeedXorshift64(from: seed, mixConstant: audioMixConstant)
super.init(initialRngState: initialRngState, mul: mul, add: add)
}
public func _computeSamples(
graph: SynthGraph,
count: Int
) -> [[Double]] {
_checkCount(count)
for i: Int in 0..<count {
_result[0][i] = nextSample()
}
_mulAdd.applyIfNeeded(to: &_result, graph: graph, count: count)
return _result
}
}
/// Control-rate ___FILEBASENAMEASIDENTIFIER___ — draws one new value per
/// audio block, emits a linear ramp to the new target. Override
/// `calculatedSamples` bypasses the sub-block loop so the draw rate stays
/// at one per audio block regardless of `controlBlockSize`.
///
/// - Parameters:
/// - seed: PRNG seed. Defaults to a time-derived value.
/// - 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
private var _rampTarget: Double = 0.0
/// - Parameters:
/// - seed: PRNG seed.
/// - mul: Output multiplier.
/// - add: Output offset.
public init(
seed: UInt64? = nil,
mul: any ValidGeneratorInput = 1.0,
add: any ValidGeneratorInput = 0.0
) {
let controlMixConstant: UInt64 = 0xB220_BBBB_A5A5_C3C3
let initialRngState = lyrebirdSeedXorshift64(from: seed, mixConstant: controlMixConstant)
super.init(initialRngState: initialRngState, mul: mul, add: add)
_setupSubBlockBuffer()
}
// Bypass sub-block loop: one draw per audio block regardless of cbs.
public func calculatedSamples(
graph: SynthGraph,
count: Int
) -> [[Double]] {
_calculatedSamplesBlockRate(graph: graph, count: count)
}
public func _computeSamples(
graph: SynthGraph,
count: Int
) -> [[Double]] {
_checkCount(count)
let target: Double = nextSample()
let rampStart: Double = _rampTarget
_rampTarget = target
guard count > 0 else { return _result }
previousOutputValue = fillRampedResult(
into: &_result, from: rampStart, to: target, mulAdd: _mulAdd, graph: graph, count: count)
return _result
}
}
}
extension ___FILEBASENAMEASIDENTIFIER___: GeneratorEnum {
public typealias AudioType = ___FILEBASENAMEASIDENTIFIER___.Audio
public typealias ControlType = ___FILEBASENAMEASIDENTIFIER___.Control
}