Release 2.0.0: metronome, rig mute + shortcuts, set-list ordering, per-rig persistence
- Visual metronome tempo indicator (pendulum playhead) replacing the flashing LED - Rig Mute (Cmd-Z) hard-silence, distinct from Bypass Rig; wired to header, board menu, MIDI - Keyboard shortcuts: Cmd-1..9 board switch, Cmd-Shift-1..0 set-list rig load, Cmd-Z mute (macOS native menus + iOS/iPadOS hardware keyboards) - Rig set-list ordering: drag or Move Up/Down in the picker; order saved and archive-portable - Persist tempo, input selection, and engine I/O with a rig (I/O applied via opt-in applyChannelLayout, not forced on load) - Fix archive import colliding set-list positions with existing rigs - Remove ShoeGazeDemo / ShoeGazeiOSDemo apps and projects; keep the two Builder apps - Bump marketing version to 2.0.0 on both Builder projects; pin Lyrebird 1.2.3 - Add CHANGELOG.md Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -316,6 +316,138 @@ struct PresetTests {
|
||||
#expect(abs(driveValue - 12.0) < 1e-9, "drive knob value should be 12.0, got \(driveValue)")
|
||||
}
|
||||
|
||||
// MARK: - Tempo & input persistence
|
||||
|
||||
@Test func tempoAndInputSettingsRoundTripThroughFile() throws {
|
||||
let (sg, _, url): (ShoeGaze, SynthesisEngine, URL) = try makeTwoBoardRig()
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
let presetURL: URL = FileManager.default.temporaryDirectory
|
||||
.appendingPathComponent(UUID().uuidString + ".json")
|
||||
defer { try? FileManager.default.removeItem(at: presetURL) }
|
||||
|
||||
// Save a distinctive tempo + disabled tempo features (input stays on the test loop).
|
||||
let savedBpm: Double = 132.0
|
||||
sg.clock.bpm = savedBpm
|
||||
sg.setTempoEnabled(false)
|
||||
try sg.saveRig(to: presetURL)
|
||||
|
||||
// Drift the live values away from what was saved, then confirm the reload restores them.
|
||||
sg.clock.bpm = 90.0
|
||||
sg.setTempoEnabled(true)
|
||||
|
||||
try sg.loadRig(from: presetURL)
|
||||
#expect(abs(sg.clock.bpm - savedBpm) < 1e-9, "bpm should restore to \(savedBpm)")
|
||||
#expect(sg.tempoEnabled == false, "tempoEnabled should restore to false")
|
||||
#expect(sg.inputSource == .testLoop, "input source should restore to test loop")
|
||||
}
|
||||
|
||||
@Test func liveInputSourcePersistsAndFallsBackWhenChannelMissing() throws {
|
||||
// Engine WITH an input channel: a live-input rig round-trips its source.
|
||||
let (engineIn, urlIn): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: 0.1,
|
||||
numInputChannels: 1,
|
||||
numAudioBuses: 128
|
||||
)
|
||||
defer { try? FileManager.default.removeItem(at: urlIn) }
|
||||
let sgIn: ShoeGaze = ShoeGaze(engine: engineIn, inputSource: .liveInput(channel: 0))
|
||||
let board: PedalBoard = try sgIn.addBoard()
|
||||
try board.add(OverdrivePedal())
|
||||
try sgIn.finalizeBoard(board)
|
||||
|
||||
let state: ShoeGazeState = sgIn.captureState()
|
||||
#expect(state.inputSource == .liveInput(channel: 0), "capture should record the live input")
|
||||
|
||||
// Reload into the same input-capable engine: source preserved.
|
||||
try sgIn.loadRig(from: state)
|
||||
#expect(sgIn.inputSource == .liveInput(channel: 0), "live input should round-trip")
|
||||
|
||||
// loadRig does NOT auto-apply the saved channel layout, so loading into an engine with no
|
||||
// input channels falls back to the test loop rather than clobbering the engine's config.
|
||||
let (engineNoIn, urlNoIn): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: 0.1,
|
||||
numInputChannels: 0,
|
||||
numAudioBuses: 128
|
||||
)
|
||||
defer { try? FileManager.default.removeItem(at: urlNoIn) }
|
||||
let sgNoIn: ShoeGaze = ShoeGaze(engine: engineNoIn)
|
||||
try sgNoIn.loadRig(from: state)
|
||||
#expect(engineNoIn.numInputChannels == 0, "loadRig must not reconfigure the engine's I/O")
|
||||
#expect(sgNoIn.inputSource == .testLoop, "missing channel should fall back to test loop")
|
||||
}
|
||||
|
||||
@Test func channelCountsPersistButLoadDoesNotReconfigure() throws {
|
||||
// Capture a rig on an engine with 1 input / 2 output channels: the counts are recorded and
|
||||
// survive a JSON round-trip.
|
||||
let (engineA, urlA): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: 0.1,
|
||||
numOutputChannels: 2,
|
||||
numInputChannels: 1,
|
||||
numAudioBuses: 128
|
||||
)
|
||||
defer { try? FileManager.default.removeItem(at: urlA) }
|
||||
let sgA: ShoeGaze = ShoeGaze(engine: engineA)
|
||||
let boardA: PedalBoard = try sgA.addBoard()
|
||||
try boardA.add(OverdrivePedal())
|
||||
try sgA.finalizeBoard(boardA)
|
||||
|
||||
let state: ShoeGazeState = sgA.captureState()
|
||||
#expect(state.numInputChannels == 1)
|
||||
#expect(state.numOutputChannels == 2)
|
||||
let decoded: ShoeGazeState = try JSONDecoder().decode(
|
||||
ShoeGazeState.self, from: JSONEncoder().encode(state)
|
||||
)
|
||||
#expect(decoded.numInputChannels == 1)
|
||||
#expect(decoded.numOutputChannels == 2)
|
||||
|
||||
// Loading the rig must NOT reconfigure the destination engine's channel layout.
|
||||
let (engineB, urlB): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: 0.1,
|
||||
numOutputChannels: 2,
|
||||
numInputChannels: 0,
|
||||
numAudioBuses: 128
|
||||
)
|
||||
defer { try? FileManager.default.removeItem(at: urlB) }
|
||||
let sgB: ShoeGaze = ShoeGaze(engine: engineB)
|
||||
try sgB.loadRig(from: state)
|
||||
#expect(engineB.numInputChannels == 0, "loadRig must leave engine I/O untouched")
|
||||
}
|
||||
|
||||
@Test func applyChannelLayoutReconfiguresEngineToSavedCounts() throws {
|
||||
// The deliberate opt-in DOES reconfigure the engine to a rig's saved channel layout.
|
||||
let (engineA, urlA): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: 0.1,
|
||||
numOutputChannels: 2,
|
||||
numInputChannels: 1,
|
||||
numAudioBuses: 128
|
||||
)
|
||||
defer { try? FileManager.default.removeItem(at: urlA) }
|
||||
let sgA: ShoeGaze = ShoeGaze(engine: engineA)
|
||||
let boardA: PedalBoard = try sgA.addBoard()
|
||||
try boardA.add(OverdrivePedal())
|
||||
try sgA.finalizeBoard(boardA)
|
||||
let state: ShoeGazeState = sgA.captureState()
|
||||
|
||||
let (engineB, urlB): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: 0.1,
|
||||
numOutputChannels: 2,
|
||||
numInputChannels: 0,
|
||||
numAudioBuses: 128
|
||||
)
|
||||
defer { try? FileManager.default.removeItem(at: urlB) }
|
||||
let sgB: ShoeGaze = ShoeGaze(engine: engineB)
|
||||
try sgB.loadRig(from: state)
|
||||
#expect(engineB.numInputChannels == 0, "load alone leaves I/O untouched")
|
||||
|
||||
let changed: Bool = try sgB.applyChannelLayout(from: state)
|
||||
#expect(changed, "applyChannelLayout should report a change")
|
||||
#expect(engineB.numInputChannels == 1, "opt-in apply reconfigures to the saved input count")
|
||||
#expect(engineB.numOutputChannels == 2)
|
||||
|
||||
// Idempotent: applying again with matching counts is a no-op.
|
||||
let changedAgain: Bool = try sgB.applyChannelLayout(from: state)
|
||||
#expect(!changedAgain, "no reconfigure when counts already match")
|
||||
}
|
||||
|
||||
// MARK: - Save / Load via temp file
|
||||
|
||||
@Test func saveRigAndLoadRigRestoresKnobValues() throws {
|
||||
|
||||
@@ -202,4 +202,138 @@ struct RigLibraryStoreTests {
|
||||
#expect(store.entries.isEmpty)
|
||||
store.flushPendingWrites()
|
||||
}
|
||||
|
||||
// MARK: - Set-list ordering
|
||||
|
||||
@Test func newSavesAppendToSetListInSaveOrder() async throws {
|
||||
let (store, dir): (RigLibraryStore, URL) = await makeStore()
|
||||
defer { try? FileManager.default.removeItem(at: dir) }
|
||||
|
||||
// Save in reverse-alphabetical order; the set list keeps SAVE order, not name order.
|
||||
try store.save(makeEntry("Zebra"))
|
||||
try store.save(makeEntry("Alpha"))
|
||||
#expect(store.entries.map(\.name) == ["Zebra", "Alpha"])
|
||||
#expect(store.entries.map(\.sortIndex) == [0, 1])
|
||||
store.flushPendingWrites()
|
||||
}
|
||||
|
||||
@Test func moveUpMoveDownReorderAndPersistAcrossReload() async throws {
|
||||
let (store, dir): (RigLibraryStore, URL) = await makeStore()
|
||||
defer { try? FileManager.default.removeItem(at: dir) }
|
||||
|
||||
try store.save(makeEntry("A"))
|
||||
try store.save(makeEntry("B"))
|
||||
try store.save(makeEntry("C"))
|
||||
|
||||
// A,B,C → move C up → A,C,B → move A down → C,A,B
|
||||
guard let entryC: RigEntry = store.entries.first(where: { $0.name == "C" }) else {
|
||||
Issue.record("missing C"); return
|
||||
}
|
||||
store.moveUp(entryC)
|
||||
#expect(store.entries.map(\.name) == ["A", "C", "B"])
|
||||
|
||||
guard let entryA: RigEntry = store.entries.first(where: { $0.name == "A" }) else {
|
||||
Issue.record("missing A"); return
|
||||
}
|
||||
store.moveDown(entryA)
|
||||
#expect(store.entries.map(\.name) == ["C", "A", "B"])
|
||||
#expect(store.entries.map(\.sortIndex) == [0, 1, 2])
|
||||
|
||||
// Order survives a fresh store over the same directory.
|
||||
store.flushPendingWrites()
|
||||
let reopened: RigLibraryStore = RigLibraryStore(directory: dir, isICloud: false)
|
||||
await reopened.start()
|
||||
#expect(reopened.entries.map(\.name) == ["C", "A", "B"])
|
||||
}
|
||||
|
||||
@Test func moveFromOffsetsReordersAndRenumbers() async throws {
|
||||
let (store, dir): (RigLibraryStore, URL) = await makeStore()
|
||||
defer { try? FileManager.default.removeItem(at: dir) }
|
||||
|
||||
try store.save(makeEntry("A"))
|
||||
try store.save(makeEntry("B"))
|
||||
try store.save(makeEntry("C"))
|
||||
|
||||
// SwiftUI List.onMove semantics: move the first row to the end.
|
||||
store.move(fromOffsets: IndexSet(integer: 0), toOffset: 3)
|
||||
#expect(store.entries.map(\.name) == ["B", "C", "A"])
|
||||
#expect(store.entries.map(\.sortIndex) == [0, 1, 2])
|
||||
store.flushPendingWrites()
|
||||
}
|
||||
|
||||
@Test func applyOrderReordersAndRenumbers() async throws {
|
||||
let (store, dir): (RigLibraryStore, URL) = await makeStore()
|
||||
defer { try? FileManager.default.removeItem(at: dir) }
|
||||
|
||||
try store.save(makeEntry("A"))
|
||||
try store.save(makeEntry("B"))
|
||||
try store.save(makeEntry("C"))
|
||||
let byName: [String: UUID] = Dictionary(uniqueKeysWithValues: store.entries.map { ($0.name, $0.id) })
|
||||
|
||||
store.applyOrder([byName["C"], byName["A"], byName["B"]].compactMap { $0 })
|
||||
#expect(store.entries.map(\.name) == ["C", "A", "B"])
|
||||
#expect(store.entries.map(\.sortIndex) == [0, 1, 2])
|
||||
store.flushPendingWrites()
|
||||
}
|
||||
|
||||
@Test func renamePreservesSetListPosition() async throws {
|
||||
let (store, dir): (RigLibraryStore, URL) = await makeStore()
|
||||
defer { try? FileManager.default.removeItem(at: dir) }
|
||||
|
||||
try store.save(makeEntry("A"))
|
||||
try store.save(makeEntry("B"))
|
||||
try store.save(makeEntry("C"))
|
||||
let byName: [String: UUID] = Dictionary(uniqueKeysWithValues: store.entries.map { ($0.name, $0.id) })
|
||||
store.applyOrder([byName["C"], byName["A"], byName["B"]].compactMap { $0 })
|
||||
|
||||
// Renaming the middle rig keeps its slot rather than re-sorting by the new name.
|
||||
guard let entryA: RigEntry = store.entries.first(where: { $0.name == "A" }) else {
|
||||
Issue.record("missing A"); return
|
||||
}
|
||||
_ = try store.rename(entryA, to: "Zzz")
|
||||
#expect(store.entries.map(\.name) == ["C", "Zzz", "B"])
|
||||
store.flushPendingWrites()
|
||||
}
|
||||
|
||||
@Test func exportedArchiveCarriesSetListOrder() async throws {
|
||||
let (store, dir): (RigLibraryStore, URL) = await makeStore()
|
||||
defer { try? FileManager.default.removeItem(at: dir) }
|
||||
|
||||
try store.save(makeEntry("A"))
|
||||
try store.save(makeEntry("B"))
|
||||
try store.save(makeEntry("C"))
|
||||
let byName: [String: UUID] = Dictionary(uniqueKeysWithValues: store.entries.map { ($0.name, $0.id) })
|
||||
store.applyOrder([byName["C"], byName["A"], byName["B"]].compactMap { $0 })
|
||||
let archiveData: Data = try store.exportArchiveData()
|
||||
|
||||
// A fresh store importing the archive sees the same set-list order.
|
||||
let (other, otherDir): (RigLibraryStore, URL) = await makeStore()
|
||||
defer { try? FileManager.default.removeItem(at: otherDir) }
|
||||
_ = try other.importArchive(from: archiveData)
|
||||
#expect(other.entries.map(\.name) == ["C", "A", "B"])
|
||||
store.flushPendingWrites()
|
||||
other.flushPendingWrites()
|
||||
}
|
||||
|
||||
@Test func importAppendsAfterExistingRigsWithoutInterleaving() async throws {
|
||||
// Source archive with its own set-list order.
|
||||
let (source, srcDir): (RigLibraryStore, URL) = await makeStore()
|
||||
defer { try? FileManager.default.removeItem(at: srcDir) }
|
||||
try source.save(makeEntry("Import1"))
|
||||
try source.save(makeEntry("Import2"))
|
||||
let archiveData: Data = try source.exportArchiveData()
|
||||
|
||||
// Destination already holds two placed rigs; the import must land AFTER them (append),
|
||||
// not interleave by name/date on a colliding sortIndex.
|
||||
let (dest, destDir): (RigLibraryStore, URL) = await makeStore()
|
||||
defer { try? FileManager.default.removeItem(at: destDir) }
|
||||
try dest.save(makeEntry("Existing1"))
|
||||
try dest.save(makeEntry("Existing2"))
|
||||
_ = try dest.importArchive(from: archiveData)
|
||||
|
||||
#expect(dest.entries.map(\.name) == ["Existing1", "Existing2", "Import1", "Import2"])
|
||||
#expect(dest.entries.map(\.sortIndex) == [0, 1, 2, 3])
|
||||
source.flushPendingWrites()
|
||||
dest.flushPendingWrites()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user