Files
sizzletracker-android/ios/app/Host/AppBoot.swift
T
ReactorcoremeltdownandClaude Opus 5.5 4d9e2328cb 0.38.0 (72): Bluetooth LE MIDI controllers in Settings (Android and iOS)
- Android: BleMidi scans for the BLE MIDI service, connects through
  MidiManager.openBluetoothDevice, remembers and reconnects controllers;
  Settings › MIDI inputs › Bluetooth MIDI (Scan / Connect / Disconnect / Forget)
- iOS: the system Bluetooth MIDI panel from Setup › MIDI Sync, connected
  controllers remembered and reconnected at launch via CoreBluetooth

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 14:57:53 +01:00

42 lines
1.7 KiB
Swift

// 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)
BluetoothMidi.shared.reconnectRemembered()
}
/// 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 }
}