Compare commits
2 Commits
24ac361c48
...
3f05cfa416
| Author | SHA1 | Date | |
|---|---|---|---|
| 3f05cfa416 | |||
| 4cae1e6fd0 |
@@ -196,9 +196,18 @@ public final class TunedVerbPedal: Pedal {
|
|||||||
stages: [.dual(map, sideChain: sideChain)]
|
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.
|
// A large room for a cavernous tail; `time` sets the T60, `damp` the brightness.
|
||||||
let reverb: GVerb.Audio = GVerb.Audio(
|
let reverb: GVerb.Audio = GVerb.Audio(
|
||||||
source: masked,
|
source: gatedIntoVerb,
|
||||||
roomSize: roomSize,
|
roomSize: roomSize,
|
||||||
reverbTime: $time,
|
reverbTime: $time,
|
||||||
damping: $damp,
|
damping: $damp,
|
||||||
|
|||||||
@@ -63,6 +63,12 @@ public struct BoardFlowView: View {
|
|||||||
private let shoeGaze: ShoeGaze
|
private let shoeGaze: ShoeGaze
|
||||||
private let boardIndex: Int
|
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),
|
/// Undo coordinator injected by ``ShoeGazeBuilderView``; `nil` in lightweight hosts (previews),
|
||||||
/// where edits run directly without recording history.
|
/// where edits run directly without recording history.
|
||||||
@Environment(UndoCoordinator.self) private var undo: UndoCoordinator?
|
@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.
|
/// lanes exceed the viewport height (tall parallel splits). Otherwise scrolling stays horizontal.
|
||||||
@State private var contentHeight: CGFloat = 0
|
@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.shoeGaze = shoeGaze
|
||||||
self.boardIndex = boardIndex
|
self.boardIndex = boardIndex
|
||||||
|
self.sizesToContent = sizesToContent
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Body
|
// MARK: - Body
|
||||||
@@ -91,31 +98,45 @@ public struct BoardFlowView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ViewBuilder
|
||||||
private func flow(board: PedalBoard) -> some View {
|
private func flow(board: PedalBoard) -> some View {
|
||||||
let stages: [StageModel] = stageModels(board: board)
|
let stages: [StageModel] = stageModels(board: board)
|
||||||
return GeometryReader { proxy in
|
if sizesToContent {
|
||||||
let viewportHeight: CGFloat = proxy.size.height
|
// One-scroller mode: the board is only as tall as its chain and scrolls horizontally,
|
||||||
// Lock to horizontal, adding the vertical axis only when the chain is taller than the
|
// so the outer vertical scroller flows pre-board → board → post-board as one page with
|
||||||
// viewport (deep parallel splits) so it can be reached instead of clipped.
|
// no nested vertical scroll. A tall parallel split simply makes the page taller.
|
||||||
let axes: Axis.Set = contentHeight > viewportHeight + BoardFlowView.verticalScrollSlack
|
ScrollView(.horizontal, showsIndicators: true) {
|
||||||
? [.horizontal, .vertical]
|
chainRow(board: board, stages: stages)
|
||||||
: .horizontal
|
|
||||||
ScrollView(axes, showsIndicators: true) {
|
|
||||||
// The spacers centre the chain vertically when it is shorter than the viewport; when
|
|
||||||
// it overflows, the min-height floor is already exceeded so they collapse to zero and
|
|
||||||
// the chain scrolls. Pedals keep their intrinsic height either way — the window no
|
|
||||||
// longer stretches them.
|
|
||||||
VStack(spacing: 0) {
|
|
||||||
Spacer(minLength: 0)
|
|
||||||
chainRow(board: board, stages: stages)
|
|
||||||
Spacer(minLength: 0)
|
|
||||||
}
|
|
||||||
.frame(minHeight: viewportHeight)
|
|
||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
.frame(height: contentHeight > 0 ? contentHeight : nil)
|
||||||
.onPreferenceChange(BoardFlowContentHeightKey.self) { height in
|
.onPreferenceChange(BoardFlowContentHeightKey.self) { height in
|
||||||
contentHeight = height
|
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.
|
||||||
|
let axes: Axis.Set = contentHeight > viewportHeight + BoardFlowView.verticalScrollSlack
|
||||||
|
? [.horizontal, .vertical]
|
||||||
|
: .horizontal
|
||||||
|
ScrollView(axes, showsIndicators: true) {
|
||||||
|
// The spacers centre the chain vertically when it is shorter than the viewport; when
|
||||||
|
// it overflows, the min-height floor is already exceeded so they collapse to zero and
|
||||||
|
// the chain scrolls. Pedals keep their intrinsic height either way — the window no
|
||||||
|
// longer stretches them.
|
||||||
|
VStack(spacing: 0) {
|
||||||
|
Spacer(minLength: 0)
|
||||||
|
chainRow(board: board, stages: stages)
|
||||||
|
Spacer(minLength: 0)
|
||||||
|
}
|
||||||
|
.frame(minHeight: viewportHeight)
|
||||||
|
}
|
||||||
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
|
.onPreferenceChange(BoardFlowContentHeightKey.self) { height in
|
||||||
|
contentHeight = height
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -726,9 +726,18 @@ public struct ShoeGazeBuilderView: View {
|
|||||||
}
|
}
|
||||||
Divider().overlay(Color.white.opacity(ShoeGazeBuilderView.dividerOpacity))
|
Divider().overlay(Color.white.opacity(ShoeGazeBuilderView.dividerOpacity))
|
||||||
ControlMappingLegend()
|
ControlMappingLegend()
|
||||||
preBoardStrip
|
// Pre-board, the board canvas and post-board share a single vertical scroller, so the whole
|
||||||
boardArea
|
// signal path reads top-to-bottom as one page (on macOS and iOS alike) instead of pinning
|
||||||
postBoardStrip
|
// 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)
|
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
||||||
// Make the undo coordinator reachable to every board / palette subview so their structural
|
// Make the undo coordinator reachable to every board / palette subview so their structural
|
||||||
@@ -1598,13 +1607,11 @@ public struct ShoeGazeBuilderView: View {
|
|||||||
// MARK: - Board area
|
// MARK: - Board area
|
||||||
|
|
||||||
private var boardArea: some View {
|
private var boardArea: some View {
|
||||||
// Vertically center the signal-flow board in the available space.
|
// Content-sized so it flows inside the shared pre/board/post vertical scroller (scrolls
|
||||||
VStack(spacing: 0) {
|
// horizontally for a long chain; a tall parallel split grows the page). No vertical centering —
|
||||||
Spacer(minLength: 0)
|
// the board sits in signal-flow order between the pre-board and post-board strips.
|
||||||
BoardFlowView(shoeGaze: shoeGaze, boardIndex: clampedBoardIndex)
|
BoardFlowView(shoeGaze: shoeGaze, boardIndex: clampedBoardIndex, sizesToContent: true)
|
||||||
Spacer(minLength: 0)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
}
|
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Performs a routing action from the palette against the selected board.
|
/// Performs a routing action from the palette against the selected board.
|
||||||
|
|||||||
@@ -188,47 +188,87 @@ struct TunedVerbPedalTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test func panShiftsTheLeftLeg() throws {
|
@Test func panShiftsTheLeftLeg() throws {
|
||||||
// Fully wet, the output follows the panned wash. Hard left fills the left leg; hard right
|
// Fully wet, the output follows the panned wash — but the wash only exists after a capture, so
|
||||||
// nearly empties it. (Tests exercise the left output leg; the right is board-wired live.)
|
// capture early, then measure. Hard left fills the left leg; hard right nearly empties it.
|
||||||
let hardLeft: [Float] = try render(duration: 0.6) { pedal in pedal.mix = 1.0; pedal.pan = -1.0 }
|
// (`stepRender` returns the left output bus; the right is board-wired live.)
|
||||||
let hardRight: [Float] = try render(duration: 0.6) { pedal in pedal.mix = 1.0; pedal.pan = 1.0 }
|
let blockSize: Int = 512
|
||||||
let leftRMS: Double = rms(hardLeft, loFrame: 0, hiFrame: hardLeft.count)
|
let totalFrames: Int = Int(0.8 * sampleRate)
|
||||||
let rightRMS: Double = rms(hardRight, loFrame: 0, hiFrame: hardRight.count)
|
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,
|
#expect(leftRMS > rightRMS * 3.0,
|
||||||
"panning hard left should fill the left leg far more than hard right: L \(leftRMS) vs R \(rightRMS)")
|
"panning hard left should fill the left leg far more than hard right: L \(leftRMS) vs R \(rightRMS)")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test func captureLocksTheFilterSoAChangedInputIsShapedDifferently() throws {
|
@Test func wetIsSilentUntilCaptureThenAudible() throws {
|
||||||
// Capture the filter on tone A, then morph the input to tone B. A locked filter (shaped by A)
|
// Core contract: with no captured moment there is no filter template, so a fully-wet TunedVerb
|
||||||
// masks B differently than a filter that keeps tracking the live input — so the two renders
|
// must output silence — not the live pass-through poured into the reverb. After the Capture
|
||||||
// diverge once the input has changed.
|
// 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 blockSize: Int = 512
|
||||||
let totalFrames: Int = Int(1.4 * sampleRate)
|
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 windowLo: Int = Int(0.95 * sampleRate)
|
||||||
let windowHi: Int = Int(1.35 * sampleRate)
|
let windowHi: Int = Int(1.35 * sampleRate)
|
||||||
|
|
||||||
var captured: Bool = false
|
// Locked on tone A, then morphed to B.
|
||||||
let locked: [Float] = try stepRender(totalFrames: totalFrames, blockSize: blockSize) { pedal in
|
var capturedA: Bool = false
|
||||||
|
let lockedOnA: [Float] = try stepRender(totalFrames: totalFrames, blockSize: blockSize) { pedal in
|
||||||
pedal.mix = 1.0; pedal.time = 3.0
|
pedal.mix = 1.0; pedal.time = 3.0
|
||||||
} onFrame: { frame, source, pedal in
|
} onFrame: { frame, source, pedal in
|
||||||
if frame >= captureFrame, !captured { pedal.toggleCapture(); captured = true }
|
if frame >= Int(0.4 * sampleRate), !capturedA { pedal.toggleCapture(); capturedA = true }
|
||||||
if frame >= morphFrame { source.morph = 1.0 } // switch to tone B
|
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
|
pedal.mix = 1.0; pedal.time = 3.0
|
||||||
} onFrame: { frame, source, _ in
|
} onFrame: { frame, source, pedal in
|
||||||
// Never capture; morph at the same frame.
|
if frame >= Int(0.2 * sampleRate) { source.morph = 1.0 } // switch to tone B first
|
||||||
if frame >= morphFrame { source.morph = 1.0 }
|
if frame >= Int(0.4 * sampleRate), !capturedB { pedal.toggleCapture(); capturedB = true }
|
||||||
}
|
}
|
||||||
|
|
||||||
let signal: Double = rms(tracking, loFrame: windowLo, hiFrame: windowHi)
|
let signal: Double = rms(lockedOnB, loFrame: windowLo, hiFrame: windowHi)
|
||||||
let diff: Double = rmsDiff(locked, tracking, loFrame: windowLo, hiFrame: windowHi)
|
let diff: Double = rmsDiff(lockedOnA, lockedOnB, loFrame: windowLo, hiFrame: windowHi)
|
||||||
#expect(signal > 1.0e-4, "control render should be audible on tone B, got \(signal)")
|
#expect(signal > 1.0e-4, "a captured render should be audible on tone B, got \(signal)")
|
||||||
#expect(diff > signal * 0.25,
|
#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
|
// MARK: - Bypass
|
||||||
|
|||||||
Reference in New Issue
Block a user