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>
59 lines
2.3 KiB
Swift
59 lines
2.3 KiB
Swift
// RingModulatorPedalTests.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("RingModulatorPedal")
|
|
struct RingModulatorPedalTests {
|
|
|
|
private func render(frequency: Double) 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: RingModulatorPedal = RingModulatorPedal(inputBus: srcBus.index, outputBus: dstBus.index)
|
|
pedal.frequency = frequency
|
|
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(frequency: 220.0)
|
|
#expect(!samples.isEmpty)
|
|
#expect(hasNonSilentOutput(samples), "RingModulatorPedal produced silence")
|
|
}
|
|
|
|
@Test func frequencyChangesOutput() throws {
|
|
let low: [Float] = try render(frequency: 100.0)
|
|
let high: [Float] = try render(frequency: 800.0)
|
|
#expect(hasNonSilentOutput(low) && hasNonSilentOutput(high))
|
|
|
|
let skip: Int = 1024, window: Int = 2048
|
|
guard low.count >= skip + window, high.count >= skip + window else { return }
|
|
let ssd: Double = zip(low[skip..<(skip + window)], high[skip..<(skip + window)]).reduce(0.0) { acc, pair in
|
|
let d: Double = Double(pair.0 - pair.1); return acc + d * d
|
|
}
|
|
#expect(ssd > 0, "carrier frequency had no effect on output")
|
|
}
|
|
}
|