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:
@@ -31,6 +31,14 @@ struct LooperTimelineView: View {
|
||||
private static let lengthLabelOpacity: Double = 0.75
|
||||
private static let emptyLedBrightness: Double = 0.3
|
||||
private static let borderLineWidth: CGFloat = 1
|
||||
private static let slotDotSpacing: CGFloat = 4
|
||||
private static let slotDotDiameter: CGFloat = 18
|
||||
private static let slotLabelFontSize: CGFloat = 10
|
||||
private static let slotDotBrightness: Double = 0.16
|
||||
private static let slotFilledOpacity: Double = 0.55
|
||||
private static let slotEmptyOpacity: Double = 0.45
|
||||
private static let slotActiveRingWidth: CGFloat = 1.5
|
||||
private static let slotLabels: [String] = ["A", "B", "C", "D", "E", "F", "G", "H"]
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
@@ -40,6 +48,9 @@ struct LooperTimelineView: View {
|
||||
@State private var state: LooperTransportState = .empty
|
||||
@State private var lengthSeconds: Double = 0.0
|
||||
@State private var lengthBeats: Double = 0.0
|
||||
@State private var activeSlot: Int = 0
|
||||
@State private var slotContent: [Bool] = Array(repeating: false, count: LooperPedal.slotCount)
|
||||
@State private var stopArmed: Bool = false
|
||||
|
||||
init(pedal: LooperPedal) {
|
||||
self.pedal = pedal
|
||||
@@ -52,6 +63,8 @@ struct LooperTimelineView: View {
|
||||
HStack(spacing: LooperTimelineView.sectionSpacing) {
|
||||
stateBadge
|
||||
Spacer(minLength: 0)
|
||||
slotDots
|
||||
Spacer(minLength: 0)
|
||||
lengthLabel
|
||||
}
|
||||
track
|
||||
@@ -63,6 +76,9 @@ struct LooperTimelineView: View {
|
||||
state = pedal.transportState
|
||||
lengthSeconds = pedal.loopLengthSeconds
|
||||
lengthBeats = pedal.loopLengthBeats
|
||||
activeSlot = pedal.activeSlotIndex
|
||||
slotContent = (0 ..< LooperPedal.slotCount).map { pedal.slotHasContent($0) }
|
||||
stopArmed = pedal.isStopAtLoopEndArmed
|
||||
try? await Task.sleep(nanoseconds: LooperTimelineView.pollIntervalNanoseconds)
|
||||
}
|
||||
}
|
||||
@@ -70,6 +86,29 @@ struct LooperTimelineView: View {
|
||||
|
||||
// MARK: - Subviews
|
||||
|
||||
/// One labelled dot per slot: filled when it holds a loop, ringed when it is the active slot.
|
||||
private var slotDots: some View {
|
||||
HStack(spacing: LooperTimelineView.slotDotSpacing) {
|
||||
ForEach(0 ..< LooperPedal.slotCount, id: \.self) { index in
|
||||
let isActive: Bool = index == activeSlot
|
||||
let hasContent: Bool = index < slotContent.count && slotContent[index]
|
||||
Text(LooperTimelineView.slotLabels[index])
|
||||
.font(.system(size: LooperTimelineView.slotLabelFontSize,
|
||||
weight: .bold, design: .monospaced))
|
||||
.foregroundStyle(hasContent ? Color.white : Color.white.opacity(LooperTimelineView.slotEmptyOpacity))
|
||||
.frame(width: LooperTimelineView.slotDotDiameter, height: LooperTimelineView.slotDotDiameter)
|
||||
.background(
|
||||
Circle().fill(hasContent ? Color.green.opacity(LooperTimelineView.slotFilledOpacity)
|
||||
: Color(white: LooperTimelineView.slotDotBrightness))
|
||||
)
|
||||
.overlay(
|
||||
Circle().stroke(isActive ? Color.white : Color.clear,
|
||||
lineWidth: LooperTimelineView.slotActiveRingWidth)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var stateBadge: some View {
|
||||
HStack(spacing: LooperTimelineView.badgeInnerSpacing) {
|
||||
Circle()
|
||||
@@ -78,6 +117,11 @@ struct LooperTimelineView: View {
|
||||
Text(stateText)
|
||||
.font(.system(size: LooperTimelineView.labelFontSize, weight: .semibold, design: .monospaced))
|
||||
.foregroundStyle(Color.white)
|
||||
if stopArmed {
|
||||
Text("→END")
|
||||
.font(.system(size: LooperTimelineView.labelFontSize, weight: .semibold, design: .monospaced))
|
||||
.foregroundStyle(Color.orange)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +166,7 @@ struct LooperTimelineView: View {
|
||||
case .armedRecord, .armedStop: return Color.orange
|
||||
case .recording: return Color.red
|
||||
case .playing: return Color.green
|
||||
case .stopped: return Color.orange
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,6 +177,7 @@ struct LooperTimelineView: View {
|
||||
case .recording: return "REC"
|
||||
case .armedStop: return "END"
|
||||
case .playing: return "PLAY"
|
||||
case .stopped: return "STOP"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user