feat(postboard): shared post-board chain after the board mix
Add a dedicated linear stereo post-board chain that processes the summed board mix once, after the board split, before the hardware output — for global reverb, a bus limiter, a final EQ, and the like. Routing: when a post-chain exists, every BoardOutputMaster writes a shared stereo mix bus (parameterized output bus indices) instead of hardware; the post-chain (PostChain + PostChainOutput) reads that mix, runs its pedals in order, and copies the tail to the hardware outputs. Always stereo-headed (dual-mono for a mono rig) so mono pedals auto-stereoize per channel. The chain's head node is inserted at .tail(of: mainGroup), so it evaluates after every board master regardless of board add order — no re-order on board add, and no board dropped from the mix. buildPostChain tracks the chain before wiring it so a mid-build throw stays reclaimable by teardown. State: additive ShoeGazeState.postChain (nil-when-empty, decodeIfPresent, byte-identical old-rig round-trip). Edit API (append/insert/remove/move) mirrors the pre-board chain: capture-from-live, stop/teardown/rebuild. Undo treats a post-topology change as a full rebuild via id-sequence compare. UI: a hide-when-empty post-board strip below the boards, symmetric to the pre-board strip, with palette routing and per-pedal remove through undo. Bumps the iOS demo's Lyrebird pin to 2.3.0 (onEditingEnded). Tests: PostBoardChainTests (render, closed-volume silences output, post-chain-after-every-master ordering, board-add ordering, insert/move/ remove, save/load round-trip with knob, old-rig decode) + post-pedal undo. 855 tests pass. Reviewed (RT-safety + line sweep); the ordering bug both reviewers caught is fixed at the root and covered by a deterministic test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -186,6 +186,8 @@ public struct ShoeGazeBuilderView: View {
|
||||
@State private var showPaletteSheet: Bool = false
|
||||
/// When `true`, the next palette pick is added to the pre-board chain rather than a board.
|
||||
@State private var addToPreBoard: Bool = false
|
||||
/// When `true`, the next palette pick is added to the post-board chain rather than a board.
|
||||
@State private var addToPostBoard: Bool = false
|
||||
@State private var showSettingsSheet: Bool = false
|
||||
|
||||
/// Type filter for the compact Add-Pedal sheet, hoisted so it sits in the sheet's fixed header.
|
||||
@@ -587,9 +589,9 @@ public struct ShoeGazeBuilderView: View {
|
||||
/// Hosts the compact Add-pedal palette sheet on its own node.
|
||||
private var paletteSheetAnchor: some View {
|
||||
Color.clear
|
||||
// Reset the pre-board routing flag on any dismissal (incl. swipe-to-dismiss), so a later
|
||||
// board-level "+" never misroutes its pick into the pre-board chain.
|
||||
.sheet(isPresented: $showPaletteSheet, onDismiss: { addToPreBoard = false }) {
|
||||
// Reset the pre/post-board routing flags on any dismissal (incl. swipe-to-dismiss), so a
|
||||
// later board-level "+" never misroutes its pick into a pre- or post-board chain.
|
||||
.sheet(isPresented: $showPaletteSheet, onDismiss: { addToPreBoard = false; addToPostBoard = false }) {
|
||||
paletteSheet
|
||||
}
|
||||
}
|
||||
@@ -726,6 +728,7 @@ public struct ShoeGazeBuilderView: View {
|
||||
ControlMappingLegend()
|
||||
preBoardStrip
|
||||
boardArea
|
||||
postBoardStrip
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
||||
// Make the undo coordinator reachable to every board / palette subview so their structural
|
||||
@@ -943,7 +946,7 @@ public struct ShoeGazeBuilderView: View {
|
||||
.foregroundStyle(Color.white)
|
||||
Spacer()
|
||||
pedalFilterMenu
|
||||
Button("Done") { addToPreBoard = false; showPaletteSheet = false }
|
||||
Button("Done") { addToPreBoard = false; addToPostBoard = false; showPaletteSheet = false }
|
||||
.fontWeight(.semibold)
|
||||
}
|
||||
.padding()
|
||||
@@ -956,13 +959,21 @@ public struct ShoeGazeBuilderView: View {
|
||||
filter: $pedalFilter,
|
||||
showsFilterMenu: false,
|
||||
onAdd: { type in
|
||||
if addToPreBoard { addPrePedal(type: type) } else { addPedal(type: type) }
|
||||
if addToPreBoard {
|
||||
addPrePedal(type: type)
|
||||
} else if addToPostBoard {
|
||||
addPostPedal(type: type)
|
||||
} else {
|
||||
addPedal(type: type)
|
||||
}
|
||||
addToPreBoard = false
|
||||
addToPostBoard = false
|
||||
showPaletteSheet = false
|
||||
},
|
||||
onRouting: { action in
|
||||
// Routing regions belong to a board, never the linear pre-board chain.
|
||||
// Routing regions belong to a board, never the linear pre- or post-board chain.
|
||||
addToPreBoard = false
|
||||
addToPostBoard = false
|
||||
performRouting(action)
|
||||
showPaletteSheet = false
|
||||
}
|
||||
@@ -1490,6 +1501,100 @@ public struct ShoeGazeBuilderView: View {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Post-board chain
|
||||
|
||||
/// The post-board chain strip, shown below the boards. Mirrors ``preBoardStrip``: hidden (just a
|
||||
/// "+Post" button) when empty, a horizontal pedal strip otherwise. The post-chain processes the
|
||||
/// summed board mix once before the hardware output — global reverb, a bus limiter, a final EQ.
|
||||
@ViewBuilder
|
||||
private var postBoardStrip: some View {
|
||||
let postPedals: [Pedal] = shoeGaze.postBoardPedals
|
||||
if postPedals.isEmpty {
|
||||
HStack {
|
||||
Button {
|
||||
addToPostBoard = true
|
||||
showPaletteSheet = true
|
||||
} label: {
|
||||
Label("Post-board", systemImage: "plus").font(.caption)
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.tint(.gray)
|
||||
.help("Add a post-board pedal — processes the summed board mix before the output")
|
||||
Spacer()
|
||||
}
|
||||
.padding(.horizontal, ShoeGazeBuilderView.outerPadding)
|
||||
} else {
|
||||
VStack(alignment: .leading, spacing: ShoeGazeBuilderView.rowSpacing) {
|
||||
HStack(spacing: 6) {
|
||||
Rectangle().fill(Color.white.opacity(ShoeGazeBuilderView.dividerOpacity)).frame(height: 1)
|
||||
Text("from board mix")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(Color.white.opacity(ShoeGazeBuilderView.labelOpacity))
|
||||
.fixedSize()
|
||||
Rectangle().fill(Color.white.opacity(ShoeGazeBuilderView.dividerOpacity)).frame(height: 1)
|
||||
}
|
||||
.padding(.horizontal, ShoeGazeBuilderView.outerPadding)
|
||||
HStack {
|
||||
Text("Post-board").font(.caption).bold().foregroundStyle(Color.white)
|
||||
Spacer()
|
||||
Button {
|
||||
addToPostBoard = true
|
||||
showPaletteSheet = true
|
||||
} label: {
|
||||
Image(systemName: "plus")
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.tint(.gray)
|
||||
.help("Add a post-board pedal")
|
||||
}
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
HStack(alignment: .top, spacing: ShoeGazeBuilderView.rowSpacing) {
|
||||
// Key by the pedal's stable id — a post-board edit rebuilds the chain into new
|
||||
// instances, so an offset key would bind a card to a torn-down pedal.
|
||||
ForEach(Array(postPedals.enumerated()), id: \.element.id) { pair in
|
||||
PedalView(pedal: pair.element)
|
||||
.overlay(alignment: .topTrailing) {
|
||||
Button(role: .destructive) {
|
||||
removePostBoardPedal(at: pair.offset)
|
||||
} label: {
|
||||
Image(systemName: "xmark.circle.fill")
|
||||
.font(.title3)
|
||||
.foregroundStyle(Color.white, Color.black.opacity(0.55))
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.padding(4)
|
||||
.help("Remove this post-board pedal")
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, ShoeGazeBuilderView.outerPadding)
|
||||
}
|
||||
}
|
||||
.environment(undo)
|
||||
.environment(\.shoeGazeTempoEnabled, shoeGaze.tempoEnabled)
|
||||
}
|
||||
}
|
||||
|
||||
private func addPostPedal(type: String) {
|
||||
do {
|
||||
try editing("Add \(type) (post-board)") { try shoeGaze.appendPostPedal(PedalType(type)) }
|
||||
autosave()
|
||||
} catch {
|
||||
print("[ShoeGazeBuilderView] appendPostPedal failed: \(error)")
|
||||
reportError("Couldn’t add \(type)", error)
|
||||
}
|
||||
}
|
||||
|
||||
private func removePostBoardPedal(at index: Int) {
|
||||
do {
|
||||
try editing("Remove post-board pedal") { try shoeGaze.removePostPedal(at: index) }
|
||||
autosave()
|
||||
} catch {
|
||||
print("[ShoeGazeBuilderView] removePostPedal failed: \(error)")
|
||||
reportError("Couldn’t remove post-board pedal", error)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Board area
|
||||
|
||||
private var boardArea: some View {
|
||||
|
||||
Reference in New Issue
Block a user