Add Chorus, Sustainer, Ring Modulator pedals + pedal-info UI
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>
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
// PedalInfoView.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import SwiftUI
|
||||
import LyrebirdUI
|
||||
import LyrebirdShoeGaze
|
||||
|
||||
/// An info panel for a single pedal: its description and the effect controls with their ranges.
|
||||
///
|
||||
/// Shows `pedal.summary` and lists the **effect** controls only — `effectKnobs` + `effectSliders`
|
||||
/// + `effectSwitches`, each with its value range or switch positions. The common Mix / Level /
|
||||
/// bypass controls are intentionally omitted (they behave the same on every pedal). Presented
|
||||
/// from the pedal's ⓘ button.
|
||||
public struct PedalInfoView: View {
|
||||
|
||||
// MARK: - Layout constants
|
||||
|
||||
private static let sectionSpacing: CGFloat = 16
|
||||
private static let rowSpacing: CGFloat = 8
|
||||
private static let labelColumnWidth: CGFloat = 110
|
||||
private static let summaryOpacity: Double = 0.85
|
||||
private static let valueOpacity: Double = 0.7
|
||||
private static let headerOpacity: Double = 0.5
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
private let pedal: Pedal
|
||||
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates an info panel for `pedal`.
|
||||
public init(pedal: Pedal) {
|
||||
self.pedal = pedal
|
||||
}
|
||||
|
||||
// MARK: - Body
|
||||
|
||||
public var body: some View {
|
||||
NavigationStack {
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: PedalInfoView.sectionSpacing) {
|
||||
if !pedal.summary.isEmpty {
|
||||
Text(pedal.summary)
|
||||
.font(.body)
|
||||
.foregroundStyle(.primary.opacity(PedalInfoView.summaryOpacity))
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
|
||||
if !controlRows.isEmpty {
|
||||
VStack(alignment: .leading, spacing: PedalInfoView.rowSpacing) {
|
||||
Text("CONTROLS")
|
||||
.font(.caption2.weight(.semibold))
|
||||
.foregroundStyle(.secondary.opacity(PedalInfoView.headerOpacity))
|
||||
ForEach(Array(controlRows.enumerated()), id: \.offset) { pair in
|
||||
controlRow(pair.element)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
.navigationTitle(pedal.displayName)
|
||||
#if !os(macOS)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
#endif
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .confirmationAction) {
|
||||
Button("Done") { dismiss() }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Control rows
|
||||
|
||||
private func controlRow(_ row: ControlRow) -> some View {
|
||||
HStack(alignment: .firstTextBaseline) {
|
||||
Text(row.label)
|
||||
.font(.callout.weight(.medium))
|
||||
.frame(width: PedalInfoView.labelColumnWidth, alignment: .leading)
|
||||
Text(row.value)
|
||||
.font(.callout.monospacedDigit())
|
||||
.foregroundStyle(.secondary.opacity(PedalInfoView.valueOpacity))
|
||||
Spacer(minLength: 0)
|
||||
}
|
||||
}
|
||||
|
||||
/// One displayed control: a label and its range / options string.
|
||||
private struct ControlRow {
|
||||
let label: String
|
||||
let value: String
|
||||
}
|
||||
|
||||
/// Effect controls only (knobs + sliders + switches), in display order.
|
||||
private var controlRows: [ControlRow] {
|
||||
var rows: [ControlRow] = []
|
||||
for knob: PedalKnob in pedal.effectKnobs {
|
||||
rows.append(ControlRow(label: knob.label, value: PedalInfoView.rangeText(knob.range)))
|
||||
}
|
||||
for slider: PedalSlider in pedal.effectSliders {
|
||||
rows.append(ControlRow(label: slider.label, value: PedalInfoView.rangeText(slider.range)))
|
||||
}
|
||||
for pedalSwitch: PedalSwitch in pedal.effectSwitches {
|
||||
let options: String = pedalSwitch.options.map { $0.title }.joined(separator: " / ")
|
||||
rows.append(ControlRow(label: pedalSwitch.label, value: options))
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
// MARK: - Formatting
|
||||
|
||||
/// Formats a value range as `"lo – hi"`, using integers when both bounds are whole.
|
||||
private static func rangeText(_ range: ClosedRange<Double>) -> String {
|
||||
"\(number(range.lowerBound)) – \(number(range.upperBound))"
|
||||
}
|
||||
|
||||
private static func number(_ value: Double) -> String {
|
||||
if value == value.rounded() {
|
||||
return String(format: "%.0f", value)
|
||||
}
|
||||
return String(format: "%.3g", value)
|
||||
}
|
||||
}
|
||||
@@ -41,13 +41,17 @@ public struct PedalPaletteView: View {
|
||||
private static let routingCaptionOpacity: Double = 0.5
|
||||
private static let routingCaptionFontSize: CGFloat = 10
|
||||
private static let addGlyphOpacity: Double = 0.4
|
||||
/// Vertical gap between a pedal row's name and its description subtitle.
|
||||
private static let rowSubtitleSpacing: CGFloat = 2
|
||||
/// Opacity of the pedal-row description subtitle.
|
||||
private static let summaryOpacity: Double = 0.55
|
||||
|
||||
/// Preferred display order for the built-in pedals. Any registered pedal not listed here is
|
||||
/// appended afterwards (sorted) so the palette never silently drops a newly added pedal.
|
||||
private static let preferredOrder: [String] = [
|
||||
"Overdrive", "Compressor", "Limiter", "Noise Gate", "Fuzz",
|
||||
"Graphic EQ", "Tremolo", "Phaser", "Modulation",
|
||||
"Auto-Wah", "Mutant", "Bass Octaver", "Octave Splitter",
|
||||
"Overdrive", "Compressor", "Sustainer", "Limiter", "Noise Gate", "Fuzz",
|
||||
"Graphic EQ", "Tremolo", "Phaser", "Modulation", "Chorus",
|
||||
"Auto-Wah", "Mutant", "Ring Modulator", "Bass Octaver", "Octave Splitter",
|
||||
"Delay", "Feedback Delay", "Multi-Tap Delay", "Ping-Pong", "Reverb",
|
||||
]
|
||||
|
||||
@@ -128,18 +132,29 @@ public struct PedalPaletteView: View {
|
||||
/// A full-width pedal row: tap appends to the main chain; drag carries `"add:<name>"` so it can
|
||||
/// be dropped onto a stereo/parallel lane.
|
||||
private func pedalRow(_ name: String) -> some View {
|
||||
Button {
|
||||
let summary: String = PedalRegistry.summary(for: name)
|
||||
return Button {
|
||||
onAdd(name)
|
||||
} label: {
|
||||
HStack(spacing: 4) {
|
||||
Text(name)
|
||||
.font(.callout)
|
||||
.foregroundStyle(Color.white)
|
||||
.lineLimit(1)
|
||||
Spacer(minLength: 0)
|
||||
Image(systemName: "plus")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(Color.white.opacity(PedalPaletteView.addGlyphOpacity))
|
||||
VStack(alignment: .leading, spacing: PedalPaletteView.rowSubtitleSpacing) {
|
||||
HStack(spacing: 4) {
|
||||
Text(name)
|
||||
.font(.callout)
|
||||
.foregroundStyle(Color.white)
|
||||
.lineLimit(1)
|
||||
Spacer(minLength: 0)
|
||||
Image(systemName: "plus")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(Color.white.opacity(PedalPaletteView.addGlyphOpacity))
|
||||
}
|
||||
if !summary.isEmpty {
|
||||
Text(summary)
|
||||
.font(.caption2)
|
||||
.foregroundStyle(Color.white.opacity(PedalPaletteView.summaryOpacity))
|
||||
.lineLimit(2)
|
||||
.multilineTextAlignment(.leading)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, PedalPaletteView.cardPaddingH)
|
||||
.padding(.vertical, PedalPaletteView.cardPaddingV)
|
||||
|
||||
@@ -31,6 +31,9 @@ private func enclosureColor(for displayName: String) -> Color {
|
||||
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
|
||||
case "Chorus": return Color(red: 0.16, green: 0.50, blue: 0.64) // aqua
|
||||
case "Sustainer": return Color(red: 0.22, green: 0.46, blue: 0.30) // pine green
|
||||
case "Ring Modulator": return Color(red: 0.64, green: 0.30, blue: 0.10) // burnt amber
|
||||
default: return Color(red: 0.36, green: 0.36, blue: 0.38) // steel gray
|
||||
}
|
||||
}
|
||||
@@ -212,6 +215,8 @@ public struct PedalView: View {
|
||||
private static let screwHalfSize: CGFloat = 4
|
||||
private static let namePlateBackgroundOpacity: Double = 0.35
|
||||
private static let fontSizeNamePlate: CGFloat = 13
|
||||
/// Opacity of the trailing ⓘ info button on the name plate.
|
||||
private static let infoButtonOpacity: Double = 0.7
|
||||
private static let outerBorderLineWidth: CGFloat = 1.5
|
||||
private static let innerHighlightLineWidth: CGFloat = 1
|
||||
private static let innerHighlightPadding: CGFloat = 1
|
||||
@@ -221,6 +226,9 @@ public struct PedalView: View {
|
||||
|
||||
private let pedal: Pedal
|
||||
|
||||
/// Presentation flag for the pedal info panel (description + control ranges).
|
||||
@State private var showInfo: Bool = false
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a stompbox pedal view for the given pedal.
|
||||
@@ -282,11 +290,15 @@ public struct PedalView: View {
|
||||
x: PedalView.shadowXOffset,
|
||||
y: PedalView.shadowYOffset
|
||||
)
|
||||
.sheet(isPresented: $showInfo) {
|
||||
PedalInfoView(pedal: pedal)
|
||||
.presentationDetents([.medium, .large])
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Subviews
|
||||
|
||||
/// Capsule name plate near the top of the enclosure.
|
||||
/// Capsule name plate near the top of the enclosure, with a trailing info button.
|
||||
private var namePlate: some View {
|
||||
Text(pedal.displayName)
|
||||
.font(.system(size: PedalView.fontSizeNamePlate, weight: .bold, design: .rounded))
|
||||
@@ -295,6 +307,18 @@ public struct PedalView: View {
|
||||
.padding(.vertical, PedalView.namePlatePaddingV)
|
||||
.background(Color.black.opacity(PedalView.namePlateBackgroundOpacity))
|
||||
.clipShape(RoundedRectangle(cornerRadius: PedalView.namePlateCornerRadius))
|
||||
.frame(maxWidth: .infinity)
|
||||
.overlay(alignment: .trailing) {
|
||||
Button {
|
||||
showInfo = true
|
||||
} label: {
|
||||
Image(systemName: "info.circle")
|
||||
.font(.system(size: PedalView.fontSizeNamePlate))
|
||||
.foregroundStyle(Color.white.opacity(PedalView.infoButtonOpacity))
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.help("About this pedal")
|
||||
}
|
||||
}
|
||||
|
||||
/// Grid of the effect knobs, in rows of up to `knobColumnCount`.
|
||||
|
||||
Reference in New Issue
Block a user