Looper: per-track mute via the A/B/C/D dots
Each track player now runs through a smoothed per-track mute gate. Tapping a track dot selects it (as before); tapping the already-selected, recorded track toggles its mute (tapTrack). Muted dots dim and show a slash. Mutes clear on reset and don't survive a rebuild. Covered by tapTrackSelectsThenMutesRecordedTrack. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -37,6 +37,9 @@ struct LooperTimelineView: View {
|
||||
private static let dotFilledOpacity: Double = 0.55
|
||||
private static let dotEmptyOpacity: Double = 0.45
|
||||
private static let activeRingWidth: CGFloat = 1.5
|
||||
private static let mutedDotOpacity: Double = 0.4
|
||||
private static let muteSlashOpacity: Double = 0.9
|
||||
private static let muteSlashWidth: CGFloat = 1.5
|
||||
private static let indicatorFontSize: CGFloat = 11
|
||||
private static let indicatorOpacity: Double = 0.85
|
||||
private static let overdubRingColor: Color = Color.red
|
||||
@@ -53,6 +56,7 @@ struct LooperTimelineView: View {
|
||||
@State private var selectedTrack: Int = 0
|
||||
@State private var overdubbingTrack: Int?
|
||||
@State private var trackContent: [Bool] = Array(repeating: false, count: LooperPedal.trackCount)
|
||||
@State private var trackMuted: [Bool] = Array(repeating: false, count: LooperPedal.trackCount)
|
||||
@State private var stopArmed: Bool = false
|
||||
@State private var stateDescription: String = ""
|
||||
|
||||
@@ -83,6 +87,7 @@ struct LooperTimelineView: View {
|
||||
selectedTrack = pedal.selectedTrackIndex
|
||||
overdubbingTrack = pedal.overdubbingTrackIndex
|
||||
trackContent = (0 ..< LooperPedal.trackCount).map { pedal.trackHasContent($0) }
|
||||
trackMuted = (0 ..< LooperPedal.trackCount).map { pedal.isTrackMuted($0) }
|
||||
stopArmed = pedal.isStopAtLoopEndArmed
|
||||
stateDescription = pedal.stateDescription
|
||||
try? await Task.sleep(nanoseconds: LooperTimelineView.pollIntervalNanoseconds)
|
||||
@@ -93,15 +98,17 @@ struct LooperTimelineView: View {
|
||||
// MARK: - Subviews
|
||||
|
||||
/// One tappable labelled dot per track: filled when it holds a loop, white-ringed when
|
||||
/// selected, red-ringed while overdubbing. Tapping selects the track.
|
||||
/// selected, red-ringed while overdubbing, dimmed with a slash when muted. Tapping selects the
|
||||
/// track; tapping the already-selected recorded track mutes/unmutes it.
|
||||
private var trackDots: some View {
|
||||
HStack(spacing: LooperTimelineView.dotSpacing) {
|
||||
ForEach(0 ..< LooperPedal.trackCount, id: \.self) { index in
|
||||
let isSelected: Bool = index == selectedTrack
|
||||
let isOverdub: Bool = index == overdubbingTrack
|
||||
let hasContent: Bool = index < trackContent.count && trackContent[index]
|
||||
let isMuted: Bool = index < trackMuted.count && trackMuted[index]
|
||||
Button {
|
||||
pedal.selectTrack(index)
|
||||
pedal.tapTrack(index)
|
||||
} label: {
|
||||
Text(LooperTimelineView.dotLabels[index])
|
||||
.font(.system(size: LooperTimelineView.dotLabelFontSize, weight: .bold, design: .monospaced))
|
||||
@@ -111,17 +118,34 @@ struct LooperTimelineView: View {
|
||||
Circle().fill(hasContent ? Color.green.opacity(LooperTimelineView.dotFilledOpacity)
|
||||
: Color(white: LooperTimelineView.dotBrightness))
|
||||
)
|
||||
.overlay(muteSlash(isMuted))
|
||||
.overlay(
|
||||
Circle().stroke(isOverdub ? LooperTimelineView.overdubRingColor
|
||||
: (isSelected ? Color.white : Color.clear),
|
||||
lineWidth: LooperTimelineView.activeRingWidth)
|
||||
)
|
||||
.opacity(isMuted ? LooperTimelineView.mutedDotOpacity : 1.0)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A diagonal slash drawn over a muted track's dot.
|
||||
@ViewBuilder
|
||||
private func muteSlash(_ muted: Bool) -> some View {
|
||||
if muted {
|
||||
GeometryReader { geometry in
|
||||
Path { path in
|
||||
path.move(to: CGPoint(x: 0, y: geometry.size.height))
|
||||
path.addLine(to: CGPoint(x: geometry.size.width, y: 0))
|
||||
}
|
||||
.stroke(Color.white.opacity(LooperTimelineView.muteSlashOpacity),
|
||||
lineWidth: LooperTimelineView.muteSlashWidth)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var stateBadge: some View {
|
||||
HStack(spacing: LooperTimelineView.badgeInnerSpacing) {
|
||||
Circle()
|
||||
|
||||
Reference in New Issue
Block a user