diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..75ca3bf --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,92 @@ +# Changelog + +All notable changes to ShoeGaze are recorded here. The format follows +[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses +[semantic versioning](https://semver.org/spec/v2.0.0.html). + +## [2.0.0] — 2026-07-05 + +Major release. Performance-focused: a visual metronome, a real rig mute with +keyboard control, and rigs that remember their tempo, input, and I/O — plus a +saveable set-list order for hands-free switching between rigs live. The version +jumps to 2.0.0 to align ShoeGaze's numbering with the wider project family. + +### Added + +- **Visual metronome tempo indicator.** A horizontal playhead sweeps wall-to-wall + once per beat with pendulum easing (it slows into each beat so you can anticipate + it), fades toward center, and flashes a glow on the downbeat. Replaces the single + flashing LED. +- **Rig Mute (⌘Z).** A hard gate that silences the entire rig output — distinct from + Bypass Rig, which passes your dry signal through. Reachable from the header, the + per-board volume row, the macOS Board menu, and MIDI. +- **Keyboard shortcuts** (macOS native menus + iOS/iPadOS hardware keyboards): + - `⌘1`–`⌘9` — switch to / solo boards 1–9. + - `⌘⇧1`–`⌘⇧9` and `⌘⇧0` — load set-list rigs 1–10 in library order. + - `⌘Z` — toggle rig mute. + + All are listed in the in-app Help. +- **macOS menus.** Board ▸ Mute Rig and Board ▸ Bypass Rig (with live state), and a + Rigs ▸ Set List submenu whose ten slots map to `⌘⇧1`–`⌘⇧0` and track the current + library order. +- **Set-list ordering.** Reorder rigs in the picker by dragging a row or via each + rig's Move Up / Move Down menu. The order is saved and travels with an exported + archive; the top ten map to the `⌘⇧` shortcuts. +- **Per-rig persistence.** A saved rig now also stores its tempo (BPM + enabled + state) and input selection. Engine input/output channel counts are saved too, and + applied on demand via `applyChannelLayout(from:)` rather than forced on every load. + +### Changed + +- The header "Mute rig" toggle — which actually only set the tuner-mutes-rig + preference — is now a real rig-mute button. The tuner preference is relabeled + **"Mute while tuning"**. +- The rig library now honors a manual set-list order instead of sorting by name/date. + New rigs append to the end; renaming a rig keeps its position. + +### Fixed + +- Importing a rig archive into a non-empty library no longer collides set-list + positions with existing rigs — imported rigs append in archive order. + +### Removed + +- The **ShoeGazeDemo** (macOS) and **ShoeGazeiOSDemo** (iOS) minimal-player apps and + their Xcode projects. Only the full **ShoeGazeBuilder** (macOS) and + **ShoeGazeBuilderiOS** (iPad) apps remain. + +### Compatibility + +- Despite the major-version bump, rig persistence is backward-compatible: the new + tempo / input / I/O / set-list fields are additive and optional. Rigs saved by + earlier versions load unchanged (missing fields are ignored), and rigs saved by + 2.0.0 still open in older builds (the new keys are ignored there). The 2.0.0 bump + reflects the scope of new features and version alignment, not a format break. + +## [1.5.0] — 2026-07-04 + +- Looper pedal, iPad/iOS layout rework, Lyrebird 1.2.3. + +## [1.4.0] — 2026-07-01 + +- Maintenance and refinements. + +## [1.3.0] — 2026-06-28 + +- Rig / board sharing via the `.shoegaze` document type. + +## [1.2.0] — 2026-06-28 + +- Ten new pedals, iCloud rig library, builder UI rework. + +## [1.1.1] — 2026-06-26 + +- Info-button placement and region-lane drag-drop fix. + +## [1.1.0] — 2026-06-26 + +- Refinements over the initial release. + +## [1.0.0] — 2026-06-24 + +- Initial ShoeGaze release. diff --git a/Demo/ShoeGazeBuilder.xcodeproj/project.pbxproj b/Demo/ShoeGazeBuilder.xcodeproj/project.pbxproj index bdb3e2a..445527d 100644 --- a/Demo/ShoeGazeBuilder.xcodeproj/project.pbxproj +++ b/Demo/ShoeGazeBuilder.xcodeproj/project.pbxproj @@ -163,7 +163,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 8; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = HE5VJFE9E4; @@ -176,7 +176,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 15.0; - MARKETING_VERSION = 1.5; + MARKETING_VERSION = 2.0.0; PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -194,7 +194,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 8; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = HE5VJFE9E4; ENABLE_HARDENED_RUNTIME = YES; @@ -206,7 +206,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 15.0; - MARKETING_VERSION = 1.5; + MARKETING_VERSION = 2.0.0; PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; diff --git a/Demo/ShoeGazeBuilder/AppDelegate.swift b/Demo/ShoeGazeBuilder/AppDelegate.swift index 6261809..dcdd248 100644 --- a/Demo/ShoeGazeBuilder/AppDelegate.swift +++ b/Demo/ShoeGazeBuilder/AppDelegate.swift @@ -20,7 +20,7 @@ import LyrebirdShoeGazeUI /// The engine is **not** started automatically; the user clicks Start in the builder's toolbar. /// On termination the engine is stopped to release Core Audio resources cleanly. @MainActor -final class AppDelegate: NSObject, NSApplicationDelegate { +final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate { // MARK: - Engine configuration constants @@ -65,6 +65,26 @@ final class AppDelegate: NSObject, NSApplicationDelegate { /// Record toggle item, retained so `validateMenuItem(_:)` can flip its title + enabled state. private var recordMenuItem: NSMenuItem? + /// Rig-mute toggle item, retained so `validateMenuItem(_:)` can flip its title + checkmark to + /// match the current mute state (which may also change from the UI, MIDI, or the tuner). + private var muteMenuItem: NSMenuItem? + + /// Rig-bypass toggle item, retained so `validateMenuItem(_:)` can flip its title + checkmark to + /// match the current bypass state (which may also change from the UI or MIDI). + private var bypassMenuItem: NSMenuItem? + + /// The Rigs ▸ Set List submenu, retained so its item titles can be refreshed to the current + /// library order each time it opens (via `menuNeedsUpdate(_:)`). + private var setListMenu: NSMenu? + + /// The ten fixed ⌘⇧1…⌘⇧0 set-list items (tags 0…9). Their key equivalents fire whether or not + /// the menu is open; `validateMenuItem(_:)` disables slots with no rig, and `menuNeedsUpdate` + /// refreshes their titles to the rig names. + private var setListMenuItems: [NSMenuItem] = [] + + /// Number of set-list slots exposed as ⌘⇧1…⌘⇧0. + private static let setListSlotCount: Int = 10 + /// The Help window, created lazily on first open and reused thereafter. private var helpWindow: LyrebirdWindow? @@ -283,6 +303,51 @@ final class AppDelegate: NSObject, NSApplicationDelegate { // Engine start/stop lives in the in-window EngineConfigView (with sample-rate/channel // config and the mismatch alert), so the Board menu only adds boards. addItem(to: boardMenu, title: "Add Board", action: #selector(addBoardAction(_:)), key: "b") + boardMenu.addItem(NSMenuItem.separator()) + // ⌘Z toggles rig mute (a hard silence of all output; distinct from Bypass Rig's dry + // passthrough). Owns the ⌘Z key equivalent on macOS; the in-window view binds it on iOS. + self.muteMenuItem = addItem( + to: boardMenu, + title: "Mute Rig", + action: #selector(toggleMuteAction(_:)), + key: "z" + ) + // Bypass Rig routes every board to its dry input (pedals skipped) — distinct from Mute's + // hard silence. No key equivalent: ⌘B is Add Board, and Bypass has a prominent on-screen button. + self.bypassMenuItem = addItem( + to: boardMenu, + title: "Bypass Rig", + action: #selector(toggleBypassAction(_:)), + key: "" + ) + + // Rigs menu — a Set List of the top ten library rigs, each on ⌘⇧1…⌘⇧0. The items are + // fixed; their titles refresh to the current library order on open, and their key + // equivalents fire whether or not the menu is showing. + let rigsMenuItem: NSMenuItem = NSMenuItem() + mainMenu.addItem(rigsMenuItem) + let rigsMenu: NSMenu = NSMenu(title: "Rigs") + rigsMenuItem.submenu = rigsMenu + let setListItem: NSMenuItem = NSMenuItem(title: "Set List", action: nil, keyEquivalent: "") + rigsMenu.addItem(setListItem) + let setListSubmenu: NSMenu = NSMenu(title: "Set List") + setListSubmenu.delegate = self + setListItem.submenu = setListSubmenu + for slot: Int in 0 ..< AppDelegate.setListSlotCount { + // Slots 0…8 → ⌘⇧1…⌘⇧9; slot 9 → ⌘⇧0 (matches the physical number row). + let key: String = slot < 9 ? "\(slot + 1)" : "0" + let item: NSMenuItem = NSMenuItem( + title: "\(slot + 1). —", + action: #selector(loadRigSlotAction(_:)), + keyEquivalent: key + ) + item.keyEquivalentModifierMask = [.command, .shift] + item.target = self + item.tag = slot + setListSubmenu.addItem(item) + setListMenuItems.append(item) + } + self.setListMenu = setListSubmenu // Record menu — choose an output folder, then toggle recording. let recordMenuItem: NSMenuItem = NSMenuItem() @@ -382,6 +447,25 @@ final class AppDelegate: NSObject, NSApplicationDelegate { } } + @objc private func toggleMuteAction(_ sender: Any?) { + shoeGaze.toggleRigMuted() + // Reflect the new state immediately, not only on the next menu-open validation. + muteMenuItem?.title = shoeGaze.rigMuted ? "Unmute Rig" : "Mute Rig" + muteMenuItem?.state = shoeGaze.rigMuted ? .on : .off + } + + @objc private func toggleBypassAction(_ sender: Any?) { + shoeGaze.toggleRigBypassed() + bypassMenuItem?.title = shoeGaze.rigBypassed ? "Re-engage Rig" : "Bypass Rig" + bypassMenuItem?.state = shoeGaze.rigBypassed ? .on : .off + } + + /// Loads the set-list rig at the sender's slot tag. Forwards to the in-window builder (which + /// owns the current-rig state, the unsaved-changes prompt, and engine lifecycle) via notification. + @objc private func loadRigSlotAction(_ sender: NSMenuItem) { + NotificationCenter.default.post(name: .shoeGazeLoadRigSlot, object: sender.tag) + } + @objc private func addBoardAction(_ sender: Any?) { var created: PedalBoard? do { @@ -421,12 +505,45 @@ final class AppDelegate: NSObject, NSApplicationDelegate { recordMenuItem?.title = shoeGaze.isRecording ? "Stop Recording" : "Start Recording" } + // MARK: - NSMenuDelegate + + /// Refreshes the Set List item titles to the current library order each time the submenu opens. + /// Key equivalents fire independently of this (see `setListMenuItems`); this is display only. + func menuNeedsUpdate(_ menu: NSMenu) { + guard menu === setListMenu else { return } + let entries: [RigEntry] = library.entries + for item: NSMenuItem in setListMenuItems { + let slot: Int = item.tag + if slot < entries.count { + item.title = "\(slot + 1). \(entries[slot].name)" + } else { + item.title = "\(slot + 1). —" + } + } + } + func validateMenuItem(_ menuItem: NSMenuItem) -> Bool { if menuItem == recordMenuItem { menuItem.title = shoeGaze.isRecording ? "Stop Recording" : "Start Recording" // Can always stop; can only start once a folder has been chosen. return shoeGaze.isRecording || shoeGaze.recordingFolder != nil } + if menuItem == muteMenuItem { + // Mute may have changed from the UI, MIDI, or the tuner — resync title + checkmark. + menuItem.title = shoeGaze.rigMuted ? "Unmute Rig" : "Mute Rig" + menuItem.state = shoeGaze.rigMuted ? .on : .off + return true + } + if menuItem == bypassMenuItem { + // Bypass may have changed from the UI or MIDI — resync title + checkmark. + menuItem.title = shoeGaze.rigBypassed ? "Re-engage Rig" : "Bypass Rig" + menuItem.state = shoeGaze.rigBypassed ? .on : .off + return true + } + if setListMenuItems.contains(menuItem) { + // A slot is live only when the library actually holds a rig at that position. + return menuItem.tag < library.entries.count + } return true } } diff --git a/Demo/ShoeGazeBuilderiOS.xcodeproj/project.pbxproj b/Demo/ShoeGazeBuilderiOS.xcodeproj/project.pbxproj index befe2f1..acc12b3 100644 --- a/Demo/ShoeGazeBuilderiOS.xcodeproj/project.pbxproj +++ b/Demo/ShoeGazeBuilderiOS.xcodeproj/project.pbxproj @@ -172,7 +172,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.7; + MARKETING_VERSION = 2.0.0; PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilderiOS; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; @@ -201,7 +201,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.7; + MARKETING_VERSION = 2.0.0; PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilderiOS; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; diff --git a/Demo/ShoeGazeDemo.xcodeproj/project.pbxproj b/Demo/ShoeGazeDemo.xcodeproj/project.pbxproj deleted file mode 100644 index cd9273d..0000000 --- a/Demo/ShoeGazeDemo.xcodeproj/project.pbxproj +++ /dev/null @@ -1,397 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 60; - objects = { - -/* Begin PBXBuildFile section */ - C3B000000000000000000020 /* LyrebirdShoeGaze in Frameworks */ = {isa = PBXBuildFile; productRef = C3B00000000000000000001E /* LyrebirdShoeGaze */; }; - C3B000000000000000000021 /* LyrebirdShoeGazeUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3B00000000000000000001F /* LyrebirdShoeGazeUI */; }; - C3B000000000000000000022 /* Lyrebird in Frameworks */ = {isa = PBXBuildFile; productRef = C3B000000000000000000023 /* Lyrebird */; }; - C3B000000000000000000024 /* LyrebirdUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3B000000000000000000025 /* LyrebirdUI */; }; - C3B000000000000000000031 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C3B000000000000000000030 /* Assets.xcassets */; }; - C3B0000000000000000000C /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B000000000000000000007 /* main.swift */; }; - C3B0000000000000000000D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B000000000000000000008 /* AppDelegate.swift */; }; - C3B0000000000000000000E /* DemoRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B000000000000000000009 /* DemoRootView.swift */; }; - C3B0000000000000000000F /* ShoeGazeDemoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B00000000000000000000A /* ShoeGazeDemoController.swift */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - C3B000000000000000000004 /* ShoeGazeDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ShoeGazeDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; - C3B000000000000000000006 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - C3B000000000000000000007 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; - C3B000000000000000000008 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - C3B000000000000000000009 /* DemoRootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoRootView.swift; sourceTree = ""; }; - C3B00000000000000000000A /* ShoeGazeDemoController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoeGazeDemoController.swift; sourceTree = ""; }; - C3B000000000000000000030 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - C3B000000000000000000012 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - C3B000000000000000000020 /* LyrebirdShoeGaze in Frameworks */, - C3B000000000000000000021 /* LyrebirdShoeGazeUI in Frameworks */, - C3B000000000000000000022 /* Lyrebird in Frameworks */, - C3B000000000000000000024 /* LyrebirdUI in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - C3B000000000000000000002 = { - isa = PBXGroup; - children = ( - C3B000000000000000000005 /* ShoeGazeDemo */, - C3B000000000000000000003 /* Products */, - ); - sourceTree = ""; - }; - C3B000000000000000000003 /* Products */ = { - isa = PBXGroup; - children = ( - C3B000000000000000000004 /* ShoeGazeDemo.app */, - ); - name = Products; - sourceTree = ""; - }; - C3B000000000000000000005 /* ShoeGazeDemo */ = { - isa = PBXGroup; - children = ( - C3B000000000000000000007 /* main.swift */, - C3B000000000000000000008 /* AppDelegate.swift */, - C3B000000000000000000009 /* DemoRootView.swift */, - C3B00000000000000000000A /* ShoeGazeDemoController.swift */, - C3B000000000000000000030 /* Assets.xcassets */, - C3B000000000000000000006 /* Info.plist */, - ); - path = ShoeGazeDemo; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - C3B000000000000000000014 /* ShoeGazeDemo */ = { - isa = PBXNativeTarget; - buildConfigurationList = C3B000000000000000000015 /* Build configuration list for PBXNativeTarget "ShoeGazeDemo" */; - buildPhases = ( - C3B000000000000000000011 /* Sources */, - C3B000000000000000000012 /* Frameworks */, - C3B000000000000000000013 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = ShoeGazeDemo; - packageProductDependencies = ( - C3B00000000000000000001E /* LyrebirdShoeGaze */, - C3B00000000000000000001F /* LyrebirdShoeGazeUI */, - C3B000000000000000000023 /* Lyrebird */, - C3B000000000000000000025 /* LyrebirdUI */, - ); - productName = ShoeGazeDemo; - productReference = C3B000000000000000000004 /* ShoeGazeDemo.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - C3B000000000000000000001 /* Project object */ = { - isa = PBXProject; - attributes = { - BuildIndependentTargetsInParallel = 1; - LastSwiftUpdateCheck = 1600; - LastUpgradeCheck = 2620; - TargetAttributes = { - C3B000000000000000000014 = { - CreatedOnToolsVersion = 16.0; - }; - }; - }; - buildConfigurationList = C3B000000000000000000018 /* Build configuration list for PBXProject "ShoeGazeDemo" */; - compatibilityVersion = "Xcode 14.0"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = C3B000000000000000000002; - packageReferences = ( - C3B00000000000000000001B /* XCLocalSwiftPackageReference ".." */, - C3B00000000000000000001C /* XCRemoteSwiftPackageReference "Lyrebird" */, - ); - productRefGroup = C3B000000000000000000003 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - C3B000000000000000000014 /* ShoeGazeDemo */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - C3B000000000000000000013 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - C3B000000000000000000031 /* Assets.xcassets in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - C3B000000000000000000011 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - C3B0000000000000000000C /* main.swift in Sources */, - C3B0000000000000000000D /* AppDelegate.swift in Sources */, - C3B0000000000000000000E /* DemoRootView.swift in Sources */, - C3B0000000000000000000F /* ShoeGazeDemoController.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - C3B000000000000000000016 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGNING_REQUIRED = NO; - CODE_SIGN_ENTITLEMENTS = ShoeGazeDemo/ShoeGazeDemo.entitlements; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - DEAD_CODE_STRIPPING = YES; - DEBUG_INFORMATION_FORMAT = dwarf; - DEVELOPMENT_TEAM = HE5VJFE9E4; - ENABLE_HARDENED_RUNTIME = YES; - INFOPLIST_FILE = ShoeGazeDemo/Info.plist; - INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - ); - MACOSX_DEPLOYMENT_TARGET = 15.0; - PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeDemo; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_VERSION = 5.0; - }; - name = Debug; - }; - C3B000000000000000000017 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGNING_REQUIRED = NO; - CODE_SIGN_ENTITLEMENTS = ShoeGazeDemo/ShoeGazeDemo.entitlements; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - DEAD_CODE_STRIPPING = YES; - DEVELOPMENT_TEAM = HE5VJFE9E4; - ENABLE_HARDENED_RUNTIME = YES; - INFOPLIST_FILE = ShoeGazeDemo/Info.plist; - INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - ); - MACOSX_DEPLOYMENT_TARGET = 15.0; - PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeDemo; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_VERSION = 5.0; - }; - name = Release; - }; - C3B000000000000000000019 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEAD_CODE_STRIPPING = YES; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - ENABLE_USER_SCRIPT_SANDBOXING = YES; - GCC_C_LANGUAGE_STANDARD = gnu17; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = macosx; - STRING_CATALOG_GENERATE_SYMBOLS = YES; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - C3B00000000000000000001A /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEAD_CODE_STRIPPING = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_USER_SCRIPT_SANDBOXING = YES; - GCC_C_LANGUAGE_STANDARD = gnu17; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SDKROOT = macosx; - STRING_CATALOG_GENERATE_SYMBOLS = YES; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - C3B000000000000000000015 /* Build configuration list for PBXNativeTarget "ShoeGazeDemo" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C3B000000000000000000016 /* Debug */, - C3B000000000000000000017 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - C3B000000000000000000018 /* Build configuration list for PBXProject "ShoeGazeDemo" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C3B000000000000000000019 /* Debug */, - C3B00000000000000000001A /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - -/* Begin XCLocalSwiftPackageReference section */ - C3B00000000000000000001B /* XCLocalSwiftPackageReference ".." */ = { - isa = XCLocalSwiftPackageReference; - relativePath = ..; - }; -/* End XCLocalSwiftPackageReference section */ - -/* Begin XCRemoteSwiftPackageReference section */ - C3B00000000000000000001C /* XCRemoteSwiftPackageReference "Lyrebird" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://realizedsound.mooo.com/josh/Lyrebird"; - requirement = { - kind = upToNextMajorVersion; - minimumVersion = 1.2.0; - }; - }; -/* End XCRemoteSwiftPackageReference section */ - -/* Begin XCSwiftPackageProductDependency section */ - C3B00000000000000000001E /* LyrebirdShoeGaze */ = { - isa = XCSwiftPackageProductDependency; - package = C3B00000000000000000001B /* XCLocalSwiftPackageReference ".." */; - productName = LyrebirdShoeGaze; - }; - C3B00000000000000000001F /* LyrebirdShoeGazeUI */ = { - isa = XCSwiftPackageProductDependency; - package = C3B00000000000000000001B /* XCLocalSwiftPackageReference ".." */; - productName = LyrebirdShoeGazeUI; - }; - C3B000000000000000000023 /* Lyrebird */ = { - isa = XCSwiftPackageProductDependency; - package = C3B00000000000000000001C /* XCRemoteSwiftPackageReference "Lyrebird" */; - productName = Lyrebird; - }; - C3B000000000000000000025 /* LyrebirdUI */ = { - isa = XCSwiftPackageProductDependency; - package = C3B00000000000000000001C /* XCRemoteSwiftPackageReference "Lyrebird" */; - productName = LyrebirdUI; - }; -/* End XCSwiftPackageProductDependency section */ - }; - rootObject = C3B000000000000000000001 /* Project object */; -} diff --git a/Demo/ShoeGazeDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Demo/ShoeGazeDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved deleted file mode 100644 index 82a587c..0000000 --- a/Demo/ShoeGazeDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ /dev/null @@ -1,33 +0,0 @@ -{ - "originHash" : "cfdd71f4b32d744c862bbe26a8265d75aa9e906275b0fb1b63575b7d68be1b6a", - "pins" : [ - { - "identity" : "linenoise-swift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/andybest/linenoise-swift", - "state" : { - "revision" : "afc897c02b030af7333105c4fedcd843a8339238", - "version" : "0.0.3" - } - }, - { - "identity" : "lyrebird", - "kind" : "remoteSourceControl", - "location" : "https://realizedsound.mooo.com/josh/Lyrebird", - "state" : { - "revision" : "032b7c39d351eba4029e8399e1ab1ee201e8bb5c", - "version" : "1.2.0" - } - }, - { - "identity" : "nimble", - "kind" : "remoteSourceControl", - "location" : "https://github.com/Quick/Nimble.git", - "state" : { - "revision" : "e9d769113660769a4d9dd3afb855562c0b7ae7b0", - "version" : "7.3.4" - } - } - ], - "version" : 3 -} diff --git a/Demo/ShoeGazeDemo.xcodeproj/xcshareddata/xcschemes/ShoeGazeDemo.xcscheme b/Demo/ShoeGazeDemo.xcodeproj/xcshareddata/xcschemes/ShoeGazeDemo.xcscheme deleted file mode 100644 index b787f7a..0000000 --- a/Demo/ShoeGazeDemo.xcodeproj/xcshareddata/xcschemes/ShoeGazeDemo.xcscheme +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Demo/ShoeGazeDemo/AppDelegate.swift b/Demo/ShoeGazeDemo/AppDelegate.swift deleted file mode 100644 index ab08347..0000000 --- a/Demo/ShoeGazeDemo/AppDelegate.swift +++ /dev/null @@ -1,153 +0,0 @@ -// AppDelegate.swift -// Lyrebird -// -// Copyright (c) 2026 Joshua Parmenter / realizedsound -// SPDX-License-Identifier: MIT - -#if os(macOS) -import AppKit -import LyrebirdSynth -import LyrebirdUI -import LyrebirdShoeGaze -import LyrebirdShoeGazeUI - -/// Application delegate for the ShoeGaze demo. -/// -/// Creates a `SynthesisEngine`, a `ShoeGazeDemoController` (which builds the default -/// `.boards` showcase automatically), and opens a `LyrebirdWindow` hosting `DemoRootView`. -/// -/// The engine is **not** started automatically. The user clicks Start in `DemoRootView`'s -/// toolbar (or presses Stop to halt audio). On application termination, `stop()` is called -/// to release Core Audio resources cleanly. -@MainActor -final class AppDelegate: NSObject, NSApplicationDelegate { - - // MARK: - Engine configuration constants - - private static let blockSize: Int = 512 - private static let sampleRate: Double = 48_000.0 - private static let outputChannels: Int = 2 - // Built-in mics are mono; default to one input channel so live input works out of the box - // (CoreAudio can't satisfy more input channels than the device provides). Raise in the UI. - private static let inputChannels: Int = 1 - private static let numAudioBuses: Int = 256 - - // MARK: - Window geometry constants - - private static let windowWidth: CGFloat = 1_100 - private static let windowHeight: CGFloat = 640 - - // MARK: - Owned objects - - private let coreDriver: CoreAudioDriver - private let controller: ShoeGazeDemoController - private let window: LyrebirdWindow - - /// The Mute menu item, retained so `validateMenuItem(_:)` can update its checkmark. - private var muteMenuItem: NSMenuItem? - - // MARK: - Init - - override init() { - let coreDriver: CoreAudioDriver = CoreAudioDriver() - let engine: SynthesisEngine = SynthesisEngine( - blockSize: AppDelegate.blockSize, - sampleRate: AppDelegate.sampleRate, - numOutputChannels: AppDelegate.outputChannels, - numInputChannels: AppDelegate.inputChannels, - numAudioBuses: AppDelegate.numAudioBuses, - driver: coreDriver - ) - - self.coreDriver = coreDriver - self.controller = ShoeGazeDemoController(engine: engine) - self.window = LyrebirdWindow( - title: "ShoeGaze — Lyrebird Guitar Pedalboard", - width: AppDelegate.windowWidth, - height: AppDelegate.windowHeight - ) - super.init() - } - - // MARK: - NSApplicationDelegate - - func applicationDidFinishLaunching(_ notification: Notification) { - installMainMenu() - let demoController: ShoeGazeDemoController = controller - let driver: CoreAudioDriver = coreDriver - window.open { - DemoRootView(controller: demoController, hardwareSampleRate: { driver.deviceSampleRate }) - } - } - - func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { - true - } - - func applicationWillTerminate(_ notification: Notification) { - controller.stop() - } - - // MARK: - Main menu - - /// Builds the app's menu bar: an application menu (About / Hide / Quit ⌘Q) and an - /// Audio menu (Mute ⌘M). Standard items route through the responder chain to - /// `NSApplication`; Mute targets this delegate. - private func installMainMenu() { - let appName: String = ProcessInfo.processInfo.processName - let mainMenu: NSMenu = NSMenu() - - // Application menu. - let appMenuItem: NSMenuItem = NSMenuItem() - mainMenu.addItem(appMenuItem) - let appMenu: NSMenu = NSMenu() - appMenuItem.submenu = appMenu - appMenu.addItem( - withTitle: "About \(appName)", - action: #selector(NSApplication.orderFrontStandardAboutPanel(_:)), - keyEquivalent: "" - ) - appMenu.addItem(NSMenuItem.separator()) - appMenu.addItem( - withTitle: "Hide \(appName)", - action: #selector(NSApplication.hide(_:)), - keyEquivalent: "h" - ) - appMenu.addItem(NSMenuItem.separator()) - appMenu.addItem( - withTitle: "Quit \(appName)", - action: #selector(NSApplication.terminate(_:)), - keyEquivalent: "q" - ) - - // Audio menu. - let audioMenuItem: NSMenuItem = NSMenuItem() - mainMenu.addItem(audioMenuItem) - let audioMenu: NSMenu = NSMenu(title: "Audio") - audioMenuItem.submenu = audioMenu - let mute: NSMenuItem = NSMenuItem( - title: "Mute", - action: #selector(toggleMute(_:)), - keyEquivalent: "m" - ) - mute.target = self - audioMenu.addItem(mute) - muteMenuItem = mute - - NSApplication.shared.mainMenu = mainMenu - } - - /// Toggles audio output (mute). Bound to the Audio ▸ Mute menu item (⌘M). - @objc private func toggleMute(_ sender: Any?) { - controller.toggleMute() - } - - /// Shows a checkmark on the Mute item while audio is silenced (engine not running). - func validateMenuItem(_ menuItem: NSMenuItem) -> Bool { - if menuItem == muteMenuItem { - menuItem.state = controller.isRunning ? .off : .on - } - return true - } -} -#endif diff --git a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/Contents.json b/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index e4fc045..0000000 --- a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "images" : [ - {"size":"16x16","idiom":"mac","filename":"icon_16x16.png","scale":"1x"}, - {"size":"16x16","idiom":"mac","filename":"icon_16x16@2x.png","scale":"2x"}, - {"size":"32x32","idiom":"mac","filename":"icon_32x32.png","scale":"1x"}, - {"size":"32x32","idiom":"mac","filename":"icon_32x32@2x.png","scale":"2x"}, - {"size":"128x128","idiom":"mac","filename":"icon_128x128.png","scale":"1x"}, - {"size":"128x128","idiom":"mac","filename":"icon_128x128@2x.png","scale":"2x"}, - {"size":"256x256","idiom":"mac","filename":"icon_256x256.png","scale":"1x"}, - {"size":"256x256","idiom":"mac","filename":"icon_256x256@2x.png","scale":"2x"}, - {"size":"512x512","idiom":"mac","filename":"icon_512x512.png","scale":"1x"}, - {"size":"512x512","idiom":"mac","filename":"icon_512x512@2x.png","scale":"2x"} - ], - "info" : {"author":"xcode","version":1} -} diff --git a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_128x128.png b/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_128x128.png deleted file mode 100644 index 11eb204..0000000 Binary files a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_128x128.png and /dev/null differ diff --git a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png b/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png deleted file mode 100644 index 9fb9569..0000000 Binary files a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png and /dev/null differ diff --git a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_16x16.png b/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_16x16.png deleted file mode 100644 index 9a6d8ba..0000000 Binary files a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_16x16.png and /dev/null differ diff --git a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png b/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png deleted file mode 100644 index 746cd1c..0000000 Binary files a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png and /dev/null differ diff --git a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_256x256.png b/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_256x256.png deleted file mode 100644 index 9fb9569..0000000 Binary files a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_256x256.png and /dev/null differ diff --git a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png b/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png deleted file mode 100644 index 056c79a..0000000 Binary files a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png and /dev/null differ diff --git a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_32x32.png b/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_32x32.png deleted file mode 100644 index 746cd1c..0000000 Binary files a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_32x32.png and /dev/null differ diff --git a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png b/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png deleted file mode 100644 index 5a5997e..0000000 Binary files a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png and /dev/null differ diff --git a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_512x512.png b/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_512x512.png deleted file mode 100644 index 056c79a..0000000 Binary files a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_512x512.png and /dev/null differ diff --git a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png b/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png deleted file mode 100644 index 34c43a1..0000000 Binary files a/Demo/ShoeGazeDemo/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png and /dev/null differ diff --git a/Demo/ShoeGazeDemo/Assets.xcassets/Contents.json b/Demo/ShoeGazeDemo/Assets.xcassets/Contents.json deleted file mode 100644 index 4359fd8..0000000 --- a/Demo/ShoeGazeDemo/Assets.xcassets/Contents.json +++ /dev/null @@ -1 +0,0 @@ -{ "info" : {"author":"xcode","version":1} } diff --git a/Demo/ShoeGazeDemo/DemoRootView.swift b/Demo/ShoeGazeDemo/DemoRootView.swift deleted file mode 100644 index 0a06f6e..0000000 --- a/Demo/ShoeGazeDemo/DemoRootView.swift +++ /dev/null @@ -1,303 +0,0 @@ -// DemoRootView.swift -// Lyrebird -// -// Copyright (c) 2026 Joshua Parmenter / realizedsound -// SPDX-License-Identifier: MIT - -#if os(macOS) -import SwiftUI -import LyrebirdSynth -import LyrebirdUI -import LyrebirdShoeGaze -import LyrebirdShoeGazeUI - -/// Root view for the ShoeGaze demo window. -/// -/// Presents a top toolbar with a mode picker, an input-source toggle, and a Start/Stop -/// transport button, followed by a content area that switches between four showcase -/// modes as the user selects them. -/// -/// Because `ShoeGazeDemoController` is `@Observable`, SwiftUI re-renders this view and -/// all its children whenever `controller.mode`, `controller.shoeGaze.boards`, -/// `controller.router`, `controller.parallelSection`, or `controller.isRunning` change — -/// including after a ``ShoeGazeDemoController/rebuild()`` that replaces `shoeGaze`. -/// -/// ## Mode showcases -/// -/// - `.boards` → `ShoeGazeView` — two boards, eight pedals, master gain per board. -/// - `.editor` → `BoardEditorView` — board + FlowLayout pedal area + version snapshots. -/// - `.parallel` → `ParallelSectionView` — splitter, two branch rows, merger (via board). -/// - `.router` → `ChainRouterView` — dual-board chain router with splitter + master. -/// - `.stereo` → `StereoSplitSectionView` — stereo split with the four route modes. -struct DemoRootView: View { - - // MARK: - Layout constants - - private static let toolbarSpacing: CGFloat = 10 - private static let toolbarPadding: CGFloat = 12 - private static let contentPadding: CGFloat = 16 - private static let windowMinWidth: CGFloat = 1_100 - private static let windowMinHeight: CGFloat = 640 - /// Dark stage-floor background (warm almost-black). - private static let backgroundRed: Double = 0.08 - private static let backgroundGreen: Double = 0.07 - private static let backgroundBlue: Double = 0.06 - private static let dividerOpacity: Double = 0.15 - - // MARK: - Properties - - private let controller: ShoeGazeDemoController - private let hardwareSampleRate: () -> Double? - - /// Bumped on each transport press so the buttons re-read `controller.isRunning` - /// (which derives from the non-observable engine). - @State private var transportTick: Bool = false - - // MARK: - Init - - /// Creates the root demo view bound to the given controller. - /// - /// - Parameters: - /// - controller: The `ShoeGazeDemoController` that owns the engine, active `ShoeGaze` - /// session, and current mode. All toolbar actions dispatch through this. - /// - hardwareSampleRate: Returns the actual hardware sample rate (or `nil`), for the engine- - /// config mismatch warning. Defaults to `nil`. - init( - controller: ShoeGazeDemoController, - hardwareSampleRate: @escaping () -> Double? = { nil } - ) { - self.controller = controller - self.hardwareSampleRate = hardwareSampleRate - } - - // MARK: - Body - - var body: some View { - VStack(spacing: 0) { - toolbar - Divider() - .overlay(Color.white.opacity(DemoRootView.dividerOpacity)) - contentArea - .padding(DemoRootView.contentPadding) - Divider() - .overlay(Color.white.opacity(DemoRootView.dividerOpacity)) - ShoeGazeScopeView(shoeGaze: controller.shoeGaze) - .padding(DemoRootView.contentPadding) - } - .frame( - minWidth: DemoRootView.windowMinWidth, - minHeight: DemoRootView.windowMinHeight - ) - .background( - Color( - red: DemoRootView.backgroundRed, - green: DemoRootView.backgroundGreen, - blue: DemoRootView.backgroundBlue - ) - ) - .alert( - "Microphone Access Needed", - isPresented: Binding( - get: { controller.microphoneAccessDenied }, - set: { controller.microphoneAccessDenied = $0 } - ) - ) { - Button("OK", role: .cancel) { } - } message: { - Text("Live input needs microphone access. Enable it in System Settings › Privacy & " - + "Security › Microphone, then select the input again.") - } - } - - // MARK: - Toolbar - - /// Top toolbar: mode picker, input-source picker, transport, and CPU meter. - private var toolbar: some View { - HStack(spacing: DemoRootView.toolbarSpacing) { - modePicker - Spacer() - inputSourcePicker - // In Boards mode the pedalboard view (`ShoeGazeView`) supplies its own - // Start/Stop, so the board starts only when its own button is pressed. The - // other modes have no in-content transport, so show it here for them. - if controller.mode != .boards { - transportButtons - } - } - .padding(DemoRootView.toolbarPadding) - } - - /// Segmented picker for `DemoMode`. - /// - /// The selection binding's setter delegates to `controller.select(_:)` rather than - /// writing a `@State` directly, so the controller handles the mode switch and rebuild. - private var modePicker: some View { - let modeBinding: Binding = Binding( - get: { controller.mode }, - set: { controller.select($0) } - ) - return Picker("Mode", selection: modeBinding) { - ForEach(DemoMode.allCases) { demoMode in - Text(demoMode.title).tag(demoMode) - } - } - .pickerStyle(.segmented) - .frame(maxWidth: 380) - .foregroundStyle(Color.white) - } - - /// A `Binding` mapping the input Picker tag to `InputSource`. - /// - /// Tag `-1` = `.testLoop`; tags `0 ..< numInputChannels` = `.liveInput(channel:)`. - /// Setting the binding calls `controller.setInputSource(_:)`. - private var inputSourceBinding: Binding { - Binding( - get: { - switch controller.inputSource { - case .testLoop: - return -1 - case .liveInput(let channel): - return channel - } - }, - set: { newValue in - if newValue == -1 { - controller.setInputSource(.testLoop) - } else { - controller.setInputSource(.liveInput(channel: newValue)) - } - } - ) - } - - /// Picker listing "Test Loop" and one option per available hardware input channel. - /// - /// When `engine.numInputChannels == 0` only "Test Loop" is shown; the live options - /// are omitted so the picker never offers channels that do not exist. - private var inputSourcePicker: some View { - HStack(spacing: DemoRootView.toolbarSpacing) { - Text("Input:") - .font(.subheadline) - .foregroundStyle(Color.white.opacity(0.65)) - Picker("Input", selection: inputSourceBinding) { - Text("Test Loop").tag(-1) - ForEach(Array(0.. - - - - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - LSApplicationCategoryType - public.app-category.music - LSMinimumSystemVersion - $(MACOSX_DEPLOYMENT_TARGET) - NSHighResolutionCapable - - NSHumanReadableCopyright - Copyright © 2026 realizedsound. All rights reserved. - NSMicrophoneUsageDescription - ShoeGazeDemo can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode. - NSPrincipalClass - NSApplication - - diff --git a/Demo/ShoeGazeDemo/ShoeGazeDemo.entitlements b/Demo/ShoeGazeDemo/ShoeGazeDemo.entitlements deleted file mode 100644 index b572d9c..0000000 --- a/Demo/ShoeGazeDemo/ShoeGazeDemo.entitlements +++ /dev/null @@ -1,8 +0,0 @@ - - - - - com.apple.security.device.audio-input - - - diff --git a/Demo/ShoeGazeDemo/ShoeGazeDemoController.swift b/Demo/ShoeGazeDemo/ShoeGazeDemoController.swift deleted file mode 100644 index c9c5059..0000000 --- a/Demo/ShoeGazeDemo/ShoeGazeDemoController.swift +++ /dev/null @@ -1,371 +0,0 @@ -// ShoeGazeDemoController.swift -// Lyrebird -// -// Copyright (c) 2026 Joshua Parmenter / realizedsound -// SPDX-License-Identifier: MIT - -#if os(macOS) -import Observation -import LyrebirdSynth -import LyrebirdUI -import LyrebirdShoeGaze - -// MARK: - DemoMode - -/// The active showcase mode displayed in the demo window. -/// -/// Each case corresponds to one full-window showcase of a distinct ShoeGaze feature. -/// Switching modes tears down the current audio graph and rebuilds it fresh. -enum DemoMode: String, CaseIterable, Identifiable { - - /// Two full boards, each with four pedals (Board 1: Overdrive → Delay → Reverb → Modulation; - /// Board 2: Fuzz → Tremolo → Phaser → Compressor). - case boards = "Boards" - - /// A single board inside `BoardEditorView` with preset version snapshots pre-populated. - case editor = "Editor" - - /// A single board with a ``ParallelSection`` (Overdrive → split → Delay|Fuzz → merge → Reverb). - case parallel = "Parallel" - - /// A ``ChainRouter`` that splits one input across two independent boards (A: Overdrive + Delay; - /// B: Fuzz + Reverb) and recombines them through a shared master stage. - case router = "Router" - - /// A board with a ``StereoSplitSection`` (Overdrive → splitStereo(Delay | PingPong) → - /// collectStereo) showcasing the four ``StereoRoute`` modes and stereo output. - case stereo = "Stereo" - - var id: String { rawValue } - - /// Short human-readable title used in the mode picker. - var title: String { - switch self { - case .boards: return "Boards" - case .editor: return "Editor" - case .parallel: return "Parallel" - case .router: return "Router" - case .stereo: return "Stereo" - } - } -} - -// MARK: - ShoeGazeDemoController - -/// Main-actor observable controller that owns the engine and active ShoeGaze session. -/// -/// A single `ShoeGaze` instance plus optional `router` / `parallelSection` hold the -/// current showcase. Switching modes via ``select(_:)`` or changing the input source via -/// ``setInputSource(_:)`` calls ``rebuild()`` which: -/// -/// 1. Stops the engine if it is running. -/// 2. Calls `shoeGaze.teardown()` to remove all nodes and release all buses. -/// 3. Replaces `shoeGaze` with a fresh instance. -/// 4. Builds the new mode-specific graph. -/// 5. Restarts the engine if it was running before the rebuild. -/// -/// This guarantees the engine never holds stale references across mode switches. -@MainActor -@Observable -final class ShoeGazeDemoController { - - // MARK: - Public state - - /// The synthesis engine. Callers must not call `engine.start()` or `engine.stop()` - /// directly — use ``start()`` and ``stop()`` so `isRunning` stays consistent. - let engine: SynthesisEngine - - /// The active ShoeGaze session. Replaced on every ``rebuild()`` call. - private(set) var shoeGaze: ShoeGaze - - /// Non-nil only in `.router` mode, after ``buildRouter()`` succeeds. - private(set) var router: ChainRouter? - - /// Non-nil only in `.parallel` mode, after ``buildParallel()`` succeeds. - private(set) var parallelSection: ParallelSection? - - /// Non-nil only in `.stereo` mode, after ``buildStereo()`` succeeds. - private(set) var stereoSection: StereoSplitSection? - - /// Stores named board snapshots for the `.editor` showcase. - let versionStore: BoardVersionStore = BoardVersionStore() - - /// Currently selected showcase mode. - private(set) var mode: DemoMode = .boards - - /// Current input source policy. - private(set) var inputSource: InputSource = .testLoop - - /// `true` while the engine is running. Derived from the engine (the single source - /// of truth) so it stays correct regardless of which control starts/stops it. - var isRunning: Bool { engine.isRunning } - - // MARK: - Init - - /// Creates a controller, builds the default `.boards` showcase, and does NOT start the engine. - /// - /// - Parameter engine: A pre-configured `SynthesisEngine` owned by the caller. The - /// engine must not be running when this initialiser is called. - init(engine: SynthesisEngine) { - self.engine = engine - self.shoeGaze = ShoeGaze(engine: engine, inputSource: .testLoop) - buildBoards() - } - - // MARK: - Mode selection - - /// Switches to the given mode if different from the current one, triggering a full rebuild. - /// - /// - Parameter newMode: The showcase to activate. - func select(_ newMode: DemoMode) { - guard newMode != mode else { return } - mode = newMode - rebuild() - } - - // MARK: - Input source - - /// Changes the input source policy and triggers a full rebuild. - /// - /// Live input requires microphone authorisation first — without it macOS feeds the AUHAL input - /// silent zeros. The request is asynchronous, so `.liveInput` is applied only once the grant - /// resolves; a denial falls back to the test loop. - /// - /// - Parameter source: `.testLoop` for the built-in test signal or `.liveInput(channel:)` - /// for hardware microphone/instrument input on the given channel. - func setInputSource(_ source: InputSource) { - guard case .liveInput = source else { - applyInputSource(source) - return - } - MicrophonePermission.request { [weak self] granted in - if !granted { self?.microphoneAccessDenied = true } - self?.applyInputSource(granted ? source : .testLoop) - } - } - - /// Set when live input is requested but microphone access is denied/restricted. The UI observes - /// this and presents an alert, then clears it. - var microphoneAccessDenied: Bool = false - - /// Applies an input-source change and triggers a full rebuild. - private func applyInputSource(_ source: InputSource) { - inputSource = source - rebuild() - } - - // MARK: - Transport - - /// Starts the engine. Updates ``isRunning`` on success; prints on failure. - func start() { - do { - try engine.start() - } catch { - print("[ShoeGazeDemoController] engine.start() failed: \(error)") - } - } - - /// Stops the engine and updates ``isRunning``. - func stop() { - engine.stop() - } - - /// Toggles audio output on/off (mute). Muting silences output by stopping the engine; - /// unmuting restarts it. `isRunning == false` is the "muted" (silent) state. - func toggleMute() { - if isRunning { - stop() - } else { - start() - } - } - - // MARK: - Engine reconfiguration - - /// Applies new engine settings (while stopped) and rebuilds the current mode so the showcase - /// is reconstructed at the new sample rate / channel counts. Used by the engine-config UI. - /// - /// Tears the session down BEFORE reconfiguring — changing channel counts re-partitions the bus - /// allocator, which would invalidate rig buses still allocated under the old layout. - /// - /// - Throws: `SynthesisEngineConfigError` if the engine is running or a value is invalid. - func reconfigure(sampleRate: Double, inputChannels: Int, outputChannels: Int) throws { - let wasRunning: Bool = isRunning - if wasRunning { stop() } - - tearDownSession() - try engine.setSampleRate(sampleRate) - try engine.setNumOutputChannels(outputChannels) - try engine.setNumInputChannels(inputChannels) - // A live-input source past the new channel count would make rebuild fail; fall back. - if case .liveInput(let channel) = inputSource, channel >= inputChannels { - inputSource = .testLoop - } - buildSession() - // `buildSession()` creates a fresh `ShoeGaze`, whose `init` installs the scope tap for the - // new channel layout — no explicit `installScopeTap()` needed here. - - if wasRunning { start() } - } - - // MARK: - Rebuild - - /// Tears down the current session and rebuilds the active mode. - /// - /// The engine is stopped before teardown and restarted afterward if it was running, - /// satisfying the remove-before-release invariant documented on `ShoeGaze.teardown()`. - private func rebuild() { - let wasRunning: Bool = isRunning - if wasRunning { stop() } - tearDownSession() - buildSession() - if wasRunning { start() } - } - - /// Removes the current session's nodes and clears split/router references. - private func tearDownSession() { - shoeGaze.teardown() - router = nil - parallelSection = nil - stereoSection = nil - } - - /// Creates a fresh session and builds the active mode's graph. - private func buildSession() { - shoeGaze = ShoeGaze(engine: engine, inputSource: inputSource) - switch mode { - case .boards: buildBoards() - case .editor: buildEditor() - case .parallel: buildParallel() - case .router: buildRouter() - case .stereo: buildStereo() - } - } - - // MARK: - Mode builders - - /// `.boards` — three full boards covering all twelve pedal types. - /// - /// Board 1: Overdrive → Delay → Reverb → Modulation - /// Board 2: Fuzz → Tremolo → Phaser → Compressor - /// Board 3: Mutant → Auto-Wah → Feedback Delay → Multi-Tap Delay - private func buildBoards() { - do { - let board1: PedalBoard = try shoeGaze.addBoard() - board1.label = "Board 1" - try board1.add(OverdrivePedal()) - try board1.add(DelayPedal()) - try board1.add(ReverbPedal()) - try board1.add(ModulationPedal()) - try shoeGaze.finalizeBoard(board1) - - let board2: PedalBoard = try shoeGaze.addBoard() - board2.label = "Board 2" - try board2.add(FuzzPedal()) - try board2.add(TremoloPedal()) - try board2.add(PhaserPedal()) - try board2.add(CompressorPedal()) - try shoeGaze.finalizeBoard(board2) - - let board3: PedalBoard = try shoeGaze.addBoard() - board3.label = "Board 3" - try board3.add(MutantPedal()) - try board3.add(AutoWahPedal()) - try board3.add(FeedbackDelayPedal()) - try board3.add(MultiTapDelayPedal()) - try shoeGaze.finalizeBoard(board3) - } catch { - print("[ShoeGazeDemoController] buildBoards failed: \(error)") - } - } - - /// `.editor` — one board inside `BoardEditorView` with two pre-captured versions. - /// - /// The pre-populated version entries ("Crunch" and "Clean Shimmer") ensure the - /// Versions menu is not empty when the showcase first appears. - private func buildEditor() { - do { - let board: PedalBoard = try shoeGaze.addBoard() - board.label = "Editor Board" - try board.add(OverdrivePedal()) - try board.add(FuzzPedal()) - try board.add(DelayPedal()) - try board.add(ReverbPedal()) - try shoeGaze.finalizeBoard(board) - - // Pre-populate two named snapshots so the Versions menu is immediately useful. - versionStore.capture(board, name: "Crunch") - versionStore.capture(board, name: "Clean Shimmer") - } catch { - print("[ShoeGazeDemoController] buildEditor failed: \(error)") - } - } - - /// `.parallel` — Overdrive → split(Delay | Fuzz) → merge → Reverb. - /// - /// Stores the `ParallelSection` in `parallelSection` so `DemoRootView` can display - /// `ParallelSectionView`. - private func buildParallel() { - do { - let board: PedalBoard = try shoeGaze.addBoard() - board.label = "Parallel Board" - try board.add(OverdrivePedal()) - - let section: ParallelSection = try board.split() - try section.branchA.add(DelayPedal()) - try section.branchB.add(FuzzPedal()) - try board.merge(section) - - try board.add(ReverbPedal()) - try shoeGaze.finalizeBoard(board) - - parallelSection = section - } catch { - print("[ShoeGazeDemoController] buildParallel failed: \(error)") - } - } - - /// `.router` — ChainRouter with two independent chains: A (Overdrive + Delay), - /// B (Fuzz + Reverb), merged through a shared master stage. - /// - /// Stores the `ChainRouter` in `router` so `DemoRootView` can display - /// `ChainRouterView`. - private func buildRouter() { - do { - let r: ChainRouter = try shoeGaze.makeChainRouter() - try r.addToA(OverdrivePedal()) - try r.addToA(DelayPedal()) - try r.addToB(FuzzPedal()) - try r.addToB(ReverbPedal()) - try r.finalize() - router = r - } catch { - print("[ShoeGazeDemoController] buildRouter failed: \(error)") - } - } - - /// `.stereo` — Overdrive → splitStereo(left: Delay | right: Ping-Pong) → collectStereo. - /// - /// Demonstrates the stereo split mechanism: a mono signal fanned into two independently - /// authored chains that become the left and right output channels, with the four - /// ``StereoRoute`` modes (stereo / left / right / bypass) selectable live. Stores the - /// `StereoSplitSection` so `DemoRootView` can display `StereoSplitSectionView`. - private func buildStereo() { - do { - let board: PedalBoard = try shoeGaze.addBoard() - board.label = "Stereo Board" - try board.add(OverdrivePedal()) - - let section: StereoSplitSection = try board.splitStereo() - try section.left.add(DelayPedal()) - try section.right.add(PingPongDelayPedal()) - try board.collectStereo(section) - - try shoeGaze.finalizeBoard(board) - stereoSection = section - } catch { - print("[ShoeGazeDemoController] buildStereo failed: \(error)") - } - } -} -#endif diff --git a/Demo/ShoeGazeDemo/main.swift b/Demo/ShoeGazeDemo/main.swift deleted file mode 100644 index e7205d2..0000000 --- a/Demo/ShoeGazeDemo/main.swift +++ /dev/null @@ -1,24 +0,0 @@ -// main.swift -// Lyrebird -// -// Copyright (c) 2026 Joshua Parmenter / realizedsound -// SPDX-License-Identifier: MIT - -#if os(macOS) -import AppKit - -// Program entry runs on the main thread; assert main-actor isolation for the -// AppKit bootstrap rather than hopping asynchronously. `AppDelegate.init` builds -// `@MainActor` synthesizers and UI. -MainActor.assumeIsolated { - let app: NSApplication = NSApplication.shared - let delegate: AppDelegate = AppDelegate() - app.setActivationPolicy(.regular) - app.delegate = delegate - app.activate(ignoringOtherApps: true) - app.run() -} -#else -// The ShoeGaze demo is a macOS AppKit application and has no iOS entry point. -print("ShoeGazeDemo runs on macOS only.") -#endif diff --git a/Demo/ShoeGazeiOSDemo.xcodeproj/project.pbxproj b/Demo/ShoeGazeiOSDemo.xcodeproj/project.pbxproj deleted file mode 100644 index a79c66d..0000000 --- a/Demo/ShoeGazeiOSDemo.xcodeproj/project.pbxproj +++ /dev/null @@ -1,387 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 60; - objects = { - -/* Begin PBXBuildFile section */ - C3C000000000000000000009 /* ShoeGazeiOSDemoApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3C000000000000000000007 /* ShoeGazeiOSDemoApp.swift */; }; - C3C00000000000000000000A /* ShoeGazeiOSDemoAppModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3C000000000000000000008 /* ShoeGazeiOSDemoAppModel.swift */; }; - C3C00000000000000000000B /* LyrebirdShoeGaze in Frameworks */ = {isa = PBXBuildFile; productRef = C3C00000000000000000001A /* LyrebirdShoeGaze */; }; - C3C00000000000000000000C /* LyrebirdShoeGazeUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3C00000000000000000001B /* LyrebirdShoeGazeUI */; }; - C3C00000000000000000000D /* LyrebirdUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3C00000000000000000001C /* LyrebirdUI */; }; - C3C00000000000000000001D /* Lyrebird in Frameworks */ = {isa = PBXBuildFile; productRef = C3C00000000000000000001E /* Lyrebird */; }; - C3C000000000000000000031 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C3C000000000000000000030 /* Assets.xcassets */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - C3C000000000000000000004 /* ShoeGazeiOSDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ShoeGazeiOSDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; - C3C000000000000000000006 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - C3C000000000000000000007 /* ShoeGazeiOSDemoApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoeGazeiOSDemoApp.swift; sourceTree = ""; }; - C3C000000000000000000008 /* ShoeGazeiOSDemoAppModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoeGazeiOSDemoAppModel.swift; sourceTree = ""; }; - C3C000000000000000000030 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - C3C00000000000000000000F /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - C3C00000000000000000000B /* LyrebirdShoeGaze in Frameworks */, - C3C00000000000000000000C /* LyrebirdShoeGazeUI in Frameworks */, - C3C00000000000000000000D /* LyrebirdUI in Frameworks */, - C3C00000000000000000001D /* Lyrebird in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - C3C000000000000000000002 = { - isa = PBXGroup; - children = ( - C3C000000000000000000005 /* ShoeGazeiOSDemo */, - C3C000000000000000000003 /* Products */, - ); - sourceTree = ""; - }; - C3C000000000000000000003 /* Products */ = { - isa = PBXGroup; - children = ( - C3C000000000000000000004 /* ShoeGazeiOSDemo.app */, - ); - name = Products; - sourceTree = ""; - }; - C3C000000000000000000005 /* ShoeGazeiOSDemo */ = { - isa = PBXGroup; - children = ( - C3C000000000000000000007 /* ShoeGazeiOSDemoApp.swift */, - C3C000000000000000000008 /* ShoeGazeiOSDemoAppModel.swift */, - C3C000000000000000000030 /* Assets.xcassets */, - C3C000000000000000000006 /* Info.plist */, - ); - path = ShoeGazeiOSDemo; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - C3C000000000000000000011 /* ShoeGazeiOSDemo */ = { - isa = PBXNativeTarget; - buildConfigurationList = C3C000000000000000000012 /* Build configuration list for PBXNativeTarget "ShoeGazeiOSDemo" */; - buildPhases = ( - C3C00000000000000000000E /* Sources */, - C3C00000000000000000000F /* Frameworks */, - C3C000000000000000000010 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = ShoeGazeiOSDemo; - packageProductDependencies = ( - C3C00000000000000000001A /* LyrebirdShoeGaze */, - C3C00000000000000000001B /* LyrebirdShoeGazeUI */, - C3C00000000000000000001C /* LyrebirdUI */, - C3C00000000000000000001E /* Lyrebird */, - ); - productName = ShoeGazeiOSDemo; - productReference = C3C000000000000000000004 /* ShoeGazeiOSDemo.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - C3C000000000000000000001 /* Project object */ = { - isa = PBXProject; - attributes = { - BuildIndependentTargetsInParallel = 1; - LastSwiftUpdateCheck = 1600; - LastUpgradeCheck = 2620; - TargetAttributes = { - C3C000000000000000000011 = { - CreatedOnToolsVersion = 16.0; - }; - }; - }; - buildConfigurationList = C3C000000000000000000015 /* Build configuration list for PBXProject "ShoeGazeiOSDemo" */; - compatibilityVersion = "Xcode 14.0"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = C3C000000000000000000002; - packageReferences = ( - C3C000000000000000000018 /* XCLocalSwiftPackageReference ".." */, - C3C000000000000000000019 /* XCRemoteSwiftPackageReference "Lyrebird" */, - ); - productRefGroup = C3C000000000000000000003 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - C3C000000000000000000011 /* ShoeGazeiOSDemo */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - C3C000000000000000000010 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - C3C000000000000000000031 /* Assets.xcassets in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - C3C00000000000000000000E /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - C3C000000000000000000009 /* ShoeGazeiOSDemoApp.swift in Sources */, - C3C00000000000000000000A /* ShoeGazeiOSDemoAppModel.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - C3C000000000000000000013 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGNING_REQUIRED = NO; - CODE_SIGN_STYLE = Automatic; - DEBUG_INFORMATION_FORMAT = dwarf; - DEVELOPMENT_TEAM = HE5VJFE9E4; - INFOPLIST_FILE = ShoeGazeiOSDemo/Info.plist; - INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music"; - IPHONEOS_DEPLOYMENT_TARGET = 18.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeiOSDemo; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = iphoneos; - SUPPORTS_MACCATALYST = NO; - SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_VERSION = 6.0; - TARGETED_DEVICE_FAMILY = 2; - }; - name = Debug; - }; - C3C000000000000000000014 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGNING_REQUIRED = NO; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = HE5VJFE9E4; - INFOPLIST_FILE = ShoeGazeiOSDemo/Info.plist; - INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music"; - IPHONEOS_DEPLOYMENT_TARGET = 18.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeiOSDemo; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = iphoneos; - SUPPORTS_MACCATALYST = NO; - SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_VERSION = 6.0; - TARGETED_DEVICE_FAMILY = 2; - }; - name = Release; - }; - C3C000000000000000000016 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - ENABLE_USER_SCRIPT_SANDBOXING = YES; - GCC_C_LANGUAGE_STANDARD = gnu17; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 18.0; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - STRING_CATALOG_GENERATE_SYMBOLS = YES; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - C3C000000000000000000017 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_USER_SCRIPT_SANDBOXING = YES; - GCC_C_LANGUAGE_STANDARD = gnu17; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 18.0; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SDKROOT = iphoneos; - STRING_CATALOG_GENERATE_SYMBOLS = YES; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - C3C000000000000000000012 /* Build configuration list for PBXNativeTarget "ShoeGazeiOSDemo" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C3C000000000000000000013 /* Debug */, - C3C000000000000000000014 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - C3C000000000000000000015 /* Build configuration list for PBXProject "ShoeGazeiOSDemo" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C3C000000000000000000016 /* Debug */, - C3C000000000000000000017 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - -/* Begin XCLocalSwiftPackageReference section */ - C3C000000000000000000018 /* XCLocalSwiftPackageReference ".." */ = { - isa = XCLocalSwiftPackageReference; - relativePath = ..; - }; -/* End XCLocalSwiftPackageReference section */ - -/* Begin XCRemoteSwiftPackageReference section */ - C3C000000000000000000019 /* XCRemoteSwiftPackageReference "Lyrebird" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://realizedsound.mooo.com/josh/Lyrebird"; - requirement = { - kind = upToNextMajorVersion; - minimumVersion = 1.2.0; - }; - }; -/* End XCRemoteSwiftPackageReference section */ - -/* Begin XCSwiftPackageProductDependency section */ - C3C00000000000000000001A /* LyrebirdShoeGaze */ = { - isa = XCSwiftPackageProductDependency; - package = C3C000000000000000000018 /* XCLocalSwiftPackageReference ".." */; - productName = LyrebirdShoeGaze; - }; - C3C00000000000000000001B /* LyrebirdShoeGazeUI */ = { - isa = XCSwiftPackageProductDependency; - package = C3C000000000000000000018 /* XCLocalSwiftPackageReference ".." */; - productName = LyrebirdShoeGazeUI; - }; - C3C00000000000000000001C /* LyrebirdUI */ = { - isa = XCSwiftPackageProductDependency; - package = C3C000000000000000000019 /* XCRemoteSwiftPackageReference "Lyrebird" */; - productName = LyrebirdUI; - }; - C3C00000000000000000001E /* Lyrebird */ = { - isa = XCSwiftPackageProductDependency; - package = C3C000000000000000000019 /* XCRemoteSwiftPackageReference "Lyrebird" */; - productName = Lyrebird; - }; -/* End XCSwiftPackageProductDependency section */ - }; - rootObject = C3C000000000000000000001 /* Project object */; -} diff --git a/Demo/ShoeGazeiOSDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Demo/ShoeGazeiOSDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved deleted file mode 100644 index 82a587c..0000000 --- a/Demo/ShoeGazeiOSDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ /dev/null @@ -1,33 +0,0 @@ -{ - "originHash" : "cfdd71f4b32d744c862bbe26a8265d75aa9e906275b0fb1b63575b7d68be1b6a", - "pins" : [ - { - "identity" : "linenoise-swift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/andybest/linenoise-swift", - "state" : { - "revision" : "afc897c02b030af7333105c4fedcd843a8339238", - "version" : "0.0.3" - } - }, - { - "identity" : "lyrebird", - "kind" : "remoteSourceControl", - "location" : "https://realizedsound.mooo.com/josh/Lyrebird", - "state" : { - "revision" : "032b7c39d351eba4029e8399e1ab1ee201e8bb5c", - "version" : "1.2.0" - } - }, - { - "identity" : "nimble", - "kind" : "remoteSourceControl", - "location" : "https://github.com/Quick/Nimble.git", - "state" : { - "revision" : "e9d769113660769a4d9dd3afb855562c0b7ae7b0", - "version" : "7.3.4" - } - } - ], - "version" : 3 -} diff --git a/Demo/ShoeGazeiOSDemo.xcodeproj/xcshareddata/xcschemes/ShoeGazeiOSDemo.xcscheme b/Demo/ShoeGazeiOSDemo.xcodeproj/xcshareddata/xcschemes/ShoeGazeiOSDemo.xcscheme deleted file mode 100644 index 8d5b689..0000000 --- a/Demo/ShoeGazeiOSDemo.xcodeproj/xcshareddata/xcschemes/ShoeGazeiOSDemo.xcscheme +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Demo/ShoeGazeiOSDemo/Assets.xcassets/AppIcon.appiconset/Contents.json b/Demo/ShoeGazeiOSDemo/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index 584abc1..0000000 --- a/Demo/ShoeGazeiOSDemo/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "images" : [ - {"filename":"icon_1024.png","idiom":"universal","platform":"ios","size":"1024x1024"} - ], - "info" : {"author":"xcode","version":1} -} diff --git a/Demo/ShoeGazeiOSDemo/Assets.xcassets/AppIcon.appiconset/icon_1024.png b/Demo/ShoeGazeiOSDemo/Assets.xcassets/AppIcon.appiconset/icon_1024.png deleted file mode 100644 index b3eb3cf..0000000 Binary files a/Demo/ShoeGazeiOSDemo/Assets.xcassets/AppIcon.appiconset/icon_1024.png and /dev/null differ diff --git a/Demo/ShoeGazeiOSDemo/Assets.xcassets/Contents.json b/Demo/ShoeGazeiOSDemo/Assets.xcassets/Contents.json deleted file mode 100644 index 4359fd8..0000000 --- a/Demo/ShoeGazeiOSDemo/Assets.xcassets/Contents.json +++ /dev/null @@ -1 +0,0 @@ -{ "info" : {"author":"xcode","version":1} } diff --git a/Demo/ShoeGazeiOSDemo/Info.plist b/Demo/ShoeGazeiOSDemo/Info.plist deleted file mode 100644 index 9563314..0000000 --- a/Demo/ShoeGazeiOSDemo/Info.plist +++ /dev/null @@ -1,47 +0,0 @@ - - - - - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - LSRequiresIPhoneOS - - NSHumanReadableCopyright - Copyright © 2026 realizedsound. All rights reserved. - NSMicrophoneUsageDescription - ShoeGazeiOSDemo can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode. - UIApplicationSceneManifest - - UIApplicationSupportsMultipleScenes - - - UILaunchScreen - - UIRequiresFullScreen - - UISupportedInterfaceOrientations - - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - - - diff --git a/Demo/ShoeGazeiOSDemo/ShoeGazeiOSDemoApp.swift b/Demo/ShoeGazeiOSDemo/ShoeGazeiOSDemoApp.swift deleted file mode 100644 index 4954bab..0000000 --- a/Demo/ShoeGazeiOSDemo/ShoeGazeiOSDemoApp.swift +++ /dev/null @@ -1,33 +0,0 @@ -// ShoeGazeiOSDemoApp.swift -// Lyrebird -// -// Copyright (c) 2026 Joshua Parmenter / realizedsound -// SPDX-License-Identifier: MIT - -import SwiftUI -import LyrebirdShoeGazeUI - -/// iOS entry point for the ShoeGaze in-repo demo. -/// -/// Holds the `ShoeGazeiOSDemoAppModel` as `@State` so it is created once and -/// owned for the lifetime of the app. The audio engine is **not** started -/// automatically — the user presses Start in the pedalboard (`ShoeGazeView`) to -/// begin audio. The engine is stopped when the view disappears. -@main -struct ShoeGazeiOSDemoApp: App { - - @State private var model: ShoeGazeiOSDemoAppModel = ShoeGazeiOSDemoAppModel() - - var body: some Scene { - WindowGroup { - NavigationStack { - ScrollView { - ShoeGazeView(shoeGaze: model.shoeGaze, hardwareSampleRate: { model.hardwareSampleRate }) - .padding(.horizontal, 12) - } - .navigationTitle("ShoeGaze") - } - .onDisappear { model.stop() } - } - } -} diff --git a/Demo/ShoeGazeiOSDemo/ShoeGazeiOSDemoAppModel.swift b/Demo/ShoeGazeiOSDemo/ShoeGazeiOSDemoAppModel.swift deleted file mode 100644 index 9473c7d..0000000 --- a/Demo/ShoeGazeiOSDemo/ShoeGazeiOSDemoAppModel.swift +++ /dev/null @@ -1,103 +0,0 @@ -// ShoeGazeiOSDemoAppModel.swift -// Lyrebird -// -// Copyright (c) 2026 Joshua Parmenter / realizedsound -// SPDX-License-Identifier: MIT - -import AVFoundation -import Observation -import LyrebirdSynth -import LyrebirdShoeGaze - -/// Observable model that owns the `SynthesisEngine` and `ShoeGaze` session for -/// the ShoeGaze iOS demo. -/// -/// The engine is not started automatically — the pedalboard's Start button -/// (`ShoeGazeView`) drives `engine.start()`. `stop()` is called from `.onDisappear` -/// to release audio resources when the view goes away. -/// -/// `AVAudioSession` is activated at init so the hardware sample rate is known -/// before the engine is constructed — iOS devices typically lock to 48 000 Hz -/// regardless of the preferred rate, and querying the session after activation -/// avoids pitch and timing errors. -/// -/// The default board (Overdrive → Delay → Reverb → Modulation) uses `.testLoop` -/// as the input source, so no microphone permission is required to run the demo. -/// Switch to `.liveInput(channel: 0)` and set `numInputChannels: 1` in the -/// engine init to route hardware microphone or instrument input through the board. -@Observable -@MainActor -final class ShoeGazeiOSDemoAppModel { - - // MARK: - Engine configuration constants - - private static let blockSize: Int = 512 - private static let outputChannels: Int = 2 - private static let numAudioBuses: Int = 256 - - // MARK: - Owned objects - - /// The active ShoeGaze pedalboard session. - private(set) var shoeGaze: ShoeGaze - - private let engine: SynthesisEngine - private let iosDriver: iOSAudioDriver - - /// The sample rate the audio session actually committed to (for the config mismatch warning). - var hardwareSampleRate: Double? { iosDriver.sessionSampleRate } - - // MARK: - Init - - init() { - // Activate the session before querying `sampleRate` so the hardware rate - // is reported correctly (iOS locks to 48 000 Hz on most devices). - let session: AVAudioSession = AVAudioSession.sharedInstance() - try? session.setCategory(.playAndRecord, - mode: .default, - options: [.defaultToSpeaker, .allowBluetoothHFP]) - try? session.setActive(true) - let sampleRate: Double = session.sampleRate - - let driver: iOSAudioDriver = iOSAudioDriver() - let eng: SynthesisEngine = SynthesisEngine( - blockSize: ShoeGazeiOSDemoAppModel.blockSize, - sampleRate: sampleRate, - numOutputChannels: ShoeGazeiOSDemoAppModel.outputChannels, - numInputChannels: 0, - numAudioBuses: ShoeGazeiOSDemoAppModel.numAudioBuses, - driver: driver - ) - self.iosDriver = driver - self.engine = eng - self.shoeGaze = ShoeGaze(engine: eng) - - do { - let board: PedalBoard = try shoeGaze.addBoard() - board.label = "Demo Board" - try board.add(OverdrivePedal()) - try board.add(DelayPedal()) - try board.add(ReverbPedal()) - try board.add(ModulationPedal()) - try shoeGaze.finalizeBoard(board) - } catch { - print("[ShoeGazeiOSDemo] board build failed: \(error)") - } - } - - // MARK: - Transport - - /// Starts the audio engine. Not called automatically — the pedalboard's Start - /// button drives `engine.start()`; this is here for callers that want to start it. - func start() { - do { - try engine.start() - } catch { - print("[ShoeGazeiOSDemo] engine.start() failed: \(error)") - } - } - - /// Stops the audio engine. Call from `.onDisappear`. - func stop() { - engine.stop() - } -} diff --git a/Package.swift b/Package.swift index 2202fea..c52182e 100644 --- a/Package.swift +++ b/Package.swift @@ -11,8 +11,9 @@ // double-registration. The dynamic-product dance used by `LiveCompile/` is only // required for runtime dylib hot-swap, which ShoeGaze does not do. // -// The demo app lives at Demo/ShoeGazeDemo.xcodeproj — open ShoeGaze.xcworkspace -// in Xcode and run the ShoeGazeDemo scheme to build it. +// The apps live at Demo/ShoeGazeBuilder.xcodeproj (macOS) and +// Demo/ShoeGazeBuilderiOS.xcodeproj (iPad) — open ShoeGaze.xcworkspace in Xcode +// and run the matching scheme to build them. import PackageDescription let package = Package( diff --git a/README.md b/README.md index f25b5b7..775a1cf 100644 --- a/README.md +++ b/README.md @@ -105,12 +105,11 @@ struct ContentView: View { } ``` -## Demo apps +## Apps Open `ShoeGaze.xcworkspace` in Xcode and run a scheme from `Demo/`: - **ShoeGazeBuilder** (macOS) / **ShoeGazeBuilderiOS** (iPad) — the full palette + board builder. -- **ShoeGazeDemo** / **ShoeGazeiOSDemo** — a minimal player view. ## Screenshots diff --git a/ShoeGaze.xcworkspace/contents.xcworkspacedata b/ShoeGaze.xcworkspace/contents.xcworkspacedata index 0770dba..e3e56b2 100644 --- a/ShoeGaze.xcworkspace/contents.xcworkspacedata +++ b/ShoeGaze.xcworkspace/contents.xcworkspacedata @@ -4,12 +4,6 @@ - - - - diff --git a/ShoeGaze.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ShoeGaze.xcworkspace/xcshareddata/swiftpm/Package.resolved index 2f0800b..13422d2 100644 --- a/ShoeGaze.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ShoeGaze.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "91598bde27d299c8e3d95f9dc660396f52cf9b8e78f90ff2652c9d34d869f572", + "originHash" : "39c6a5f1535f779ef8a83b5ea2ab6f965ee3b28ad8419b94679e422a92f75603", "pins" : [ { "identity" : "linenoise-swift", @@ -15,8 +15,8 @@ "kind" : "remoteSourceControl", "location" : "https://realizedsound.mooo.com/josh/Lyrebird", "state" : { - "revision" : "8a2eb191a204a76735ba7eeac94e18f2e65f1b23", - "version" : "1.2.2" + "revision" : "c058493a9853695c441895a12e9f4a5dbc7295b0", + "version" : "1.2.3" } }, { diff --git a/Sources/LyrebirdShoeGaze/Input/InputSource.swift b/Sources/LyrebirdShoeGaze/Input/InputSource.swift index e5feded..76bf94a 100644 --- a/Sources/LyrebirdShoeGaze/Input/InputSource.swift +++ b/Sources/LyrebirdShoeGaze/Input/InputSource.swift @@ -22,6 +22,46 @@ public enum InputSource: Equatable { case liveInput(channel: Int) } +// MARK: - Codable + +/// Persisted so a saved rig round-trips its input selection. Encoded as a `kind` discriminator +/// plus an optional `channel`, so adding future cases stays forward-tolerant. +extension InputSource: Codable { + + private enum Kind: String, Codable { + case testLoop + case liveInput + } + + private enum CodingKeys: String, CodingKey { + case kind + case channel + } + + public init(from decoder: Decoder) throws { + let container: KeyedDecodingContainer = try decoder.container(keyedBy: CodingKeys.self) + let kind: Kind = try container.decode(Kind.self, forKey: .kind) + switch kind { + case .testLoop: + self = .testLoop + case .liveInput: + let channel: Int = try container.decode(Int.self, forKey: .channel) + self = .liveInput(channel: channel) + } + } + + public func encode(to encoder: Encoder) throws { + var container: KeyedEncodingContainer = encoder.container(keyedBy: CodingKeys.self) + switch self { + case .testLoop: + try container.encode(Kind.testLoop, forKey: .kind) + case .liveInput(let channel): + try container.encode(Kind.liveInput, forKey: .kind) + try container.encode(channel, forKey: .channel) + } + } +} + /// Validates a `.liveInput` channel against the engine and returns the engine audio-bus /// index of that hardware input channel. /// diff --git a/Sources/LyrebirdShoeGaze/Presets/RigEntry.swift b/Sources/LyrebirdShoeGaze/Presets/RigEntry.swift index 1c95da8..0940a47 100644 --- a/Sources/LyrebirdShoeGaze/Presets/RigEntry.swift +++ b/Sources/LyrebirdShoeGaze/Presets/RigEntry.swift @@ -43,6 +43,14 @@ public struct RigEntry: Codable, Identifiable, Equatable { /// The full rig snapshot — every board, segment, and pedal parameter. public let state: ShoeGazeState + /// The rig's position in the user's manually-ordered set list, or `nil` for a rig that has + /// not been placed (a legacy entry saved before ordering existed, or one not yet reordered). + /// + /// Persisted per-file and inside archive export/import, so a set-list order travels with a + /// shared or backed-up library. `RigLibraryStore` sorts placed entries by this index and + /// falls back to name/date for unplaced ones. Optional, so older files decode cleanly. + public let sortIndex: Int? + /// Creates a rig library entry. /// /// - Parameters: @@ -51,11 +59,13 @@ public struct RigEntry: Codable, Identifiable, Equatable { /// - savedAt: Save timestamp. Defaults to `Date()` (now). Rounded to the nearest /// whole second so persistence round-trips are lossless. /// - state: The ``ShoeGazeState`` rig snapshot to store. + /// - sortIndex: Manual set-list position, or `nil` when unplaced. Defaults to `nil`. public init( id: UUID = UUID(), name: String, savedAt: Date = Date(), - state: ShoeGazeState + state: ShoeGazeState, + sortIndex: Int? = nil ) { self.id = id self.name = name @@ -64,6 +74,16 @@ public struct RigEntry: Codable, Identifiable, Equatable { // disk round-trip. self.savedAt = Date(timeIntervalSince1970: savedAt.timeIntervalSince1970.rounded()) self.state = state + self.sortIndex = sortIndex + } + + /// Returns a copy of this entry placed at `index` in the set list, keeping its identity, + /// name, timestamp, and state. Used by `RigLibraryStore` reordering. + /// + /// - Parameter index: The new set-list position, or `nil` to unplace. + /// - Returns: A copy at the new `sortIndex`. + public func reordered(to index: Int?) -> RigEntry { + RigEntry(id: id, name: name, savedAt: savedAt, state: state, sortIndex: index) } /// Returns a copy of this entry with a new `name`, a fresh `id`, and `savedAt` updated to @@ -78,7 +98,9 @@ public struct RigEntry: Codable, Identifiable, Equatable { name: String, date: Date = Date() ) -> RigEntry { - RigEntry(id: UUID(), name: name, savedAt: date, state: state) + // A duplicate is unplaced (`sortIndex: nil`) so the store appends it to the set list rather + // than colliding with the source's position. + RigEntry(id: UUID(), name: name, savedAt: date, state: state, sortIndex: nil) } /// Returns a copy of this entry with a new `name` and `savedAt` updated to `date`, keeping @@ -93,6 +115,7 @@ public struct RigEntry: Codable, Identifiable, Equatable { to name: String, date: Date = Date() ) -> RigEntry { - RigEntry(id: id, name: name, savedAt: date, state: state) + // Preserve the set-list position on rename — only the name and timestamp change. + RigEntry(id: id, name: name, savedAt: date, state: state, sortIndex: sortIndex) } } diff --git a/Sources/LyrebirdShoeGaze/Presets/RigLibraryStore.swift b/Sources/LyrebirdShoeGaze/Presets/RigLibraryStore.swift index 8e2268a..35bf9c0 100644 --- a/Sources/LyrebirdShoeGaze/Presets/RigLibraryStore.swift +++ b/Sources/LyrebirdShoeGaze/Presets/RigLibraryStore.swift @@ -176,14 +176,17 @@ public final class RigLibraryStore { /// asynchronously on a background queue and only logs on failure — call /// ``flushPendingWrites()`` to wait for it (e.g. in tests or at app termination). public func save(_ entry: RigEntry) throws { + // Place the entry in the set list first (new rigs append; overwrites keep their position), + // so the persisted file carries a stable `sortIndex`. + let placed: RigEntry = placedForSave(entry) // Encode synchronously (cheap, CPU) so an encoding failure is surfaced to the caller; then // update the in-memory list immediately and push the disk write to the background queue. - let data: Data = try encode(entry) - let target: URL = fileURL(for: entry) + let data: Data = try encode(placed) + let target: URL = fileURL(for: placed) let directory: URL = self.directory - let id: UUID = entry.id + let id: UUID = placed.id let coordinated: Bool = isICloud - upsert(entry) + upsert(placed) ioQueue.async { // Remove any prior file for this id first (a rename changes the name-prefixed filename). if let stale: URL = RigLibraryStore.existingFileURL(for: id, in: directory), @@ -198,6 +201,87 @@ public final class RigLibraryStore { } } + // MARK: - Reordering + + /// Moves entries within the set list (SwiftUI `onMove` semantics), renumbers every entry's + /// `sortIndex` to its new dense position, and persists the changed files. + /// + /// - Parameters: + /// - source: The indices being moved, into the current `entries` order. + /// - destination: The insertion offset, per SwiftUI `List.onMove`. + public func move(fromOffsets source: IndexSet, toOffset destination: Int) { + var ordered: [RigEntry] = entries + ordered.move(fromOffsets: source, toOffset: destination) + renumberAndPersist(ordered) + } + + /// Moves `entry` one slot earlier in the set list. No-op if it is already first or absent. + public func moveUp(_ entry: RigEntry) { + guard let index: Int = entries.firstIndex(where: { $0.id == entry.id }), index > 0 else { return } + var ordered: [RigEntry] = entries + ordered.swapAt(index, index - 1) + renumberAndPersist(ordered) + } + + /// Moves `entry` one slot later in the set list. No-op if it is already last or absent. + public func moveDown(_ entry: RigEntry) { + guard let index: Int = entries.firstIndex(where: { $0.id == entry.id }), + index < entries.count - 1 else { return } + var ordered: [RigEntry] = entries + ordered.swapAt(index, index + 1) + renumberAndPersist(ordered) + } + + /// Reorders the set list to match `orderedIDs`, renumbers every entry, and persists the changes. + /// Any entry not named in `orderedIDs` is appended in its current relative order (a safety net; + /// drag reorder always passes the full id list). Used by the sidebar's drag-to-reorder. + /// + /// - Parameter orderedIDs: The desired full ordering, by entry id. + public func applyOrder(_ orderedIDs: [UUID]) { + let byID: [UUID: RigEntry] = Dictionary(entries.map { ($0.id, $0) }, uniquingKeysWith: { first, _ in first }) + var ordered: [RigEntry] = orderedIDs.compactMap { byID[$0] } + for entry: RigEntry in entries where !orderedIDs.contains(entry.id) { + ordered.append(entry) + } + renumberAndPersist(ordered) + } + + /// Renumbers `ordered` so each entry's `sortIndex` equals its position, updates the in-memory + /// list, and writes only the files whose index actually changed. + private func renumberAndPersist(_ ordered: [RigEntry]) { + var renumbered: [RigEntry] = [] + var changed: [RigEntry] = [] + for (position, entry) in ordered.enumerated() { + if entry.sortIndex == position { + renumbered.append(entry) + } else { + let moved: RigEntry = entry.reordered(to: position) + renumbered.append(moved) + changed.append(moved) + } + } + entries = RigLibraryStore.sorted(renumbered) + for entry: RigEntry in changed { persistToDisk(entry) } + } + + /// Writes `entry`'s JSON file on the background queue without touching the in-memory list or + /// re-sorting — the reorder path already updated `entries` in one shot. + private func persistToDisk(_ entry: RigEntry) { + guard let data: Data = try? encode(entry) else { return } + let target: URL = fileURL(for: entry) + let directory: URL = self.directory + let id: UUID = entry.id + let coordinated: Bool = isICloud + ioQueue.async { + if let stale: URL = RigLibraryStore.existingFileURL(for: id, in: directory), + stale.standardizedFileURL != target.standardizedFileURL { + try? RigLibraryStore.removeFile(at: stale, coordinated: coordinated) + } + do { try RigLibraryStore.writeData(data, to: target, coordinated: coordinated) } + catch { print("[RigLibraryStore] reorder write failed: \(error)") } + } + } + /// Deletes `entry` from memory immediately and removes its file on the background queue. /// /// - Parameter entry: The rig entry to remove. @@ -328,10 +412,13 @@ public final class RigLibraryStore { let existingIDs: Set = Set(entries.map(\.id)) var added: Int = 0 for entry: RigEntry in imported { - // Avoid clobbering an existing rig that happens to share this id. + // Avoid clobbering an existing rig that happens to share this id. Either way, clear the + // set-list position so the import appends after the existing entries (in archive order) + // rather than colliding with their indices — `duplicated` already unplaces; a + // non-colliding entry is explicitly unplaced via `reordered(to: nil)`. let toSave: RigEntry = existingIDs.contains(entry.id) ? entry.duplicated(name: entry.name, date: entry.savedAt) - : entry + : entry.reordered(to: nil) try save(toSave) added += 1 } @@ -549,14 +636,31 @@ public final class RigLibraryStore { entries = RigLibraryStore.sorted(next) } - /// Sorts entries by name (case-insensitive), then most-recently-saved first, then id for a - /// fully deterministic order. + /// Sorts entries by manual set-list position first (placed entries, ascending), then — for + /// unplaced entries or ties — by name (case-insensitive), most-recently-saved first, and id, + /// for a fully deterministic order. private static func sorted(_ entries: [RigEntry]) -> [RigEntry] { entries.sorted { lhs, rhs in + let lhsIndex: Int = lhs.sortIndex ?? Int.max + let rhsIndex: Int = rhs.sortIndex ?? Int.max + if lhsIndex != rhsIndex { return lhsIndex < rhsIndex } let byName: ComparisonResult = lhs.name.localizedCaseInsensitiveCompare(rhs.name) if byName != .orderedSame { return byName == .orderedAscending } if lhs.savedAt != rhs.savedAt { return lhs.savedAt > rhs.savedAt } return lhs.id.uuidString < rhs.id.uuidString } } + + /// Assigns a set-list position to an entry about to be saved so every stored rig is placed: + /// an explicit index is kept as-is; overwriting an existing rig with an unplaced snapshot + /// preserves that rig's current position; a brand-new unplaced rig appends after the last one. + private func placedForSave(_ entry: RigEntry) -> RigEntry { + if entry.sortIndex != nil { return entry } + if let existing: RigEntry = entries.first(where: { $0.id == entry.id }), + let existingIndex: Int = existing.sortIndex { + return entry.reordered(to: existingIndex) + } + let nextIndex: Int = (entries.compactMap { $0.sortIndex }.max() ?? -1) + 1 + return entry.reordered(to: nextIndex) + } } diff --git a/Sources/LyrebirdShoeGaze/Presets/ShoeGaze+Engine.swift b/Sources/LyrebirdShoeGaze/Presets/ShoeGaze+Engine.swift index 3088a8f..e2b0bdb 100644 --- a/Sources/LyrebirdShoeGaze/Presets/ShoeGaze+Engine.swift +++ b/Sources/LyrebirdShoeGaze/Presets/ShoeGaze+Engine.swift @@ -60,6 +60,35 @@ extension ShoeGaze { try rebuildAllBoards(from: snapshot) } + /// Applies a rig snapshot's saved hardware channel layout (``ShoeGazeState/numInputChannels`` / + /// ``ShoeGazeState/numOutputChannels``) to the engine — a **deliberate opt-in**. + /// + /// ``loadRig(from:)`` persists a rig's I/O but does not auto-apply it: forcing the engine's + /// channel layout on every load would override the user's global engine config and clobber the + /// enable-live-input flow. Call this explicitly (e.g. from the engine-config UI, or a "match rig + /// I/O" action) when you do want the rig's saved layout. Reuses ``reconfigureEngine(...)`` — so + /// it captures the current rig and rebuilds every board at the new layout. + /// + /// A no-op (returns `false`) when the snapshot carries no saved counts or they already match. + /// + /// - Parameter state: The rig snapshot whose channel layout should be applied. + /// - Returns: `true` if the engine was reconfigured, `false` if nothing needed to change. + /// - Throws: `SynthesisEngineConfigError.engineIsRunning` if the engine is running, or any error + /// from ``reconfigureEngine(sampleRate:inputChannels:outputChannels:)``. + @discardableResult + public func applyChannelLayout(from state: ShoeGazeState) throws -> Bool { + guard !engine.isRunning else { throw SynthesisEngineConfigError.engineIsRunning } + guard let inCount: Int = state.numInputChannels, + let outCount: Int = state.numOutputChannels else { return false } + guard inCount != engine.numInputChannels || outCount != engine.numOutputChannels else { return false } + try reconfigureEngine( + sampleRate: engine.sampleRate, + inputChannels: inCount, + outputChannels: outCount + ) + return true + } + /// Default samples-per-frame captured by the scope tap. public static let defaultScopeBufferSize: Int = 2_048 diff --git a/Sources/LyrebirdShoeGaze/Presets/ShoeGaze+Preset.swift b/Sources/LyrebirdShoeGaze/Presets/ShoeGaze+Preset.swift index 22b3038..f3f3518 100644 --- a/Sources/LyrebirdShoeGaze/Presets/ShoeGaze+Preset.swift +++ b/Sources/LyrebirdShoeGaze/Presets/ShoeGaze+Preset.swift @@ -18,7 +18,15 @@ extension ShoeGaze { /// - Returns: A `ShoeGazeState` reflecting the current rig. public func captureState() -> ShoeGazeState { let boardStates: [BoardState] = boards.map { $0.captureState() } - return ShoeGazeState(boards: boardStates, midiMap: midiMap) + return ShoeGazeState( + boards: boardStates, + midiMap: midiMap, + bpm: clock.bpm, + tempoEnabled: tempoEnabled, + inputSource: inputSource, + numInputChannels: engine.numInputChannels, + numOutputChannels: engine.numOutputChannels + ) } /// Captures the current rig as a named ``RigEntry`` suitable for the rig library. @@ -93,11 +101,39 @@ extension ShoeGaze { throw PresetError.unsupportedVersion(state.version) } + // Note: `state.numInputChannels` / `numOutputChannels` are persisted with the rig (see + // `captureState`) but intentionally NOT auto-applied here. Forcing the engine's channel + // layout on every load would fight the global engine config and clobber the iOS + // enable-live-input flow (rebuild engine to 1 input, then load a rig saved with 0). Apply a + // rig's saved layout deliberately via `applyChannelLayout(from:)` / the config UI instead. + + // Restore the saved input source before rebuilding, since board construction reads it. A + // saved live-input channel that no longer exists on this engine falls back to the test loop + // (same guard as reconfigureEngine), so the rebuild's addBoard() can't throw on a stale + // channel. Absent (older rig) → leave the current input source untouched. + if let savedInput: InputSource = state.inputSource { + if case .liveInput(let channel) = savedInput, + channel < 0 || channel >= engine.numInputChannels { + inputSource = .testLoop + } else { + inputSource = savedInput + } + } + teardown() try rebuildAllBoards(from: state) // Restore the rig's MIDI bindings after the boards exist, so a MIDIController re-reading the // map resolves against the freshly rebuilt boards. midiMap = state.midiMap + + // Tempo restore is graph-independent, so it happens after the rebuild. Absent (older rig) → + // leave the current session tempo untouched. + if let savedBpm: Double = state.bpm { + clock.bpm = savedBpm + } + if let savedTempoEnabled: Bool = state.tempoEnabled { + setTempoEnabled(savedTempoEnabled) + } } /// Rebuilds every board from a snapshot with all-or-nothing semantics. diff --git a/Sources/LyrebirdShoeGaze/Presets/ShoeGazeState.swift b/Sources/LyrebirdShoeGaze/Presets/ShoeGazeState.swift index 5d54635..0143480 100644 --- a/Sources/LyrebirdShoeGaze/Presets/ShoeGazeState.swift +++ b/Sources/LyrebirdShoeGaze/Presets/ShoeGazeState.swift @@ -34,26 +34,69 @@ public struct ShoeGazeState: Codable, Equatable { /// version bump is required for this additive field. public let midiMap: MIDIMap? + /// The rig's tempo in BPM at save time, or `nil` for a rig saved before tempo persistence. + /// Restored onto the shared clock on load; `nil` leaves the current session tempo untouched. + public let bpm: Double? + + /// Whether the tempo indicator and tempo-synced features were enabled at save time, or `nil` + /// for a rig saved before tempo persistence. + public let tempoEnabled: Bool? + + /// How the board head bus was fed at save time (test loop or a live-input channel), or `nil` + /// for a rig saved before input persistence. A saved live-input channel that no longer exists + /// on the loading engine falls back to the test loop. + public let inputSource: InputSource? + + /// The engine's hardware input-channel count at save time, or `nil` for a rig saved before I/O + /// persistence. Reapplied on load (when the engine is stopped and the count differs), so a rig + /// can restore its channel layout. Hardware that can't supply the count is negotiated at + /// `engine.start()`, exactly as with a manual reconfigure. + public let numInputChannels: Int? + + /// The engine's hardware output-channel count at save time, or `nil` for a rig saved before I/O + /// persistence. Reapplied on load under the same conditions as ``numInputChannels``. + public let numOutputChannels: Int? + /// Creates a rig state snapshot. /// /// - Parameters: /// - version: Preset format version. Defaults to `presetFormatVersion`. /// - boards: Ordered list of board state snapshots. /// - midiMap: The rig's MIDI bindings, or `nil` when there are none. Defaults to `nil`. + /// - bpm: The rig's tempo in BPM, or `nil` to not persist a tempo. Defaults to `nil`. + /// - tempoEnabled: Whether tempo features were enabled, or `nil`. Defaults to `nil`. + /// - inputSource: The rig's input selection, or `nil` to not persist one. Defaults to `nil`. + /// - numInputChannels: The engine input-channel count, or `nil`. Defaults to `nil`. + /// - numOutputChannels: The engine output-channel count, or `nil`. Defaults to `nil`. public init( version: Int = presetFormatVersion, boards: [BoardState], - midiMap: MIDIMap? = nil + midiMap: MIDIMap? = nil, + bpm: Double? = nil, + tempoEnabled: Bool? = nil, + inputSource: InputSource? = nil, + numInputChannels: Int? = nil, + numOutputChannels: Int? = nil ) { self.version = version self.boards = boards self.midiMap = midiMap + self.bpm = bpm + self.tempoEnabled = tempoEnabled + self.inputSource = inputSource + self.numInputChannels = numInputChannels + self.numOutputChannels = numOutputChannels } private enum CodingKeys: String, CodingKey { case version case boards case midiMap + case bpm + case tempoEnabled + case inputSource + case numInputChannels + case numOutputChannels } /// Decodes a rig snapshot, tolerating an absent, malformed, OR legacy-format `midiMap`. @@ -79,5 +122,12 @@ public struct ShoeGazeState: Codable, Equatable { } else { self.midiMap = nil } + + // Additive tempo + input + I/O fields: absent in older rigs, so decode leniently to `nil`. + self.bpm = try container.decodeIfPresent(Double.self, forKey: .bpm) + self.tempoEnabled = try container.decodeIfPresent(Bool.self, forKey: .tempoEnabled) + self.inputSource = try container.decodeIfPresent(InputSource.self, forKey: .inputSource) + self.numInputChannels = try container.decodeIfPresent(Int.self, forKey: .numInputChannels) + self.numOutputChannels = try container.decodeIfPresent(Int.self, forKey: .numOutputChannels) } } diff --git a/Sources/LyrebirdShoeGazeUI/HelpView.swift b/Sources/LyrebirdShoeGazeUI/HelpView.swift index 58a5f0a..19d0342 100644 --- a/Sources/LyrebirdShoeGazeUI/HelpView.swift +++ b/Sources/LyrebirdShoeGazeUI/HelpView.swift @@ -43,6 +43,23 @@ public struct HelpView: View { "Bypass Rig compares your sound with and without the whole pedalboard.", ] ) + topicSection( + icon: "keyboard", + title: "Keyboard Shortcuts", + intro: "With a hardware keyboard, these speed up live use.", + steps: [ + "⌘1–⌘9 switch to (and solo) boards 1–9 — the fastest way to change board live.", + "⌘⇧1–⌘⇧9 and ⌘⇧0 load set-list rigs 1–10 in the order shown in the Rigs list — " + + "build a set list by reordering rigs, then step through them hands-free.", + "⌘Z mutes and unmutes the whole rig — a hard silence of all output (distinct " + + "from Bypass Rig, which passes your dry signal through).", + "On macOS the menu bar adds: ⌘N New Rig, ⌘S Save Rig, ⌘E Export Archive, " + + "⌘I Import Archive, ⌘B Add Board, ⇧⌘R Start / Stop Recording, ⌘? Help, and " + + "Rigs ▸ Set List (the ⌘⇧ rig slots).", + "The board and set-list shortcuts and ⌘Z also work on iOS / iPadOS with a " + + "hardware keyboard attached.", + ] + ) topicSection( icon: "waveform", title: "Choosing an Input", @@ -64,6 +81,9 @@ public struct HelpView: View { + "crossfade time; each board has S (solo) and B (bypass).", "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 / " + + "Move Down menu. The order is saved and travels with an exported archive; " + + "the top ten map to ⌘⇧1–⌘⇧0.", ] ) topicSection( diff --git a/Sources/LyrebirdShoeGazeUI/RigLibraryCommands.swift b/Sources/LyrebirdShoeGazeUI/RigLibraryCommands.swift index a8a7c7a..f025277 100644 --- a/Sources/LyrebirdShoeGazeUI/RigLibraryCommands.swift +++ b/Sources/LyrebirdShoeGazeUI/RigLibraryCommands.swift @@ -16,4 +16,8 @@ public extension Notification.Name { /// Create a new, named, empty rig and make it current. static let shoeGazeNewRig: Notification.Name = Notification.Name("net.realizedsound.shoegaze.newRig") + + /// Load the set-list rig at a zero-based slot index (0…9, mapped to ⌘⇧1…⌘⇧0 on macOS). The + /// slot index is posted as the notification's `object` (an `NSNumber`/`Int`). + static let shoeGazeLoadRigSlot: Notification.Name = Notification.Name("net.realizedsound.shoegaze.loadRigSlot") } diff --git a/Sources/LyrebirdShoeGazeUI/RigLibrarySidebarView.swift b/Sources/LyrebirdShoeGazeUI/RigLibrarySidebarView.swift index 916ae61..653f2af 100644 --- a/Sources/LyrebirdShoeGazeUI/RigLibrarySidebarView.swift +++ b/Sources/LyrebirdShoeGazeUI/RigLibrarySidebarView.swift @@ -149,7 +149,20 @@ struct RigLibrarySidebarView: View { .contentShape(Rectangle()) } .buttonStyle(.plain) + // Drag the row onto another to reorder; dropping inserts it just before the target. Works + // on macOS (mouse drag) and iPad (long-press drag); taps still select. + .draggable(entry.id.uuidString) + .dropDestination(for: String.self) { droppedIDs, _ in + guard let first: String = droppedIDs.first else { return false } + moveDragged(first, onto: entry) + return true + } .contextMenu { + Button("Move Up") { store.moveUp(entry) } + .disabled(isFirst(entry)) + Button("Move Down") { store.moveDown(entry) } + .disabled(isLast(entry)) + Divider() Button("Rename…") { onRename(entry) } Button("Duplicate…") { onDuplicate(entry) } // Encoding a fully-concrete RigEntry to JSON does not fail in practice; on the @@ -167,6 +180,28 @@ struct RigLibrarySidebarView: View { } } + // MARK: - Reorder helpers + + private func isFirst(_ entry: RigEntry) -> Bool { + store.entries.first?.id == entry.id + } + + private func isLast(_ entry: RigEntry) -> Bool { + store.entries.last?.id == entry.id + } + + /// Moves the dragged entry (by id string) to sit just before `target` in the set list. + private func moveDragged(_ draggedIDString: String, onto target: RigEntry) { + guard let draggedID: UUID = UUID(uuidString: draggedIDString), draggedID != target.id else { return } + var order: [UUID] = store.entries.map(\.id) + guard let from: Int = order.firstIndex(of: draggedID) else { return } + order.remove(at: from) + // Target's index in the post-removal array; inserting there drops the dragged row before it. + guard let to: Int = order.firstIndex(of: target.id) else { return } + order.insert(draggedID, at: to) + store.applyOrder(order) + } + // MARK: - Action bar private var actionBar: some View { diff --git a/Sources/LyrebirdShoeGazeUI/ShoeGazeBuilderView.swift b/Sources/LyrebirdShoeGazeUI/ShoeGazeBuilderView.swift index e0f20bf..1cb2677 100644 --- a/Sources/LyrebirdShoeGazeUI/ShoeGazeBuilderView.swift +++ b/Sources/LyrebirdShoeGazeUI/ShoeGazeBuilderView.swift @@ -65,6 +65,9 @@ public struct ShoeGazeBuilderView: View { private static let maxCrossfadeSeconds: Double = 10.0 /// Highest board reachable via a ⌘-number switch shortcut. private static let maxBoardShortcuts: Int = 9 + + /// The number of set-list rigs reachable by ⌘⇧1…⌘⇧0 (the top ten). + private static let maxRigShortcuts: Int = 10 /// Default filename offered when exporting the whole library as an archive. private static let defaultArchiveFileName: String = "ShoeGaze Library" /// Extra width reserved for the rig-library sidebar on top of the builder's minimum width. @@ -311,6 +314,11 @@ public struct ShoeGazeBuilderView: View { .onReceive(NotificationCenter.default.publisher(for: .shoeGazeNewRig)) { _ in promptNewRig() } + .onReceive(NotificationCenter.default.publisher(for: .shoeGazeLoadRigSlot)) { note in + if let index: Int = note.object as? Int { + loadRigSlot(index) + } + } .confirmationDialog( "Clear all boards?", isPresented: $showClearDialog, @@ -578,14 +586,7 @@ public struct ShoeGazeBuilderView: View { ScrollView(.horizontal, showsIndicators: false) { HStack(spacing: ShoeGazeBuilderView.rowSpacing) { rigBypassButton - // fixedSize stops the switch Toggle from expanding to fill the row (which pushed - // the following controls far to the right, under the scope). - Toggle("Mute rig", isOn: Binding( - get: { shoeGaze.tunerMutesRig }, - set: { shoeGaze.tunerMutesRig = $0 } - )) - .toggleStyle(.switch) - .fixedSize() + rigMuteButton helpButton if let midi: MIDIController = midi { MIDIIndicatorView(controller: midi) { showMIDISheet = true } @@ -942,6 +943,7 @@ public struct ShoeGazeBuilderView: View { } helpButton rigBypassButton + rigMuteButton EngineConfigView( shoeGaze: shoeGaze, hardwareSampleRate: hardwareSampleRate, @@ -951,12 +953,13 @@ public struct ShoeGazeBuilderView: View { .frame(height: TempoView.enabledHeight) HStack(spacing: ShoeGazeBuilderView.rowSpacing) { - // Mute-rig-while-tuning toggle sits to the left of the input selector. - Toggle("Mute rig", isOn: Binding( + // Whether engaging the tuner silences the rig; sits left of the input selector. + Toggle("Mute while tuning", isOn: Binding( get: { shoeGaze.tunerMutesRig }, set: { shoeGaze.tunerMutesRig = $0 } )) .toggleStyle(.switch) + .fixedSize() Text("Input:") .font(.subheadline) @@ -1010,6 +1013,22 @@ public struct ShoeGazeBuilderView: View { .help("Bypass the entire rig — every board passes your dry input straight through") } + /// Global rig mute — a hard gate to silence the whole output (distinct from Bypass, which + /// passes the dry signal through). Lit when engaged. A live performance panic/silence control. + private var rigMuteButton: some View { + let muted: Bool = shoeGaze.rigMuted + return Button { + shoeGaze.toggleRigMuted() + } label: { + Label(muted ? "Rig Muted" : "Mute Rig", + systemImage: muted ? "speaker.slash.fill" : "speaker.wave.2.fill") + .font(.subheadline) + } + .buttonStyle(.bordered) + .tint(muted ? .red : .gray) + .help("Mute the entire rig output — silences all sound") + } + // MARK: - Board area private var boardArea: some View { @@ -1213,19 +1232,40 @@ public struct ShoeGazeBuilderView: View { // MARK: - Board-switch shortcuts /// Hidden ⌘1…⌘9 buttons that solo (live-switch to) the matching board and select it as the - /// edit target. Kept at zero opacity so the shortcuts stay active without showing chrome. + /// edit target, plus ⌘M to toggle the rig mute. Kept at zero opacity so the shortcuts stay + /// active without showing chrome. private var boardSwitchShortcuts: some View { ZStack { ForEach(0 ..< min(ShoeGazeBuilderView.maxBoardShortcuts, shoeGaze.boards.count), id: \.self) { index in - Button("") { switchToBoard(index) } + // Titles are invisible (the ZStack is opacity 0) but feed the iPadOS ⌘-hold + // discoverability HUD, so the shortcut reads as a named command there. + Button("Switch to Board \(index + 1)") { switchToBoard(index) } .keyboardShortcut(KeyEquivalent(Character("\(index + 1)")), modifiers: .command) } + // ⌘Z toggles rig mute on iOS/iPadOS hardware keyboards. On macOS the Board menu item + // owns the ⌘Z equivalent, so it is not also bound here (a double-bound event is ambiguous). + #if !os(macOS) + Button("Mute / Unmute Rig") { shoeGaze.toggleRigMuted() } + .keyboardShortcut("z", modifiers: .command) + // ⌘⇧1…⌘⇧9 + ⌘⇧0 load set-list rigs 1…10. macOS binds these via the Rigs ▸ Set List menu + // instead, so they are not also bound here. + ForEach(0 ..< ShoeGazeBuilderView.maxRigShortcuts, id: \.self) { slot in + Button("Load Set List Rig \(slot + 1)") { loadRigSlot(slot) } + .keyboardShortcut(ShoeGazeBuilderView.rigSlotKey(slot), modifiers: [.command, .shift]) + } + #endif } .opacity(0) .frame(width: 0, height: 0) .accessibilityHidden(true) } + /// The key equivalent for set-list slot `slot` (0-based): slots 0…8 map to `1`…`9`, slot 9 to + /// `0` — matching the ⌘⇧1…⌘⇧0 physical row. + private static func rigSlotKey(_ slot: Int) -> KeyEquivalent { + KeyEquivalent(Character(slot < 9 ? "\(slot + 1)" : "0")) + } + /// Solos board `index` (a live amp-channel-style switch) and makes it the edit target. private func switchToBoard(_ index: Int) { guard index < shoeGaze.boards.count else { return } @@ -1315,6 +1355,16 @@ public struct ShoeGazeBuilderView: View { transportTick.toggle() } + /// Loads the set-list rig at zero-based `index` (the library's manual order), if one exists. + /// Backs the ⌘⇧1…⌘⇧0 shortcuts and the macOS Rigs ▸ Set List menu. Routes through + /// ``requestLoad(_:)`` so the unsaved-changes prompt and no-op-if-current behaviour apply. + /// + /// - Parameter index: Zero-based slot index (0…9). + private func loadRigSlot(_ index: Int) { + guard index >= 0, index < library.entries.count else { return } + requestLoad(library.entries[index]) + } + /// Switches to `entry`, prompting to save first when the current rig has unsaved changes. /// No-op when `entry` is already the current rig. private func requestLoad(_ entry: RigEntry) { diff --git a/Sources/LyrebirdShoeGazeUI/TempoView.swift b/Sources/LyrebirdShoeGazeUI/TempoView.swift index e216f09..22b5c08 100644 --- a/Sources/LyrebirdShoeGazeUI/TempoView.swift +++ b/Sources/LyrebirdShoeGazeUI/TempoView.swift @@ -19,13 +19,32 @@ public struct TempoView: View { // MARK: - Constants private static let pollIntervalNanoseconds: UInt64 = 33_333_333 // ~30 Hz - /// Fraction of each beat the LED stays lit — a short flash, not a 50% duty-cycle blink. - private static let flashDutyCycle: Double = 0.15 private static let minBpm: Double = 30.0 private static let maxBpm: Double = 300.0 private static let bpmStep: Double = 1.0 - private static let ledDiameter: CGFloat = 14 private static let rowSpacing: CGFloat = 10 + + // Metronome track: a dot swings wall-to-wall once per beat, pausing at each wall (the beat) + // so the eye can anticipate the hit. Pendulum easing comes for free from the cosine map. + private static let trackWidth: CGFloat = 150 + private static let trackHeight: CGFloat = 16 + private static let trackCornerRadius: CGFloat = 4 + private static let trackBrightness: Double = 0.14 + private static let trackBorderOpacity: Double = 0.35 + private static let trackBorderWidth: CGFloat = 1 + /// Vertical playhead sweeping horizontally across the track (Looper-style), full track height. + private static let lineWidth: CGFloat = 3 + /// Playhead opacity floor at mid-swing; ramps to full at the walls so it fades as it travels + /// toward center and re-brightens into each beat. + private static let lineMinOpacity: Double = 0.25 + /// Curve on the wall-proximity → brightness map; > 1 dims harder through the middle. + private static let brightnessFadeCurve: Double = 1.6 + /// Soft glow drawn behind the playhead; its opacity peaks at the turnaround (on the beat). + private static let glowWidth: CGFloat = 16 + private static let glowMaxOpacity: Double = 0.7 + /// End-wall tick marks sit on the beat positions. + private static let wallTickWidth: CGFloat = 2 + private static let wallTickOpacity: Double = 0.4 /// Fixed row height = the enabled (BPM/TAP-visible) height, so toggling doesn't shift layout. static let enabledHeight: CGFloat = 34 @@ -34,7 +53,8 @@ public struct TempoView: View { private let shoeGaze: ShoeGaze @State private var displayedBpm: Double - @State private var ledOn: Bool = false + /// Continuous beat position, polled from the clock; drives the metronome dot. + @State private var beat: Double = 0.0 // MARK: - Init @@ -57,7 +77,7 @@ public struct TempoView: View { .help("Show the tempo indicator and enable tempo-synced controls") if shoeGaze.tempoEnabled { - led + metronome Text("\(Int(displayedBpm.rounded())) BPM") .font(.system(size: 18, weight: .semibold, design: .rounded)) .foregroundStyle(Color.white) @@ -84,9 +104,7 @@ public struct TempoView: View { .frame(height: TempoView.enabledHeight) .task(id: shoeGaze.tempoEnabled) { while shoeGaze.tempoEnabled && !Task.isCancelled { - let beat: Double = shoeGaze.clock.currentBeat - let phase: Double = beat - beat.rounded(.down) - ledOn = phase < TempoView.flashDutyCycle + beat = shoeGaze.clock.currentBeat displayedBpm = shoeGaze.clock.bpm try? await Task.sleep(nanoseconds: TempoView.pollIntervalNanoseconds) } @@ -95,10 +113,62 @@ public struct TempoView: View { // MARK: - Subviews - private var led: some View { - Circle() - .fill(ledOn ? Color.red : Color.red.opacity(0.15)) - .frame(width: TempoView.ledDiameter, height: TempoView.ledDiameter) + /// Horizontal pendulum: the dot maps `beat` through a cosine so it eases to a stop at each + /// wall (an integer beat) and moves fastest at mid-swing — the wall pauses give the eye a + /// runway to anticipate the beat. `x01 = (1 − cos(π·swing)) / 2`, `swing = beat mod 2`, puts + /// the left wall on even beats and the right wall on odd beats (one wall hit per beat). + private var metronome: some View { + // Reduce beat mod 2 before the cosine so precision holds over a long session. + let swing: Double = beat.truncatingRemainder(dividingBy: 2) + let x01: Double = (1 - cos(.pi * swing)) / 2 + // Proximity to a wall in [0, 1]: 1 at a wall (on the beat), 0 at mid-swing. The curve dims + // harder through the middle so the playhead visibly fades as it travels toward center. + let wallGlow: Double = pow(1 - 2 * min(x01, 1 - x01), TempoView.brightnessFadeCurve) + + return ZStack(alignment: .leading) { + RoundedRectangle(cornerRadius: TempoView.trackCornerRadius) + .fill(Color(white: TempoView.trackBrightness)) + .overlay( + RoundedRectangle(cornerRadius: TempoView.trackCornerRadius) + .strokeBorder( + Color.white.opacity(TempoView.trackBorderOpacity), + lineWidth: TempoView.trackBorderWidth + ) + ) + // Beat-position tick marks flush against each end wall. + .overlay(alignment: .leading) { wallTick } + .overlay(alignment: .trailing) { wallTick } + + playhead(x01: x01, wallGlow: wallGlow) + } + .frame(width: TempoView.trackWidth, height: TempoView.trackHeight) + .clipShape(RoundedRectangle(cornerRadius: TempoView.trackCornerRadius)) + } + + private var wallTick: some View { + Rectangle() + .fill(Color.white.opacity(TempoView.wallTickOpacity)) + .frame(width: TempoView.wallTickWidth) + } + + private func playhead(x01: Double, wallGlow: Double) -> some View { + // Travel spans the track minus the line's own width so the playhead kisses each wall. + let travel: CGFloat = TempoView.trackWidth - TempoView.lineWidth + let x: CGFloat = CGFloat(x01) * travel + let lineOpacity: Double = TempoView.lineMinOpacity + (1 - TempoView.lineMinOpacity) * wallGlow + + // Center glow + line share a leading-aligned box; offset positions the line's leading edge. + return ZStack { + Rectangle() + .fill(Color.red.opacity(TempoView.glowMaxOpacity * wallGlow)) + .frame(width: TempoView.glowWidth, height: TempoView.trackHeight) + .blur(radius: TempoView.glowWidth / 3) + Rectangle() + .fill(Color.red.opacity(lineOpacity)) + .frame(width: TempoView.lineWidth, height: TempoView.trackHeight) + } + .frame(width: TempoView.lineWidth, height: TempoView.trackHeight, alignment: .center) + .offset(x: x) } private var tapArea: some View { diff --git a/Tests/LyrebirdShoeGazeTests/PresetTests.swift b/Tests/LyrebirdShoeGazeTests/PresetTests.swift index 9bf56fe..9cd2dce 100644 --- a/Tests/LyrebirdShoeGazeTests/PresetTests.swift +++ b/Tests/LyrebirdShoeGazeTests/PresetTests.swift @@ -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 { diff --git a/Tests/LyrebirdShoeGazeTests/RigLibraryStoreTests.swift b/Tests/LyrebirdShoeGazeTests/RigLibraryStoreTests.swift index 6c4bc5e..d469cad 100644 --- a/Tests/LyrebirdShoeGazeTests/RigLibraryStoreTests.swift +++ b/Tests/LyrebirdShoeGazeTests/RigLibraryStoreTests.swift @@ -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() + } } diff --git a/docs/stereo-routing-design.md b/docs/stereo-routing-design.md index 4a9feae..489ebc6 100644 --- a/docs/stereo-routing-design.md +++ b/docs/stereo-routing-design.md @@ -197,10 +197,8 @@ are the case names — renames are a format break. Wideners and stereo-native pe (`OctaveUpSplitterPedal` "Octave Splitter", `PingPongDelayPedal` "Ping-Pong") are registered in `PedalRegistry`. Unknown pedal types are skipped on load, including inside branches. -The macOS Demo app has a `.stereo` mode (`ShoeGazeDemoController.buildStereo()` + -`DemoRootView.stereoContent`): Overdrive → `splitStereo(Delay | Ping-Pong)` → `collectStereo`, -with the four route modes selectable live. +The Builder app composes stereo chains directly from the palette — e.g. Overdrive → +`splitStereo(Delay | Ping-Pong)` → `collectStereo`, with the four route modes selectable live. -Deferred (follow-up): an iOS demo showcase (the iOS demo app has no mode switcher); rendering -the board's `orderedSegments` directly in a generic board view (today the UI composes pedal -rows and section views separately). +Deferred (follow-up): rendering the board's `orderedSegments` directly in a generic board view +(today the UI composes pedal rows and section views separately).