diff --git a/Demo/ShoeGazeBuilder.xcodeproj/project.pbxproj b/Demo/ShoeGazeBuilder.xcodeproj/project.pbxproj new file mode 100644 index 0000000..8317f7b --- /dev/null +++ b/Demo/ShoeGazeBuilder.xcodeproj/project.pbxproj @@ -0,0 +1,379 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 60; + objects = { + +/* Begin PBXBuildFile section */ + C3B1000000000000000000C /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B100000000000000000007 /* main.swift */; }; + C3B1000000000000000000D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B100000000000000000008 /* AppDelegate.swift */; }; + C3B100000000000000000020 /* LyrebirdShoeGaze in Frameworks */ = {isa = PBXBuildFile; productRef = C3B10000000000000000001E /* LyrebirdShoeGaze */; }; + C3B100000000000000000021 /* LyrebirdShoeGazeUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3B10000000000000000001F /* LyrebirdShoeGazeUI */; }; + C3B100000000000000000022 /* Lyrebird in Frameworks */ = {isa = PBXBuildFile; productRef = C3B100000000000000000023 /* Lyrebird */; }; + C3B100000000000000000024 /* LyrebirdUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3B100000000000000000025 /* LyrebirdUI */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + C3B100000000000000000004 /* ShoeGazeBuilder.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ShoeGazeBuilder.app; sourceTree = BUILT_PRODUCTS_DIR; }; + C3B100000000000000000006 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C3B100000000000000000007 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + C3B100000000000000000008 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + C3B100000000000000000012 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + C3B100000000000000000020 /* LyrebirdShoeGaze in Frameworks */, + C3B100000000000000000021 /* LyrebirdShoeGazeUI in Frameworks */, + C3B100000000000000000022 /* Lyrebird in Frameworks */, + C3B100000000000000000024 /* LyrebirdUI in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + C3B100000000000000000002 = { + isa = PBXGroup; + children = ( + C3B100000000000000000005 /* ShoeGazeBuilder */, + C3B100000000000000000003 /* Products */, + ); + sourceTree = ""; + }; + C3B100000000000000000003 /* Products */ = { + isa = PBXGroup; + children = ( + C3B100000000000000000004 /* ShoeGazeBuilder.app */, + ); + name = Products; + sourceTree = ""; + }; + C3B100000000000000000005 /* ShoeGazeBuilder */ = { + isa = PBXGroup; + children = ( + C3B100000000000000000007 /* main.swift */, + C3B100000000000000000008 /* AppDelegate.swift */, + C3B100000000000000000006 /* Info.plist */, + ); + path = ShoeGazeBuilder; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + C3B100000000000000000014 /* ShoeGazeBuilder */ = { + isa = PBXNativeTarget; + buildConfigurationList = C3B100000000000000000015 /* Build configuration list for PBXNativeTarget "ShoeGazeBuilder" */; + buildPhases = ( + C3B100000000000000000011 /* Sources */, + C3B100000000000000000012 /* Frameworks */, + C3B100000000000000000013 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ShoeGazeBuilder; + packageProductDependencies = ( + C3B10000000000000000001E /* LyrebirdShoeGaze */, + C3B10000000000000000001F /* LyrebirdShoeGazeUI */, + C3B100000000000000000023 /* Lyrebird */, + C3B100000000000000000025 /* LyrebirdUI */, + ); + productName = ShoeGazeBuilder; + productReference = C3B100000000000000000004 /* ShoeGazeBuilder.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + C3B100000000000000000001 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1600; + LastUpgradeCheck = 2620; + TargetAttributes = { + C3B100000000000000000014 = { + CreatedOnToolsVersion = 16.0; + }; + }; + }; + buildConfigurationList = C3B100000000000000000018 /* Build configuration list for PBXProject "ShoeGazeBuilder" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = C3B100000000000000000002; + packageReferences = ( + C3B10000000000000000001B /* XCLocalSwiftPackageReference ".." */, + C3B10000000000000000001C /* XCRemoteSwiftPackageReference "Lyrebird" */, + ); + productRefGroup = C3B100000000000000000003 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + C3B100000000000000000014 /* ShoeGazeBuilder */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + C3B100000000000000000013 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + C3B100000000000000000011 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C3B1000000000000000000C /* main.swift in Sources */, + C3B1000000000000000000D /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + C3B100000000000000000016 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + CODE_SIGNING_REQUIRED = NO; + COMBINE_HIDPI_IMAGES = YES; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = dwarf; + DEVELOPMENT_TEAM = ""; + ENABLE_HARDENED_RUNTIME = YES; + INFOPLIST_FILE = ShoeGazeBuilder/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 15.0; + PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + C3B100000000000000000017 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + CODE_SIGNING_REQUIRED = NO; + COMBINE_HIDPI_IMAGES = YES; + DEAD_CODE_STRIPPING = YES; + DEVELOPMENT_TEAM = ""; + ENABLE_HARDENED_RUNTIME = YES; + INFOPLIST_FILE = ShoeGazeBuilder/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 15.0; + PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilder; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + C3B100000000000000000019 /* 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; + }; + C3B10000000000000000001A /* 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 */ + C3B100000000000000000015 /* Build configuration list for PBXNativeTarget "ShoeGazeBuilder" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C3B100000000000000000016 /* Debug */, + C3B100000000000000000017 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C3B100000000000000000018 /* Build configuration list for PBXProject "ShoeGazeBuilder" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C3B100000000000000000019 /* Debug */, + C3B10000000000000000001A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + C3B10000000000000000001B /* XCLocalSwiftPackageReference ".." */ = { + isa = XCLocalSwiftPackageReference; + relativePath = ..; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCRemoteSwiftPackageReference section */ + C3B10000000000000000001C /* XCRemoteSwiftPackageReference "Lyrebird" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://realizedsound.mooo.com/josh/Lyrebird"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 1.2.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + C3B10000000000000000001E /* LyrebirdShoeGaze */ = { + isa = XCSwiftPackageProductDependency; + package = C3B10000000000000000001B /* XCLocalSwiftPackageReference ".." */; + productName = LyrebirdShoeGaze; + }; + C3B10000000000000000001F /* LyrebirdShoeGazeUI */ = { + isa = XCSwiftPackageProductDependency; + package = C3B10000000000000000001B /* XCLocalSwiftPackageReference ".." */; + productName = LyrebirdShoeGazeUI; + }; + C3B100000000000000000023 /* Lyrebird */ = { + isa = XCSwiftPackageProductDependency; + package = C3B10000000000000000001C /* XCRemoteSwiftPackageReference "Lyrebird" */; + productName = Lyrebird; + }; + C3B100000000000000000025 /* LyrebirdUI */ = { + isa = XCSwiftPackageProductDependency; + package = C3B10000000000000000001C /* XCRemoteSwiftPackageReference "Lyrebird" */; + productName = LyrebirdUI; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = C3B100000000000000000001 /* Project object */; +} diff --git a/Demo/ShoeGazeBuilder.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Demo/ShoeGazeBuilder.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..82a587c --- /dev/null +++ b/Demo/ShoeGazeBuilder.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,33 @@ +{ + "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/ShoeGazeBuilder.xcodeproj/xcshareddata/xcschemes/ShoeGazeBuilder.xcscheme b/Demo/ShoeGazeBuilder.xcodeproj/xcshareddata/xcschemes/ShoeGazeBuilder.xcscheme new file mode 100644 index 0000000..411f737 --- /dev/null +++ b/Demo/ShoeGazeBuilder.xcodeproj/xcshareddata/xcschemes/ShoeGazeBuilder.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Demo/ShoeGazeBuilder/AppDelegate.swift b/Demo/ShoeGazeBuilder/AppDelegate.swift new file mode 100644 index 0000000..0df0109 --- /dev/null +++ b/Demo/ShoeGazeBuilder/AppDelegate.swift @@ -0,0 +1,158 @@ +// 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 Builder. +/// +/// Creates a `SynthesisEngine` and a `ShoeGaze` session seeded with one empty board, then opens a +/// `LyrebirdWindow` hosting ``ShoeGazeBuilderView`` — the interactive palette + board builder. +/// +/// 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 { + + // MARK: - Engine configuration constants + + private static let blockSize: Int = 512 + private static let sampleRate: Double = 48_000.0 + private static let outputChannels: Int = 2 + private static let inputChannels: Int = 2 + private static let numAudioBuses: Int = 256 + + // MARK: - Window geometry constants + + private static let windowWidth: CGFloat = 1_400 + private static let windowHeight: CGFloat = 860 + + /// Margin from the left edge of the screen's visible area, in points. + private static let leftMargin: CGFloat = 100 + /// Margin reserved at the right edge so the window never runs off-screen. + private static let rightMargin: CGFloat = 40 + /// Fraction of the visible screen height the window should occupy. + private static let heightFraction: CGFloat = 0.88 + + /// The default pedal the seed board comes up with, so audio is audible immediately on Start. + private static let seedPedalType: String = "Overdrive" + + // MARK: - Owned objects + + private let engine: SynthesisEngine + private let shoeGaze: ShoeGaze + private let window: LyrebirdWindow + + // MARK: - Init + + override init() { + let engine: SynthesisEngine = SynthesisEngine( + blockSize: AppDelegate.blockSize, + sampleRate: AppDelegate.sampleRate, + numOutputChannels: AppDelegate.outputChannels, + numInputChannels: AppDelegate.inputChannels, + numAudioBuses: AppDelegate.numAudioBuses, + driver: CoreAudioDriver() + ) + self.engine = engine + self.shoeGaze = ShoeGaze(engine: engine) + self.window = LyrebirdWindow( + title: "ShoeGaze Builder — Lyrebird Pedalboard", + width: AppDelegate.windowWidth, + height: AppDelegate.windowHeight + ) + super.init() + + seedInitialBoard() + } + + /// Seeds one board with a single pedal so the builder opens with an audible starting point. + private func seedInitialBoard() { + var created: PedalBoard? + do { + let board: PedalBoard = try shoeGaze.addBoard() + created = board + try shoeGaze.appendPedal(type: AppDelegate.seedPedalType, to: board) + } catch { + if let board: PedalBoard = created { shoeGaze.removeBoard(board) } + print("[ShoeGazeBuilder] seed board failed: \(error)") + } + } + + // MARK: - NSApplicationDelegate + + func applicationDidFinishLaunching(_ notification: Notification) { + installMainMenu() + let session: ShoeGaze = shoeGaze + window.open { + ShoeGazeBuilderView(shoeGaze: session) + } + anchorWindowLeft() + } + + /// Anchors the window `leftMargin` points from the left of the visible screen and sizes it to + /// most of the visible height, so it presents large and left-aligned rather than centered. + private func anchorWindowLeft() { + guard let nsWindow: NSWindow = window.nsWindow, + let screen: NSScreen = nsWindow.screen ?? NSScreen.main else { return } + let visible: NSRect = screen.visibleFrame + let height: CGFloat = visible.height * AppDelegate.heightFraction + let maxWidth: CGFloat = visible.width - AppDelegate.leftMargin - AppDelegate.rightMargin + let width: CGFloat = min(AppDelegate.windowWidth, maxWidth) + let originX: CGFloat = visible.minX + AppDelegate.leftMargin + // Top-align: place the window's top near the top of the visible area. + let originY: CGFloat = visible.maxY - height + nsWindow.setFrame( + NSRect(x: originX, y: originY, width: width, height: height), + display: true + ) + } + + func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + true + } + + func applicationWillTerminate(_ notification: Notification) { + engine.stop() + } + + // MARK: - Main menu + + /// Builds a minimal menu bar: an application menu with About / Hide / Quit (⌘Q). + private func installMainMenu() { + let appName: String = ProcessInfo.processInfo.processName + let mainMenu: NSMenu = NSMenu() + + 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" + ) + + NSApplication.shared.mainMenu = mainMenu + } +} +#endif diff --git a/Demo/ShoeGazeBuilder/Info.plist b/Demo/ShoeGazeBuilder/Info.plist new file mode 100644 index 0000000..6734627 --- /dev/null +++ b/Demo/ShoeGazeBuilder/Info.plist @@ -0,0 +1,32 @@ + + + + + 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 Realized Sound. All rights reserved. + NSMicrophoneUsageDescription + ShoeGaze Builder can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode. + NSPrincipalClass + NSApplication + + diff --git a/Demo/ShoeGazeBuilder/main.swift b/Demo/ShoeGazeBuilder/main.swift new file mode 100644 index 0000000..a67108b --- /dev/null +++ b/Demo/ShoeGazeBuilder/main.swift @@ -0,0 +1,23 @@ +// 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 Builder is a macOS AppKit application and has no iOS entry point here. +print("ShoeGazeBuilder runs on macOS only.") +#endif diff --git a/Demo/ShoeGazeBuilderiOS.xcodeproj/project.pbxproj b/Demo/ShoeGazeBuilderiOS.xcodeproj/project.pbxproj new file mode 100644 index 0000000..9784552 --- /dev/null +++ b/Demo/ShoeGazeBuilderiOS.xcodeproj/project.pbxproj @@ -0,0 +1,379 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 60; + objects = { + +/* Begin PBXBuildFile section */ + C3C100000000000000000009 /* ShoeGazeBuilderiOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3C100000000000000000007 /* ShoeGazeBuilderiOSApp.swift */; }; + C3C10000000000000000000A /* ShoeGazeBuilderiOSAppModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3C100000000000000000008 /* ShoeGazeBuilderiOSAppModel.swift */; }; + C3C10000000000000000000B /* LyrebirdShoeGaze in Frameworks */ = {isa = PBXBuildFile; productRef = C3C10000000000000000001A /* LyrebirdShoeGaze */; }; + C3C10000000000000000000C /* LyrebirdShoeGazeUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3C10000000000000000001B /* LyrebirdShoeGazeUI */; }; + C3C10000000000000000000D /* LyrebirdUI in Frameworks */ = {isa = PBXBuildFile; productRef = C3C10000000000000000001C /* LyrebirdUI */; }; + C3C10000000000000000001D /* Lyrebird in Frameworks */ = {isa = PBXBuildFile; productRef = C3C10000000000000000001E /* Lyrebird */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + C3C100000000000000000004 /* ShoeGazeBuilderiOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ShoeGazeBuilderiOS.app; sourceTree = BUILT_PRODUCTS_DIR; }; + C3C100000000000000000006 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C3C100000000000000000007 /* ShoeGazeBuilderiOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoeGazeBuilderiOSApp.swift; sourceTree = ""; }; + C3C100000000000000000008 /* ShoeGazeBuilderiOSAppModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoeGazeBuilderiOSAppModel.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + C3C10000000000000000000F /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + C3C10000000000000000000B /* LyrebirdShoeGaze in Frameworks */, + C3C10000000000000000000C /* LyrebirdShoeGazeUI in Frameworks */, + C3C10000000000000000000D /* LyrebirdUI in Frameworks */, + C3C10000000000000000001D /* Lyrebird in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + C3C100000000000000000002 = { + isa = PBXGroup; + children = ( + C3C100000000000000000005 /* ShoeGazeBuilderiOS */, + C3C100000000000000000003 /* Products */, + ); + sourceTree = ""; + }; + C3C100000000000000000003 /* Products */ = { + isa = PBXGroup; + children = ( + C3C100000000000000000004 /* ShoeGazeBuilderiOS.app */, + ); + name = Products; + sourceTree = ""; + }; + C3C100000000000000000005 /* ShoeGazeBuilderiOS */ = { + isa = PBXGroup; + children = ( + C3C100000000000000000007 /* ShoeGazeBuilderiOSApp.swift */, + C3C100000000000000000008 /* ShoeGazeBuilderiOSAppModel.swift */, + C3C100000000000000000006 /* Info.plist */, + ); + path = ShoeGazeBuilderiOS; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + C3C100000000000000000011 /* ShoeGazeBuilderiOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = C3C100000000000000000012 /* Build configuration list for PBXNativeTarget "ShoeGazeBuilderiOS" */; + buildPhases = ( + C3C10000000000000000000E /* Sources */, + C3C10000000000000000000F /* Frameworks */, + C3C100000000000000000010 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ShoeGazeBuilderiOS; + packageProductDependencies = ( + C3C10000000000000000001A /* LyrebirdShoeGaze */, + C3C10000000000000000001B /* LyrebirdShoeGazeUI */, + C3C10000000000000000001C /* LyrebirdUI */, + C3C10000000000000000001E /* Lyrebird */, + ); + productName = ShoeGazeBuilderiOS; + productReference = C3C100000000000000000004 /* ShoeGazeBuilderiOS.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + C3C100000000000000000001 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1600; + LastUpgradeCheck = 2620; + TargetAttributes = { + C3C100000000000000000011 = { + CreatedOnToolsVersion = 16.0; + }; + }; + }; + buildConfigurationList = C3C100000000000000000015 /* Build configuration list for PBXProject "ShoeGazeBuilderiOS" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = C3C100000000000000000002; + packageReferences = ( + C3C100000000000000000018 /* XCLocalSwiftPackageReference ".." */, + C3C100000000000000000019 /* XCRemoteSwiftPackageReference "Lyrebird" */, + ); + productRefGroup = C3C100000000000000000003 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + C3C100000000000000000011 /* ShoeGazeBuilderiOS */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + C3C100000000000000000010 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + C3C10000000000000000000E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C3C100000000000000000009 /* ShoeGazeBuilderiOSApp.swift in Sources */, + C3C10000000000000000000A /* ShoeGazeBuilderiOSAppModel.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + C3C100000000000000000013 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + CODE_SIGNING_REQUIRED = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = ShoeGazeBuilderiOS/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 18.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilderiOS; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SUPPORTS_MACCATALYST = NO; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 6.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + C3C100000000000000000014 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + CODE_SIGNING_REQUIRED = NO; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = ShoeGazeBuilderiOS/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 18.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = net.realizedsound.ShoeGazeBuilderiOS; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SUPPORTS_MACCATALYST = NO; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 6.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + C3C100000000000000000016 /* 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; + }; + C3C100000000000000000017 /* 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 */ + C3C100000000000000000012 /* Build configuration list for PBXNativeTarget "ShoeGazeBuilderiOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C3C100000000000000000013 /* Debug */, + C3C100000000000000000014 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C3C100000000000000000015 /* Build configuration list for PBXProject "ShoeGazeBuilderiOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C3C100000000000000000016 /* Debug */, + C3C100000000000000000017 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + C3C100000000000000000018 /* XCLocalSwiftPackageReference ".." */ = { + isa = XCLocalSwiftPackageReference; + relativePath = ..; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCRemoteSwiftPackageReference section */ + C3C100000000000000000019 /* XCRemoteSwiftPackageReference "Lyrebird" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://realizedsound.mooo.com/josh/Lyrebird"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 1.2.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + C3C10000000000000000001A /* LyrebirdShoeGaze */ = { + isa = XCSwiftPackageProductDependency; + package = C3C100000000000000000018 /* XCLocalSwiftPackageReference ".." */; + productName = LyrebirdShoeGaze; + }; + C3C10000000000000000001B /* LyrebirdShoeGazeUI */ = { + isa = XCSwiftPackageProductDependency; + package = C3C100000000000000000018 /* XCLocalSwiftPackageReference ".." */; + productName = LyrebirdShoeGazeUI; + }; + C3C10000000000000000001C /* LyrebirdUI */ = { + isa = XCSwiftPackageProductDependency; + package = C3C100000000000000000019 /* XCRemoteSwiftPackageReference "Lyrebird" */; + productName = LyrebirdUI; + }; + C3C10000000000000000001E /* Lyrebird */ = { + isa = XCSwiftPackageProductDependency; + package = C3C100000000000000000019 /* XCRemoteSwiftPackageReference "Lyrebird" */; + productName = Lyrebird; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = C3C100000000000000000001 /* Project object */; +} diff --git a/Demo/ShoeGazeBuilderiOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Demo/ShoeGazeBuilderiOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..82a587c --- /dev/null +++ b/Demo/ShoeGazeBuilderiOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,33 @@ +{ + "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/ShoeGazeBuilderiOS.xcodeproj/xcshareddata/xcschemes/ShoeGazeBuilderiOS.xcscheme b/Demo/ShoeGazeBuilderiOS.xcodeproj/xcshareddata/xcschemes/ShoeGazeBuilderiOS.xcscheme new file mode 100644 index 0000000..3fb8344 --- /dev/null +++ b/Demo/ShoeGazeBuilderiOS.xcodeproj/xcshareddata/xcschemes/ShoeGazeBuilderiOS.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Demo/ShoeGazeBuilderiOS/Info.plist b/Demo/ShoeGazeBuilderiOS/Info.plist new file mode 100644 index 0000000..6a23071 --- /dev/null +++ b/Demo/ShoeGazeBuilderiOS/Info.plist @@ -0,0 +1,46 @@ + + + + + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + NSHumanReadableCopyright + Copyright © 2026 Realized Sound. All rights reserved. + NSMicrophoneUsageDescription + ShoeGaze Builder can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode. + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + + UILaunchScreen + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Demo/ShoeGazeBuilderiOS/ShoeGazeBuilderiOSApp.swift b/Demo/ShoeGazeBuilderiOS/ShoeGazeBuilderiOSApp.swift new file mode 100644 index 0000000..78f4d3a --- /dev/null +++ b/Demo/ShoeGazeBuilderiOS/ShoeGazeBuilderiOSApp.swift @@ -0,0 +1,33 @@ +// ShoeGazeBuilderiOSApp.swift +// Lyrebird +// +// Copyright (c) 2026 Joshua Parmenter / realizedsound +// SPDX-License-Identifier: MIT + +import SwiftUI +import LyrebirdShoeGazeUI + +/// iOS entry point for the ShoeGaze Builder. +/// +/// Holds the `ShoeGazeBuilderiOSAppModel` 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 ``ShoeGazeBuilderView``. The engine is stopped when the view disappears. +/// +/// ``ShoeGazeBuilderView`` manages its own scroll regions (palette + builder), so it is hosted +/// directly rather than wrapped in an outer `ScrollView`. +@main +struct ShoeGazeBuilderiOSApp: App { + + @State private var model: ShoeGazeBuilderiOSAppModel = ShoeGazeBuilderiOSAppModel() + + var body: some Scene { + WindowGroup { + NavigationStack { + ShoeGazeBuilderView(shoeGaze: model.shoeGaze) + .navigationTitle("ShoeGaze Builder") + .navigationBarTitleDisplayMode(.inline) + } + .onDisappear { model.stop() } + } + } +} diff --git a/Demo/ShoeGazeBuilderiOS/ShoeGazeBuilderiOSAppModel.swift b/Demo/ShoeGazeBuilderiOS/ShoeGazeBuilderiOSAppModel.swift new file mode 100644 index 0000000..bf5a257 --- /dev/null +++ b/Demo/ShoeGazeBuilderiOS/ShoeGazeBuilderiOSAppModel.swift @@ -0,0 +1,79 @@ +// ShoeGazeBuilderiOSAppModel.swift +// Lyrebird +// +// Copyright (c) 2026 Joshua Parmenter / realizedsound +// SPDX-License-Identifier: MIT + +import AVFoundation +import Observation +import LyrebirdSynth +import LyrebirdShoeGaze + +/// Observable model owning the `SynthesisEngine` and `ShoeGaze` session for the iOS builder. +/// +/// `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). The session is seeded with one board +/// holding a single pedal so the builder opens with an audible starting point; the user adds / +/// removes / reorders pedals from the palette. Input defaults to `.testLoop`, so no microphone +/// permission is required to start. +@Observable +@MainActor +final class ShoeGazeBuilderiOSAppModel { + + // MARK: - Engine configuration constants + + private static let blockSize: Int = 512 + private static let outputChannels: Int = 2 + private static let numAudioBuses: Int = 256 + private static let seedPedalType: String = "Overdrive" + + // MARK: - Owned objects + + /// The active ShoeGaze builder session. + private(set) var shoeGaze: ShoeGaze + + private let engine: SynthesisEngine + + // MARK: - Init + + init() { + let session: AVAudioSession = AVAudioSession.sharedInstance() + do { + try session.setCategory(.playAndRecord, + mode: .default, + options: [.defaultToSpeaker, .allowBluetoothHFP]) + try session.setActive(true) + } catch { + // Surface the failure: the engine is built from `session.sampleRate` below, which may + // report a stale/default rate if activation failed. + print("[ShoeGazeBuilderiOS] AVAudioSession setup failed: \(error)") + } + let sampleRate: Double = session.sampleRate + + let eng: SynthesisEngine = SynthesisEngine( + blockSize: ShoeGazeBuilderiOSAppModel.blockSize, + sampleRate: sampleRate, + numOutputChannels: ShoeGazeBuilderiOSAppModel.outputChannels, + numInputChannels: 0, + numAudioBuses: ShoeGazeBuilderiOSAppModel.numAudioBuses, + driver: iOSAudioDriver() + ) + self.engine = eng + self.shoeGaze = ShoeGaze(engine: eng) + + do { + let board: PedalBoard = try shoeGaze.addBoard() + board.label = "Board 1" + try shoeGaze.appendPedal(type: ShoeGazeBuilderiOSAppModel.seedPedalType, to: board) + } catch { + print("[ShoeGazeBuilderiOS] seed board failed: \(error)") + } + } + + // MARK: - Transport + + /// Stops the audio engine. Call from `.onDisappear`. + func stop() { + engine.stop() + } +} diff --git a/ShoeGaze.xcworkspace/contents.xcworkspacedata b/ShoeGaze.xcworkspace/contents.xcworkspacedata index c7c9596..0770dba 100644 --- a/ShoeGaze.xcworkspace/contents.xcworkspacedata +++ b/ShoeGaze.xcworkspace/contents.xcworkspacedata @@ -10,4 +10,10 @@ + + + +