Add Flanger, Vibrato, and Distortion pedals; 6th intervals on Harmonizer
- Flanger: wraps Lyrebird Flanger (Rate/Depth/Feedback), run fully wet. - Vibrato: sine-swept delay line, fully wet pitch wobble (Rate/Depth). - Distortion: DC-block → tanh drive → tone LPF → hard clip (Drive/Tone); sits between Overdrive and Fuzz. - Harmonizer interval pickers gain minor/major sixths above and below. Each registered (PedalType + registry + enclosure color + palette slot) with build/non-silent + parameter-change + registry tests. Suite 227. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
// DistortionPedalTests.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("DistortionPedal")
|
||||
struct DistortionPedalTests {
|
||||
|
||||
private func render(
|
||||
configure: (DistortionPedal) -> Void
|
||||
) throws -> [Float] {
|
||||
let renderDuration: Double = 0.2
|
||||
let numAudioBuses: Int = 64
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: renderDuration,
|
||||
numAudioBuses: numAudioBuses
|
||||
)
|
||||
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: DistortionPedal = DistortionPedal(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)
|
||||
}
|
||||
|
||||
private func windowedSSD(_ a: [Float], _ b: [Float]) -> Double {
|
||||
let skipSamples: Int = 2048
|
||||
let windowSize: Int = 2048
|
||||
guard a.count >= skipSamples + windowSize,
|
||||
b.count >= skipSamples + windowSize else { return 0.0 }
|
||||
let aWindow: ArraySlice<Float> = a[skipSamples..<(skipSamples + windowSize)]
|
||||
let bWindow: ArraySlice<Float> = b[skipSamples..<(skipSamples + windowSize)]
|
||||
return zip(aWindow, bWindow).reduce(0.0) { acc, pair in
|
||||
let diff: Double = Double(pair.0 - pair.1)
|
||||
return acc + diff * diff
|
||||
}
|
||||
}
|
||||
|
||||
@Test func buildsAndProducesNonSilentOutput() throws {
|
||||
let samples: [Float] = try render { _ in }
|
||||
#expect(!samples.isEmpty)
|
||||
#expect(hasNonSilentOutput(samples), "distortion output was silent")
|
||||
}
|
||||
|
||||
@Test func driveChangesOutput() throws {
|
||||
let low: [Float] = try render { pedal in pedal.drive = 2.0 }
|
||||
let high: [Float] = try render { pedal in pedal.drive = 45.0 }
|
||||
#expect(hasNonSilentOutput(high), "high-drive distortion was silent")
|
||||
#expect(windowedSSD(low, high) > 0, "changing drive did not change the output")
|
||||
}
|
||||
|
||||
@Test func toneChangesOutput() throws {
|
||||
let dark: [Float] = try render { pedal in pedal.drive = 30.0; pedal.tone = 700.0 }
|
||||
let bright: [Float] = try render { pedal in pedal.drive = 30.0; pedal.tone = 5500.0 }
|
||||
#expect(hasNonSilentOutput(bright), "bright distortion was silent")
|
||||
#expect(windowedSSD(dark, bright) > 0, "changing tone did not change the output")
|
||||
}
|
||||
|
||||
@Test func exposesDriveToneKnobs() throws {
|
||||
let pedal: DistortionPedal = DistortionPedal()
|
||||
let labels: [String] = pedal.effectKnobs.map { $0.label }
|
||||
#expect(labels == ["Drive", "Tone"])
|
||||
}
|
||||
|
||||
@Test func registeredInBuiltInRegistry() throws {
|
||||
let pedal: Pedal? = PedalRegistry.makePedal(type: "Distortion")
|
||||
#expect(pedal is DistortionPedal)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
// FlangerPedalTests.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("FlangerPedal")
|
||||
struct FlangerPedalTests {
|
||||
|
||||
private func render(
|
||||
configure: (FlangerPedal) -> Void
|
||||
) throws -> [Float] {
|
||||
let renderDuration: Double = 0.2
|
||||
let numAudioBuses: Int = 64
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: renderDuration,
|
||||
numAudioBuses: numAudioBuses
|
||||
)
|
||||
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: FlangerPedal = FlangerPedal(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)
|
||||
}
|
||||
|
||||
private func windowedSSD(_ a: [Float], _ b: [Float]) -> Double {
|
||||
let skipSamples: Int = 2048
|
||||
let windowSize: Int = 2048
|
||||
guard a.count >= skipSamples + windowSize,
|
||||
b.count >= skipSamples + windowSize else { return 0.0 }
|
||||
let aWindow: ArraySlice<Float> = a[skipSamples..<(skipSamples + windowSize)]
|
||||
let bWindow: ArraySlice<Float> = b[skipSamples..<(skipSamples + windowSize)]
|
||||
return zip(aWindow, bWindow).reduce(0.0) { acc, pair in
|
||||
let diff: Double = Double(pair.0 - pair.1)
|
||||
return acc + diff * diff
|
||||
}
|
||||
}
|
||||
|
||||
@Test func buildsAndProducesNonSilentOutput() throws {
|
||||
let samples: [Float] = try render { _ in }
|
||||
#expect(!samples.isEmpty)
|
||||
#expect(hasNonSilentOutput(samples), "flanger output was silent")
|
||||
}
|
||||
|
||||
@Test func depthChangesOutput() throws {
|
||||
let shallow: [Float] = try render { pedal in pedal.depth = 0.1; pedal.mix = 1.0 }
|
||||
let deep: [Float] = try render { pedal in pedal.depth = 0.95; pedal.mix = 1.0 }
|
||||
#expect(hasNonSilentOutput(deep), "deep flanger was silent")
|
||||
#expect(windowedSSD(shallow, deep) > 0, "changing depth did not change the output")
|
||||
}
|
||||
|
||||
@Test func feedbackChangesOutput() throws {
|
||||
let dry: [Float] = try render { pedal in pedal.feedback = 0.0; pedal.mix = 1.0 }
|
||||
let resonant: [Float] = try render { pedal in pedal.feedback = 0.85; pedal.mix = 1.0 }
|
||||
#expect(hasNonSilentOutput(resonant), "resonant flanger was silent")
|
||||
#expect(windowedSSD(dry, resonant) > 0, "changing feedback did not change the output")
|
||||
}
|
||||
|
||||
@Test func exposesRateDepthFeedbackKnobs() throws {
|
||||
let pedal: FlangerPedal = FlangerPedal()
|
||||
let labels: [String] = pedal.effectKnobs.map { $0.label }
|
||||
#expect(labels == ["Rate", "Depth", "Feedback"])
|
||||
}
|
||||
|
||||
@Test func registeredInBuiltInRegistry() throws {
|
||||
let pedal: Pedal? = PedalRegistry.makePedal(type: "Flanger")
|
||||
#expect(pedal is FlangerPedal)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
// VibratoPedalTests.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("VibratoPedal")
|
||||
struct VibratoPedalTests {
|
||||
|
||||
private func render(
|
||||
configure: (VibratoPedal) -> Void
|
||||
) throws -> [Float] {
|
||||
let renderDuration: Double = 0.2
|
||||
let numAudioBuses: Int = 64
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: renderDuration,
|
||||
numAudioBuses: numAudioBuses
|
||||
)
|
||||
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: VibratoPedal = VibratoPedal(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)
|
||||
}
|
||||
|
||||
private func windowedSSD(_ a: [Float], _ b: [Float]) -> Double {
|
||||
let skipSamples: Int = 2048
|
||||
let windowSize: Int = 2048
|
||||
guard a.count >= skipSamples + windowSize,
|
||||
b.count >= skipSamples + windowSize else { return 0.0 }
|
||||
let aWindow: ArraySlice<Float> = a[skipSamples..<(skipSamples + windowSize)]
|
||||
let bWindow: ArraySlice<Float> = b[skipSamples..<(skipSamples + windowSize)]
|
||||
return zip(aWindow, bWindow).reduce(0.0) { acc, pair in
|
||||
let diff: Double = Double(pair.0 - pair.1)
|
||||
return acc + diff * diff
|
||||
}
|
||||
}
|
||||
|
||||
@Test func buildsAndProducesNonSilentOutput() throws {
|
||||
let samples: [Float] = try render { _ in }
|
||||
#expect(!samples.isEmpty)
|
||||
#expect(hasNonSilentOutput(samples), "vibrato output was silent")
|
||||
}
|
||||
|
||||
@Test func depthChangesOutput() throws {
|
||||
let shallow: [Float] = try render { pedal in pedal.depth = 0.0006 }
|
||||
let deep: [Float] = try render { pedal in pedal.depth = 0.006 }
|
||||
#expect(hasNonSilentOutput(deep), "deep vibrato was silent")
|
||||
#expect(windowedSSD(shallow, deep) > 0, "changing depth did not change the output")
|
||||
}
|
||||
|
||||
@Test func exposesRateDepthKnobs() throws {
|
||||
let pedal: VibratoPedal = VibratoPedal()
|
||||
let labels: [String] = pedal.effectKnobs.map { $0.label }
|
||||
#expect(labels == ["Rate", "Depth"])
|
||||
}
|
||||
|
||||
@Test func registeredInBuiltInRegistry() throws {
|
||||
let pedal: Pedal? = PedalRegistry.makePedal(type: "Vibrato")
|
||||
#expect(pedal is VibratoPedal)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user