Add Limiter, Noise Gate, and Graphic EQ pedals + vertical-fader UI control

Three new pedals:
- LimiterPedal: linear boost gain stage into a LookAheadLimiter brick-wall
  ceiling. Reads engine sampleRate injected by PedalBoard.add at build time.
- NoiseGatePedal: AmplitudeFollower -> hysteretic Schmidt gate -> LinLin floor
  map -> Lag smoothing. Tuneable residual floor when the gate is closed.
- GraphicEQPedal: five cascaded RBJ filters (low/high shelf + three peaking
  mids) with per-band dB gains and a linear master output gain.

New UI control:
- PedalSlider descriptor and Pedal.effectSliders hook, alongside effectKnobs
  and effectSwitches.
- VerticalParameterSlider: a vertical fader bound to a UIParamNode.
- PedalView renders the fader bank and widens the enclosure to fit it.

Persistence/registry:
- PedalState.sliderValues (decodeIfPresent for backward compatibility); capture
  and apply in Pedal+Preset.
- Registry entries and palette ordering for all three pedals.

Tests: non-silent builds, limiter ceiling enforcement, gate open/closed/unity
floor power ratios, EQ flat output, global-gain scaling, and 6-slider preset
round-trip.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-23 11:22:14 -07:00
parent b08ce4d999
commit 69f50b2037
14 changed files with 987 additions and 4 deletions
@@ -0,0 +1,92 @@
// NoiseGatePedalTests.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("NoiseGatePedal")
struct NoiseGatePedalTests {
/// Renders a `NoiseGatePedal` through an offline engine and returns the interleaved output.
private func render(
threshold: Double,
floor: Double
) throws -> [Float] {
let renderDuration: Double = 0.1
let sampleRate: Double = 44100.0
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
duration: renderDuration,
sampleRate: sampleRate
)
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: NoiseGatePedal = NoiseGatePedal(
inputBus: srcBus.index,
outputBus: dstBus.index
)
pedal.threshold = threshold
pedal.floor = floor
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, sampleRate: sampleRate)
}
/// Sum of squared samples — a proxy for output power.
private func power(_ samples: [Float]) -> Double {
samples.reduce(0.0) { acc, s in
let v: Double = Double(s)
return acc + v * v
}
}
@Test func openGatePassesSignal() throws {
// A threshold of 0 keeps the gate open — the loop signal should pass through.
let samples: [Float] = try render(threshold: 0.0, floor: 0.0)
#expect(!samples.isEmpty)
#expect(hasNonSilentOutput(samples), "Open gate produced silence")
}
@Test func closedGateWithZeroFloorStronglyAttenuates() throws {
// An impossibly high threshold keeps the gate closed; with floor 0 the output
// should be far quieter than the open-gate render.
let openSamples: [Float] = try render(threshold: 0.0, floor: 0.0)
let closedSamples: [Float] = try render(threshold: 0.95, floor: 0.0)
let openPower: Double = power(openSamples)
let closedPower: Double = power(closedSamples)
#expect(openPower > 0, "Open gate render was silent")
// Closed gate should suppress nearly all energy.
let suppressionFactor: Double = 0.05
#expect(
closedPower < openPower * suppressionFactor,
"Closed gate did not attenuate: open=\(openPower) closed=\(closedPower)"
)
}
@Test func unityFloorLeavesSignalUntouched() throws {
// floor = 1 means no gating regardless of threshold — output stays present.
let samples: [Float] = try render(threshold: 0.95, floor: 1.0)
#expect(hasNonSilentOutput(samples), "Unity-floor gate muted the signal")
}
}