705b4ed534
Live input on iOS needs an input channel, but constructing the engine with one up-front makes iOS prompt for the microphone at the first Start even in test-loop mode. Instead the engine starts input-less (no prompt) and is rebuilt on demand: - ShoeGazeBuilderView gains an optional onEnableLiveInput hook. When the user picks live input but the engine has no input channel, the picker offers a "Live Input" option that calls the hook; the input binding routes there too. On macOS (engine already has an input channel) the hook is nil and live input is selected directly. - The iOS app model implements the hook: request mic access, then on grant snapshot the rig (rigData), stop + teardown the engine, rebuild it with one input channel, restore the rig (loadRig), and select live input. The new ShoeGaze is published so the @Observable host view re-binds. - Input persistence restores live on relaunch: a saved live choice with the mic already authorised triggers the same rebuild silently (no prompt). Test: a rig captured on a 0-input engine restores onto a freshly built 1-input engine and live input is then selectable. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
38 lines
1.3 KiB
Swift
38 lines
1.3 KiB
Swift
// 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,
|
|
hardwareSampleRate: { model.hardwareSampleRate },
|
|
onEnableLiveInput: { model.enableLiveInput() }
|
|
)
|
|
.navigationTitle("ShoeGaze Builder")
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
}
|
|
.onDisappear { model.stop() }
|
|
}
|
|
}
|
|
}
|