3 Commits

Author SHA1 Message Date
josh 3ef09a771a docs(help): explain the pre-board and post-board lanes
The Boards & Rigs help section covered boards but not the pre/post-board
chains. Add bullets: pre-board processes the input once before the split and
feeds every board (shared tuner/comp/gate); post-board runs after the boards
are mixed (global reverb/limiter/EQ); both hide when empty; and the whole
pre/board/post path scrolls together while each board scrolls sideways.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-26 15:06:26 -08:00
josh 3f05cfa416 feat(ui): pre-board, board and post-board in one vertical scroller
The board canvas used to fill the remaining height and centre itself, pinning
the pre-board strip above and the post-board strip below — so a tall pre/post
chain clipped instead of scrolling, and the three sections never read as one
signal path. Wrap pre-board → board → post-board in a single vertical
ScrollView so the whole path scrolls top-to-bottom as one page, on macOS and
iOS alike. The transport / palette / routing header stays fixed above it.

BoardFlowView gains a `sizesToContent` mode: it sizes to its chain height and
scrolls only horizontally, so it nests inside the outer vertical scroller with
no competing vertical scroll (a tall parallel split simply grows the page).
The default fill-and-centre behaviour is unchanged for any other caller.

Verified on the iPad simulator: sections stack in signal-flow order and the
board still scrolls horizontally through a long chain.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-26 14:15:41 -08:00
josh 4cae1e6fd0 fix(tunedverb): silence the wash until a moment is captured
An uncaptured TunedVerb has no filter template, so it must output silence —
but the live cross-map was pouring the dry pass-through straight into the
reverb, so every TunedVerb hummed on startup (and looked like a stale
capture surviving a restart). Gate the reverb input by the Capture latch:
`masked * $captured` feeds the reverb zero until the footswitch fires.

Because `captured` is 0 by default, reset to 0 on every graph rebuild
(resetForRebuild) and on engine stop (engineDidStop -> releaseHold), the
same gate also guarantees a fresh app launch or engine restart comes up
silent with no carried-over capture. The analysis side-chain keeps tracking
while gated, so pressing Capture still freezes the current-moment spectrum.

FreezVerb is unaffected: its Freeze holds a working reverb's tail, so it
should produce sound before freezing.

