Looper: multi-slot + timeline + stop/cue-stop, quantized transport

Checkpoint before the multitrack redesign. Adds 4 loop slots (one player
swapped via setBuffer), a play-head timeline with A/B/C/D dots, Loop/Stop/
Cue Stop/Reverse stomp toggles below the knobs, beat-quantized transport,
overdub undo, reverse, and feedback-decay overdub — all reviewed for RT
safety (transportGeneration guards on deferred beat/undo/cue callbacks).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-03 14:14:46 -07:00
parent 947dfe427a
commit 465e3e6dfd
8 changed files with 600 additions and 203 deletions
+50 -18
View File
@@ -132,9 +132,10 @@ struct LEDIndicator: View {
// MARK: - Footswitch
/// A round footswitch-style button that flips a `UIParamNode` between `0` and `1`.
/// `internal` (not `private`) so other views in this module (e.g. `PedalButtonView`) can
/// reuse the same stompbox footswitch look for non-bypass toggles.
/// A round footswitch-style button. Either flips a bound `UIParamNode` between `0` and `1`
/// (toggle) or runs an arbitrary action (momentary) — both render the identical stompbox look.
/// `internal` (not `private`) so other views in this module (e.g. `PedalButtonView`) can reuse
/// it for non-bypass toggles and momentary stomp actions.
struct FootswitchButton: View {
private static let diameter: CGFloat = 44
@@ -144,14 +145,23 @@ struct FootswitchButton: View {
private static let ringBrightness: Double = 0.50
private static let innerFillBrightness: Double = 0.25
let node: UIParamNode
private let action: () -> Void
/// Flips `node` between `0` and `1` on each press.
init(node: UIParamNode) {
self.action = {
let engaged: Bool = node.value < 0.5
node.update(engaged ? 1.0 : 0.0)
}
}
/// Runs `action` on each press (momentary).
init(action: @escaping () -> Void) {
self.action = action
}
var body: some View {
Button(action: {
let engaged: Bool = node.value < 0.5
// Toggle: engaged (0) → bypassed (1) and vice-versa.
node.update(engaged ? 1.0 : 0.0)
}) {
Button(action: action) {
ZStack {
Circle()
.fill(Color(white: FootswitchButton.outerFillBrightness))
@@ -207,6 +217,8 @@ public struct PedalView: View {
private static let enclosurePadding: CGFloat = 14
private static let screwInset: CGFloat = 6
private static let knobColumnCount: Int = 3
/// Knob columns for a double-width pedal card (fits a four-knob effect bank on one row).
private static let wideKnobColumnCount: Int = 4
private static let knobSpacing: CGFloat = 10
/// Horizontal gap between knobs within a row. Wider than `knobSpacing` so centred
/// rows keep a comfortable, touch-friendly gap between adjacent knobs.
@@ -297,6 +309,7 @@ public struct PedalView: View {
knobGrid
selectorRow
switchRow
transportButtonRow
buttonRow
sliderBank(sliders)
Spacer(minLength: 0)
@@ -367,24 +380,25 @@ public struct PedalView: View {
/// `Level` on the left, `Mix` on the right — leaving more room for the effect controls
/// at the top and giving every pedal a symmetric footer.
private var knobGrid: some View {
// Wide (double-width) pedals fit four knobs across, so a four-knob effect bank (e.g.
// the looper's Crossfade / Playback / Overdub / Feedback) sits on one row.
let columns: Int = pedal.widthUnits >= 2 ? PedalView.wideKnobColumnCount : PedalView.knobColumnCount
let knobs: [PedalKnob] = Array(pedal.knobs.dropLast(2))
let rows: [[PedalKnob]] = stride(
from: 0,
to: knobs.count,
by: PedalView.knobColumnCount
by: columns
).map { startIndex in
Array(knobs[startIndex ..< min(startIndex + PedalView.knobColumnCount, knobs.count)])
Array(knobs[startIndex ..< min(startIndex + columns, knobs.count)])
}
return VStack(spacing: PedalView.knobSpacing) {
ForEach(Array(rows.enumerated()), id: \.offset) { rowPair in
let row: [PedalKnob] = rowPair.element
// Centre each row: a short row (one or two knobs) sits centred in the
// enclosure rather than left-aligned. Symmetric spacers also centre a full
// three-knob row, so every row stays horizontally centred.
// A full three-knob row keeps the tight spacing so it fits the enclosure;
// Centre each row: a short row sits centred in the enclosure rather than
// left-aligned. A full row keeps the tight spacing so it fits the enclosure;
// shorter centred rows use a wider, touch-friendly gap.
let rowItemSpacing: CGFloat = row.count >= PedalView.knobColumnCount
let rowItemSpacing: CGFloat = row.count >= columns
? PedalView.knobSpacing
: PedalView.knobRowItemSpacing
HStack(spacing: rowItemSpacing) {
@@ -430,8 +444,26 @@ public struct PedalView: View {
}
}
/// Row of stomp-style action buttons drawn from `pedal.effectButtons`, beneath the
/// switch row. Renders nothing when the pedal publishes no buttons.
/// Transport-control row drawn from `pedal.effectTransportButtons`, placed directly below
/// the knobs so persistent state toggles and transport stops (e.g. the looper's Loop /
/// Stop / Cue Stop / Reverse) sit apart from the momentary actions. Renders nothing when
/// the pedal publishes no transport buttons.
@ViewBuilder
private var transportButtonRow: some View {
let buttons: [PedalButton] = pedal.effectTransportButtons
if !buttons.isEmpty {
HStack(alignment: .top, spacing: PedalView.knobRowItemSpacing) {
Spacer(minLength: 0)
ForEach(Array(buttons.enumerated()), id: \.offset) { pair in
PedalButtonView(pair.element)
}
Spacer(minLength: 0)
}
}
}
/// Row of momentary stomp-style action buttons drawn from `pedal.effectButtons`, beneath
/// the transport row. Renders nothing when the pedal publishes no buttons.
@ViewBuilder
private var buttonRow: some View {
let buttons: [PedalButton] = pedal.effectButtons