f29ab609bd
Pedals (each registered, with PedalType static, enclosure color, palette order, summary, and tests): - Chorus: true-stereo widener (two anti-phase modulated delay lines), distinct from the mono-summed Modulation chorus. - Sustainer: one-knob compressor (sustain drives threshold/ratio/makeup via LinLin) + tone low-pass. - Ring Modulator: dry × tunable sine carrier. Pedal-info UI: - Pedal.summary (open var, overridden by all 21 pedals; mandatory going forward). - PedalRegistry.summary(for:) for the picker. - PedalPaletteView rows show the summary as a subtitle. - PedalView gains an ⓘ button → PedalInfoView sheet showing the description and the effect controls (knobs/sliders/switches) with ranges/options — excludes the common Mix/Level/bypass. Tests: per-pedal build/param-change/knob-list; every built-in pedal has a non-empty summary; info excludes common controls. 183 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
65 lines
2.6 KiB
Swift
65 lines
2.6 KiB
Swift
// SustainerPedalTests.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import Testing
|
|
import Foundation
|
|
import LyrebirdSynth
|
|
import LyrebirdUI
|
|
@testable import LyrebirdShoeGaze
|
|
|
|
@MainActor
|
|
@Suite("SustainerPedal")
|
|
struct SustainerPedalTests {
|
|
|
|
private func render(configure: (SustainerPedal) -> Void = { _ in }) throws -> [Float] {
|
|
let renderDuration: Double = 0.1
|
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(duration: renderDuration, numAudioBuses: 64)
|
|
defer { try? FileManager.default.removeItem(at: url) }
|
|
|
|
let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
|
let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
|
defer {
|
|
engine.busAllocator.releaseAudioBus(srcBus)
|
|
engine.busAllocator.releaseAudioBus(dstBus)
|
|
}
|
|
|
|
let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index)
|
|
let pedal: SustainerPedal = SustainerPedal(inputBus: srcBus.index, outputBus: dstBus.index)
|
|
configure(pedal)
|
|
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index)
|
|
try engine.add(source)
|
|
try engine.add(pedal, position: NodePosition.after(source))
|
|
try engine.add(master, position: NodePosition.after(pedal))
|
|
try engine.start()
|
|
return readStereoCAF(url: url)
|
|
}
|
|
|
|
@Test func buildsAndProducesNonSilentOutput() throws {
|
|
let samples: [Float] = try render()
|
|
#expect(!samples.isEmpty)
|
|
#expect(hasNonSilentOutput(samples), "SustainerPedal produced silence")
|
|
}
|
|
|
|
@Test func exposesSustainAndToneKnobs() throws {
|
|
let pedal: SustainerPedal = SustainerPedal()
|
|
#expect(pedal.effectKnobs.map { $0.label } == ["Sustain", "Tone"])
|
|
}
|
|
|
|
@Test func sustainAmountChangesOutput() throws {
|
|
// Min vs max sustain drive the compressor very differently → measurably different output.
|
|
let gentle: [Float] = try render { $0.sustain = 0.0 }
|
|
let squashed: [Float] = try render { $0.sustain = 10.0 }
|
|
#expect(hasNonSilentOutput(gentle) && hasNonSilentOutput(squashed))
|
|
|
|
let skip: Int = 1024, window: Int = 2048
|
|
guard gentle.count >= skip + window, squashed.count >= skip + window else { return }
|
|
let ssd: Double = zip(gentle[skip..<(skip + window)], squashed[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
|
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
|
}
|
|
#expect(ssd > 0, "sustain knob had no effect on output")
|
|
}
|
|
}
|