Tests: new wetIsSilentUntilCaptureThenAudible; panShiftsTheLeftLeg and
captureLocksTheFilter... updated to the new contract (capture before
measuring the wash). 856 tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-26 14:02:47 -08:00
5 changed files with 140 additions and 55 deletions
@@ -196,9 +196,18 @@ public final class TunedVerbPedal: Pedal {
stages: [.dual(map, sideChain: sideChain)]
)
// Gate the wash by the Capture latch. Until a moment is captured there is no filter template,
// so the reverb must be fed silence rather than the live pass-through — otherwise an
// uncaptured TunedVerb pours the dry signal straight into the tail. `captured` is `0` until the
// footswitch fires and is reset to `0` on every rebuild and on engine stop (`resetForRebuild`
// / `releaseHold`), so a fresh app launch or an engine restart comes up silent with no stale
// capture. The analysis side-chain inside `masked` keeps tracking while gated, so pressing
// Capture still freezes the current-moment spectrum.
let gatedIntoVerb: any ValidGeneratorInput = masked * $captured
// A large room for a cavernous tail; `time` sets the T60, `damp` the brightness.
let reverb: GVerb.Audio = GVerb.Audio(
source: masked,
source: gatedIntoVerb,
roomSize: roomSize,
reverbTime: $time,
damping: $damp,
+23 -2
View File
@@ -63,6 +63,12 @@ public struct BoardFlowView: View {
private let shoeGaze: ShoeGaze
private let boardIndex: Int
/// When `true`, the view sizes to its content height and scrolls only horizontally, so it can sit
/// inside an outer vertical scroller (the pre-board → board → post-board page) without a nested
/// vertical scroll. When `false` (the default), it fills the available height and centres the
/// chain, adding a vertical scroll only for tall parallel splits.
private let sizesToContent: Bool
/// Undo coordinator injected by ``ShoeGazeBuilderView``; `nil` in lightweight hosts (previews),
/// where edits run directly without recording history.
@Environment(UndoCoordinator.self) private var undo: UndoCoordinator?
@@ -74,9 +80,10 @@ public struct BoardFlowView: View {
/// lanes exceed the viewport height (tall parallel splits). Otherwise scrolling stays horizontal.
@State private var contentHeight: CGFloat = 0
public init(shoeGaze: ShoeGaze, boardIndex: Int) {
public init(shoeGaze: ShoeGaze, boardIndex: Int, sizesToContent: Bool = false) {
self.shoeGaze = shoeGaze
self.boardIndex = boardIndex
self.sizesToContent = sizesToContent
}
// MARK: - Body
@@ -91,9 +98,22 @@ public struct BoardFlowView: View {
}
}
@ViewBuilder
private func flow(board: PedalBoard) -> some View {
let stages: [StageModel] = stageModels(board: board)
return GeometryReader { proxy in
if sizesToContent {
// One-scroller mode: the board is only as tall as its chain and scrolls horizontally,
// so the outer vertical scroller flows pre-board → board → post-board as one page with
// no nested vertical scroll. A tall parallel split simply makes the page taller.
ScrollView(.horizontal, showsIndicators: true) {
chainRow(board: board, stages: stages)
}
.frame(height: contentHeight > 0 ? contentHeight : nil)
.onPreferenceChange(BoardFlowContentHeightKey.self) { height in
contentHeight = height
}
} else {
GeometryReader { proxy in
let viewportHeight: CGFloat = proxy.size.height
// Lock to horizontal, adding the vertical axis only when the chain is taller than the
// viewport (deep parallel splits) so it can be reached instead of clipped.
@@ -118,6 +138,7 @@ public struct BoardFlowView: View {
}
}
}
}
/// The left→right chain of endpoints, connectors and stage cards. Reports its own intrinsic
/// height through `BoardFlowContentHeightKey` so `flow` can decide whether vertical scrolling is
@@ -90,6 +90,14 @@ public struct HelpView: View {
+ "insert before it; tap a palette pedal to append.",
"Add boards with +. Solo / Blend / All choose which boards you hear; XFade sets the "
+ "crossfade time; each board has S (solo) and B (bypass).",
"Pre-board is one chain that processes your input once, before the board split, and "
+ "feeds every board — good for a shared tuner, compressor, or noise gate. Tap "
+ "+ Pre-board to start it; it hides when empty.",
"Post-board is one chain after all boards are mixed down — good for a global reverb, "
+ "a limiter, or a final EQ across the whole rig. Tap + Post-board to start it; it "
+ "hides when empty.",
"Pre-board, the boards, and post-board scroll together top-to-bottom as one signal "
+ "path; each board's chain scrolls sideways.",
"The Rigs sidebar lists saved rigs, with New, Save, Save As, Duplicate, Rename, "
+ "Delete, and Erase All.",
"Reorder rigs into a set list by dragging a row, or via each rig's Move Up / "
@@ -726,10 +726,19 @@ public struct ShoeGazeBuilderView: View {
}
Divider().overlay(Color.white.opacity(ShoeGazeBuilderView.dividerOpacity))
ControlMappingLegend()
// Pre-board, the board canvas and post-board share a single vertical scroller, so the whole
// signal path reads top-to-bottom as one page (on macOS and iOS alike) instead of pinning
// the board and clipping the pre/post strips.
ScrollView(.vertical, showsIndicators: true) {
VStack(alignment: .leading, spacing: ShoeGazeBuilderView.sectionSpacing) {
preBoardStrip
boardArea
postBoardStrip
}
.frame(maxWidth: .infinity, alignment: .topLeading)
}
.frame(maxHeight: .infinity)
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
// Make the undo coordinator reachable to every board / palette subview so their structural
// edits record history. Optional-object injection: `nil` resolves `@Environment(...)` to nil.
@@ -1598,13 +1607,11 @@ public struct ShoeGazeBuilderView: View {
// MARK: - Board area
private var boardArea: some View {
// Vertically center the signal-flow board in the available space.
VStack(spacing: 0) {
Spacer(minLength: 0)
BoardFlowView(shoeGaze: shoeGaze, boardIndex: clampedBoardIndex)
Spacer(minLength: 0)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
// Content-sized so it flows inside the shared pre/board/post vertical scroller (scrolls
// horizontally for a long chain; a tall parallel split grows the page). No vertical centering —
// the board sits in signal-flow order between the pre-board and post-board strips.
BoardFlowView(shoeGaze: shoeGaze, boardIndex: clampedBoardIndex, sizesToContent: true)
.frame(maxWidth: .infinity, alignment: .leading)
}
/// Performs a routing action from the palette against the selected board.
@@ -188,47 +188,87 @@ struct TunedVerbPedalTests {
}
@Test func panShiftsTheLeftLeg() throws {
// Fully wet, the output follows the panned wash. Hard left fills the left leg; hard right
// nearly empties it. (Tests exercise the left output leg; the right is board-wired live.)
let hardLeft: [Float] = try render(duration: 0.6) { pedal in pedal.mix = 1.0; pedal.pan = -1.0 }
let hardRight: [Float] = try render(duration: 0.6) { pedal in pedal.mix = 1.0; pedal.pan = 1.0 }
let leftRMS: Double = rms(hardLeft, loFrame: 0, hiFrame: hardLeft.count)
let rightRMS: Double = rms(hardRight, loFrame: 0, hiFrame: hardRight.count)
// Fully wet, the output follows the panned wash — but the wash only exists after a capture, so
// capture early, then measure. Hard left fills the left leg; hard right nearly empties it.
// (`stepRender` returns the left output bus; the right is board-wired live.)
let blockSize: Int = 512
let totalFrames: Int = Int(0.8 * sampleRate)
let captureFrame: Int = Int(0.1 * sampleRate)
let windowLo: Int = Int(0.4 * sampleRate)
func leftLeg(pan: Double) throws -> [Float] {
var captured: Bool = false
return try stepRender(totalFrames: totalFrames, blockSize: blockSize) { pedal in
pedal.mix = 1.0; pedal.pan = pan; pedal.time = 2.0
} onFrame: { frame, _, pedal in
if frame >= captureFrame, !captured { pedal.toggleCapture(); captured = true }
}
}
let hardLeft: [Float] = try leftLeg(pan: -1.0)
let hardRight: [Float] = try leftLeg(pan: 1.0)
let leftRMS: Double = rms(hardLeft, loFrame: windowLo, hiFrame: hardLeft.count)
let rightRMS: Double = rms(hardRight, loFrame: windowLo, hiFrame: hardRight.count)
#expect(leftRMS > rightRMS * 3.0,
"panning hard left should fill the left leg far more than hard right: L \(leftRMS) vs R \(rightRMS)")
}
@Test func captureLocksTheFilterSoAChangedInputIsShapedDifferently() throws {
// Capture the filter on tone A, then morph the input to tone B. A locked filter (shaped by A)
// masks B differently than a filter that keeps tracking the live input — so the two renders
// diverge once the input has changed.
@Test func wetIsSilentUntilCaptureThenAudible() throws {
// Core contract: with no captured moment there is no filter template, so a fully-wet TunedVerb
// must output silence — not the live pass-through poured into the reverb. After the Capture
// footswitch fires, the wash appears. Fully wet (mix 1.0) so the only output is the gated wash.
let blockSize: Int = 512
let totalFrames: Int = Int(1.4 * sampleRate)
let captureFrame: Int = Int(0.5 * sampleRate)
var captured: Bool = false
let out: [Float] = try stepRender(totalFrames: totalFrames, blockSize: blockSize) { pedal in
pedal.mix = 1.0; pedal.time = 1.0
} onFrame: { frame, _, pedal in
if frame >= captureFrame, !captured { pedal.toggleCapture(); captured = true }
}
// Before capture: fully-wet output must be silent (reverb fed zero).
let preRMS: Double = rms(out, loFrame: 0, hiFrame: captureFrame - blockSize)
// Well after capture (give the reverb time to build): audible.
let postRMS: Double = rms(out, loFrame: captureFrame + Int(0.4 * sampleRate), hiFrame: out.count)
#expect(preRMS < 1.0e-6, "an uncaptured fully-wet TunedVerb must be silent, got \(preRMS)")
#expect(postRMS > 1.0e-4, "after Capture the wash must be audible, got \(postRMS)")
}
@Test func captureLocksTheFilterSoAChangedInputIsShapedDifferently() throws {
// Which moment you capture determines the filter. Capture on tone A then morph to B (the wash
// on B is shaped by A's spectrum) versus morph to B first then capture on B (shaped by B's own
// spectrum). Both are audible — the wash exists only after a capture — but the two locked
// templates mask the ongoing tone-B input differently, so the renders diverge.
let blockSize: Int = 512
let totalFrames: Int = Int(1.4 * sampleRate)
let captureFrame: Int = Int(0.4 * sampleRate)
let morphFrame: Int = Int(0.6 * sampleRate)
let windowLo: Int = Int(0.95 * sampleRate)
let windowHi: Int = Int(1.35 * sampleRate)
var captured: Bool = false
let locked: [Float] = try stepRender(totalFrames: totalFrames, blockSize: blockSize) { pedal in
// Locked on tone A, then morphed to B.
var capturedA: Bool = false
let lockedOnA: [Float] = try stepRender(totalFrames: totalFrames, blockSize: blockSize) { pedal in
pedal.mix = 1.0; pedal.time = 3.0
} onFrame: { frame, source, pedal in
if frame >= captureFrame, !captured { pedal.toggleCapture(); captured = true }
if frame >= morphFrame { source.morph = 1.0 } // switch to tone B
if frame >= Int(0.4 * sampleRate), !capturedA { pedal.toggleCapture(); capturedA = true }
if frame >= Int(0.6 * sampleRate) { source.morph = 1.0 } // switch to tone B after capture
}
let tracking: [Float] = try stepRender(totalFrames: totalFrames, blockSize: blockSize) { pedal in
// Morphed to B first, then locked on B.
var capturedB: Bool = false
let lockedOnB: [Float] = try stepRender(totalFrames: totalFrames, blockSize: blockSize) { pedal in
pedal.mix = 1.0; pedal.time = 3.0
} onFrame: { frame, source, _ in
// Never capture; morph at the same frame.
if frame >= morphFrame { source.morph = 1.0 }
} onFrame: { frame, source, pedal in
if frame >= Int(0.2 * sampleRate) { source.morph = 1.0 } // switch to tone B first
if frame >= Int(0.4 * sampleRate), !capturedB { pedal.toggleCapture(); capturedB = true }
}
let signal: Double = rms(tracking, loFrame: windowLo, hiFrame: windowHi)
let diff: Double = rmsDiff(locked, tracking, loFrame: windowLo, hiFrame: windowHi)
#expect(signal > 1.0e-4, "control render should be audible on tone B, got \(signal)")
let signal: Double = rms(lockedOnB, loFrame: windowLo, hiFrame: windowHi)
let diff: Double = rmsDiff(lockedOnA, lockedOnB, loFrame: windowLo, hiFrame: windowHi)
#expect(signal > 1.0e-4, "a captured render should be audible on tone B, got \(signal)")
#expect(diff > signal * 0.25,
"a captured filter should shape the changed input differently: diff \(diff) vs signal \(signal)")
"locking a different moment should shape the input differently: diff \(diff) vs signal \(signal)")
}
// MARK: - Bypass