commit current state
This commit is contained in:
@@ -27,7 +27,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
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
|
||||
// Built-in mics are mono; default to one input channel so live input works out of the box.
|
||||
// CoreAudio can't satisfy a request for more input channels than the device provides, which
|
||||
// leaves live input silent. Users with multi-input interfaces can raise this in the UI.
|
||||
private static let inputChannels: Int = 1
|
||||
private static let numAudioBuses: Int = 256
|
||||
|
||||
// MARK: - Window geometry constants
|
||||
@@ -47,14 +50,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
// MARK: - Owned objects
|
||||
|
||||
private let coreDriver: CoreAudioDriver
|
||||
private let engine: SynthesisEngine
|
||||
private let shoeGaze: ShoeGaze
|
||||
private let window: LyrebirdWindow
|
||||
|
||||
/// Transport menu items, retained so `validateMenuItem(_:)` can enable/disable them.
|
||||
private var startMenuItem: NSMenuItem?
|
||||
private var stopMenuItem: NSMenuItem?
|
||||
|
||||
/// Record toggle item, retained so `validateMenuItem(_:)` can flip its title + enabled state.
|
||||
private var recordMenuItem: NSMenuItem?
|
||||
|
||||
@@ -64,14 +64,16 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
// 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: CoreAudioDriver()
|
||||
driver: coreDriver
|
||||
)
|
||||
self.coreDriver = coreDriver
|
||||
self.engine = engine
|
||||
self.shoeGaze = ShoeGaze(engine: engine)
|
||||
self.window = LyrebirdWindow(
|
||||
@@ -102,8 +104,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||
installMainMenu()
|
||||
let session: ShoeGaze = shoeGaze
|
||||
let driver: CoreAudioDriver = coreDriver
|
||||
window.open {
|
||||
ShoeGazeBuilderView(shoeGaze: session)
|
||||
ShoeGazeBuilderView(shoeGaze: session, hardwareSampleRate: { driver.deviceSampleRate })
|
||||
}
|
||||
anchorWindowLeft()
|
||||
}
|
||||
@@ -176,10 +179,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
mainMenu.addItem(boardMenuItem)
|
||||
let boardMenu: NSMenu = NSMenu(title: "Board")
|
||||
boardMenuItem.submenu = boardMenu
|
||||
// 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())
|
||||
startMenuItem = addItem(to: boardMenu, title: "Start", action: #selector(startAction(_:)), key: "r")
|
||||
stopMenuItem = addItem(to: boardMenu, title: "Stop", action: #selector(stopAction(_:)), key: ".")
|
||||
|
||||
// Record menu — choose an output folder, then toggle recording.
|
||||
let recordMenuItem: NSMenuItem = NSMenuItem()
|
||||
@@ -262,15 +264,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func startAction(_ sender: Any?) {
|
||||
do { try engine.start() }
|
||||
catch { print("[ShoeGazeBuilder] engine.start() failed: \(error)") }
|
||||
}
|
||||
|
||||
@objc private func stopAction(_ sender: Any?) {
|
||||
engine.stop()
|
||||
}
|
||||
|
||||
@objc private func chooseRecordingFolderAction(_ sender: Any?) {
|
||||
let panel: NSOpenPanel = NSOpenPanel()
|
||||
panel.canChooseDirectories = true
|
||||
@@ -299,8 +292,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
}
|
||||
|
||||
func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
|
||||
if menuItem == startMenuItem { return !engine.isRunning }
|
||||
if menuItem == stopMenuItem { return engine.isRunning }
|
||||
if menuItem == recordMenuItem {
|
||||
menuItem.title = shoeGaze.isRecording ? "Stop Recording" : "Start Recording"
|
||||
// Can always stop; can only start once a folder has been chosen.
|
||||
|
||||
Reference in New Issue
Block a user