feat(ui): amp-head layout + Neural Amp model loader (S4)
- AmpPedal: double-width (widthUnits 2) amp-head card so the four tone knobs + Amp/Cab selectors + master aren't cramped. Uses the generic single-column content (no greedy Spacers → no flow-canvas height issue). - Neural Amp model loader: PedalView renders, for a NeuralAmpPedal, a "Load Model…" picker (.fileImporter for .json) plus the loaded model's filename. Picking sets Pedal.resourcePath and asks the host to rebuild the board so the model applies live. Picker + AppKit stay in the UI layer (core imports none). - New `pedalRebuildAction` environment value (@MainActor @Sendable), installed by ShoeGazeBuilderView; it resolves the pedal's board via a new branch-aware `ShoeGaze.board(containing:)` (finds pedals inside parallel / stereo-split branches, not just the main chain) and rebuilds it via the live-safe `rebuildBoard(_:from:)`. Tests: AmpPedal widthUnits == 2; board(containing:) finds main + branch pedals and returns nil for a stranger. Full suite 502. (SwiftUI loader flow needs on-device visual QA.) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -89,6 +89,7 @@ struct AmpPedalTests {
|
||||
let pedal: AmpPedal = AmpPedal()
|
||||
#expect(pedal.effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble"])
|
||||
#expect(pedal.effectSelectors.map { $0.label } == ["Amp", "Cab"])
|
||||
#expect(pedal.widthUnits == 2, "amp head should use a double-width card")
|
||||
}
|
||||
|
||||
@Test func selectionsRoundTripThroughState() throws {
|
||||
|
||||
@@ -461,6 +461,33 @@ struct BoardEditAPITests {
|
||||
#expect(hasNonSilentOutput(samples), "stereo-split board should render audio")
|
||||
}
|
||||
|
||||
@Test func boardContainingFindsMainAndBranchPedals() throws {
|
||||
let (sg, _, url, board): (ShoeGaze, SynthesisEngine, URL, PedalBoard) =
|
||||
try makeRig(pedals: ["Overdrive"])
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
// Main-chain pedal is found.
|
||||
guard let mainPedal: Pedal = board.pedals.first else {
|
||||
Issue.record("no main pedal"); return
|
||||
}
|
||||
#expect(sg.board(containing: mainPedal) === board)
|
||||
|
||||
// A pedal inside a stereo-split branch is also found (the fix: not just the main chain).
|
||||
var live: PedalBoard = try sg.appendStereoSplit(to: board)
|
||||
live = try sg.appendPedal(.delay, to: live, lane: .left(region: 1))
|
||||
var branchPedal: Pedal?
|
||||
for segment: BoardSegment in live.orderedSegments {
|
||||
if case .stereoSplit(let section) = segment { branchPedal = section.left.pedals.first }
|
||||
}
|
||||
guard let branch: Pedal = branchPedal else {
|
||||
Issue.record("no branch pedal"); return
|
||||
}
|
||||
#expect(sg.board(containing: branch) === live, "branch pedal should resolve to its board")
|
||||
|
||||
// A pedal not in any board resolves to nil.
|
||||
#expect(sg.board(containing: OverdrivePedal()) == nil)
|
||||
}
|
||||
|
||||
@Test func removePedalFromBranchLane() throws {
|
||||
let (sg, _, url, board): (ShoeGaze, SynthesisEngine, URL, PedalBoard) =
|
||||
try makeRig(pedals: ["Overdrive"])
|
||||
|
||||
Reference in New Issue
Block a user