Add ShoeGaze Builder demo apps (macOS + iOS)
Two thin app shells hosting ShoeGazeBuilderView: - macOS (AppKit): seeds one board with an Overdrive; anchors the window ~100px from the left of the visible screen and sizes it to most of the screen height via LyrebirdWindow.nsWindow. - iOS (SwiftUI): NavigationStack hosting the builder; AVAudioSession + iOSAudioDriver; logs session-activation failures. Both .xcodeproj reference the local package (..) + the remote Lyrebird package, with fresh hex object-id prefixes; added to ShoeGaze.xcworkspace. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.music</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<true/>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2026 Realized Sound. All rights reserved.</string>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>ShoeGaze Builder can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode.</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user