// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown // SPDX-License-Identifier: GPL-3.0-or-later import SwiftUI /// Everything that runs once at launch, before any screen (Android's SizzleApp): /// settings that live outside the song, MIDI, and the hardware input sources. @MainActor enum AppBoot { static func start() { let settings = AppSettings.shared let session = SizzleSession.shared session.recordTailBars = settings.recordTailBars ThemeLibrary.shared.select(settings.paletteName) let input = InputController.shared input.app = AppModel.main input.start() HardwareInput.shared.start() let midi = SizzleMidi.shared midi.sendClock = settings.sendMidiClock midi.receiveClock = settings.receiveMidiClock midi.soundModule = settings.soundModule midi.onNote = { on, ch, note, vel in input.midiNote(on: on, channel: ch, note: note, velocity: vel) } midi.onControl = { cc, value in input.midiControl(cc, value) } midi.start(withDisabledKeys: settings.midiSourcesOff) } /// Leaving the foreground: save, and unless Sizzle stays on as a sound module /// (or is playing / recording), pause the audio so iOS can suspend the app. static func background() { let session = SizzleSession.shared session.autosave() let busy = session.isPlaying || session.masterRecording || SampleRecorder.shared.isRecording if !AppSettings.shared.soundModule && !busy { session.audioSuspended = true } } static func foreground() { SizzleSession.shared.audioSuspended = false } }