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:
@@ -28,6 +28,9 @@ private func enclosureColor(for displayName: String) -> Color {
|
||||
case "Auto-Wah": return Color(red: 0.80, green: 0.62, blue: 0.10) // gold
|
||||
case "Feedback Delay": return Color(red: 0.48, green: 0.30, blue: 0.14) // tape sepia
|
||||
case "Multi-Tap Delay": return Color(red: 0.08, green: 0.48, blue: 0.68) // cyan
|
||||
case "Limiter": return Color(red: 0.62, green: 0.16, blue: 0.20) // brick red
|
||||
case "Noise Gate": return Color(red: 0.24, green: 0.26, blue: 0.30) // gunmetal
|
||||
case "Graphic EQ": return Color(red: 0.14, green: 0.40, blue: 0.50) // deep teal
|
||||
default: return Color(red: 0.36, green: 0.36, blue: 0.38) // steel gray
|
||||
}
|
||||
}
|
||||
@@ -184,6 +187,11 @@ public struct PedalView: View {
|
||||
private static let screwInset: CGFloat = 6
|
||||
private static let knobColumnCount: Int = 3
|
||||
private static let knobSpacing: CGFloat = 10
|
||||
/// Horizontal gap between adjacent vertical faders in the slider bank.
|
||||
private static let sliderBankSpacing: CGFloat = 4
|
||||
/// Approximate per-fader footprint (matches `VerticalParameterSlider.controlWidth`),
|
||||
/// used to widen the enclosure so a wide bank (e.g. a 6-band EQ) is never clipped.
|
||||
private static let sliderBankItemWidth: CGFloat = 28
|
||||
/// Horizontal gap between the Level knob and the bypass control in the bottom row.
|
||||
private static let bottomControlsSpacing: CGFloat = 18
|
||||
private static let sectionSpacing: CGFloat = 14
|
||||
@@ -224,6 +232,9 @@ public struct PedalView: View {
|
||||
public var body: some View {
|
||||
let accent: Color = enclosureColor(for: pedal.displayName)
|
||||
let darkAccent: Color = accent.opacity(PedalView.enclosureGradientDarkFraction)
|
||||
// Evaluate the (computed) slider descriptors once per render — both the bank and
|
||||
// the enclosure-width calculation consume the same array.
|
||||
let sliders: [PedalSlider] = pedal.effectSliders
|
||||
|
||||
ZStack(alignment: .topLeading) {
|
||||
// Enclosure fill with top-to-bottom gradient
|
||||
@@ -252,6 +263,7 @@ public struct PedalView: View {
|
||||
namePlate
|
||||
knobGrid
|
||||
switchRow
|
||||
sliderBank(sliders)
|
||||
Spacer(minLength: 0)
|
||||
bottomControls
|
||||
}
|
||||
@@ -260,7 +272,7 @@ public struct PedalView: View {
|
||||
// Corner screws — overlaid at the four corners
|
||||
screwCorners
|
||||
}
|
||||
.frame(width: PedalView.enclosureWidth)
|
||||
.frame(width: enclosureWidth(for: sliders))
|
||||
.shadow(
|
||||
color: Color.black.opacity(PedalView.shadowOpacity),
|
||||
radius: PedalView.shadowRadius,
|
||||
@@ -332,6 +344,32 @@ public struct PedalView: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// Row of vertical faders drawn from `pedal.effectSliders`, beneath the switch row.
|
||||
/// Renders nothing when the pedal publishes no sliders.
|
||||
@ViewBuilder
|
||||
private func sliderBank(_ sliders: [PedalSlider]) -> some View {
|
||||
if !sliders.isEmpty {
|
||||
HStack(alignment: .top, spacing: PedalView.sliderBankSpacing) {
|
||||
ForEach(Array(sliders.enumerated()), id: \.offset) { pair in
|
||||
let slider: PedalSlider = pair.element
|
||||
VerticalParameterSlider(slider.label, node: slider.node, range: slider.range)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Enclosure width — the base stompbox width, widened to fit a wide vertical-fader bank
|
||||
/// (e.g. a multi-band graphic EQ) so its faders are never clipped.
|
||||
private func enclosureWidth(for sliders: [PedalSlider]) -> CGFloat {
|
||||
let sliderCount: Int = sliders.count
|
||||
guard sliderCount > 0 else { return PedalView.enclosureWidth }
|
||||
let bankContentWidth: CGFloat =
|
||||
CGFloat(sliderCount) * PedalView.sliderBankItemWidth
|
||||
+ CGFloat(max(0, sliderCount - 1)) * PedalView.sliderBankSpacing
|
||||
let needed: CGFloat = bankContentWidth + 2 * PedalView.enclosurePadding
|
||||
return max(PedalView.enclosureWidth, needed)
|
||||
}
|
||||
|
||||
/// Bottom control row: the `Level` knob, the bypass switch, and the `Mix` knob,
|
||||
/// side-by-side and centred — a symmetric knob-switch-knob footer shared by all pedals.
|
||||
private var bottomControls: some View {
|
||||
|
||||
Reference in New Issue
Block a user