// LiveParamRampOriginTests.swift // Lyrebird // // Copyright (c) 2026 Joshua Parmenter / realizedsound // SPDX-License-Identifier: MIT import Testing @testable @_spi(LyrebirdExtensions) import LyrebirdSynth /// A synth whose only output is a `@UIParam` written straight to a bus, so a rendered block /// reveals the parameter's delivered ramp. Declaration default `0.1`. @MainActor private final class UIParamProbe: SynthesizerBase { @UIParam var p: Double = 0.1 let bus: Int init(bus: Int = 0) { self.bus = bus; super.init() } override func build() { output(bus: bus, source: $p) } } /// Same, but backed by `@LiveParam` (`ParameterNode`) — a separate priming code path from /// `@UIParam`'s `UIParamNode` delegation. @MainActor private final class LiveParamProbe: SynthesizerBase { @LiveParam var p: Double = 0.1 let bus: Int init(bus: Int = 0) { self.bus = bus; super.init() } override func build() { output(bus: bus, source: $p) } } @MainActor @Suite("Live parameter ramp origin") struct LiveParamRampOriginTests { let engine: SynthesisEngine = makeTestEngine(blockSize: 16) init() throws { try engine.start() } @Test func uiParamAssignedAfterConstructionIsDeliveredFlat() throws { // Assign AFTER construction (declaration default 0.1) but BEFORE the first render. Without // priming at add time the first block would ramp 0.1 → 0.9; the fix primes the ramp origin // when the synth is added, so the block is flat at 0.9 from sample 0. let probe: UIParamProbe = UIParamProbe(bus: 0) probe.p = 0.9 try engine.add(probe) engine.processBlock(inputSamples: []) for i: Int in 0..