iOS 0.2.0: instruments as AUv3, in-app host with keyboard, MIDI in and benchmark

Shared SizzleDeviceAU base for effects and instruments; sizzle::Instrument voice
pools; Android's factory presets generated into the specs header; the app hosts
every device in-process (no dependence on the system plugin registry).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Reactorcoremeltdown
2026-11-15 22:17:47 +01:00
co-authored by Claude Opus 5.5
parent a5b2f4c873
commit 7f231c8f79
35 changed files with 1989 additions and 368 deletions
+86 -11
View File
@@ -2,36 +2,111 @@
// SPDX-License-Identifier: GPL-3.0-or-later
import SwiftUI
import UniformTypeIdentifiers
/// The container app: what Sizzle installs as plugins, and an on-device check
/// that each one loads and processes sound. The plugins themselves are used from
/// a host (AUM, GarageBand, Loopy, …).
/// The app for now: play any Sizzle instrument through any Sizzle effect from the
/// keyboard or a MIDI controller, edit them, load samples, and measure each device
/// on this iPad. The tracker and the rest of Sizzle come in later milestones.
struct ContentView: View {
@StateObject private var model = HostModel()
@StateObject private var check = PluginCheck()
@State private var importing = false
@State private var pad = 0
@State private var showReport = false
var body: some View {
VStack(alignment: .leading, spacing: 12) {
VStack(alignment: .leading, spacing: 10) {
header
controls
editor
HStack {
Button("−") { model.octave = max(0, model.octave - 1) }.buttonStyle(.bordered)
Text("C\(model.octave)").font(.system(.body, design: .monospaced)).frame(width: 40)
Button("+") { model.octave = min(7, model.octave + 1) }.buttonStyle(.bordered)
Spacer()
Text(model.host.midiSources.isEmpty ? "No MIDI input" : "MIDI: " + model.host.midiSources.joined(separator: ", "))
.font(.system(.caption, design: .monospaced)).foregroundColor(.gray).lineLimit(1)
}
KeyboardView(octave: model.octave,
noteOn: { model.host.note(on: Int32($0), velocity: 100) },
noteOff: { model.host.noteOff(Int32($0)) })
.frame(height: 150)
}
.padding()
.preferredColorScheme(.dark)
.fileImporter(isPresented: $importing, allowedContentTypes: [.audio, .data]) { result in
if case .success(let url) = result { model.loadSample(url, pad: pad) }
}
.sheet(isPresented: $showReport) { reportSheet }
.alert(model.message ?? "", isPresented: Binding(get: { model.message != nil }, set: { if !$0 { model.message = nil } })) {
Button("OK") { model.message = nil }
}
}
private var header: some View {
HStack(alignment: .firstTextBaseline) {
Text("Sizzle").font(.system(.largeTitle, design: .monospaced)).foregroundColor(.orange)
Text("AUv3 plugins for AUM, GarageBand, Loopy and other hosts.\nLook for \"Tired Sysadmin: Sizzle …\".")
.font(.system(.footnote, design: .monospaced)).foregroundColor(.gray)
Text(versionLine).font(.system(.caption, design: .monospaced)).foregroundColor(.gray)
Button("Check all plugins") { Task { await check.run() } }
.buttonStyle(.bordered).disabled(check.running)
Spacer()
Button("Benchmark") { model.benchmark(); showReport = true }.disabled(model.busy)
Button("Check plugins") { showReport = true; Task { await check.run() } }
}
}
private var controls: some View {
HStack {
Menu {
ForEach(model.instruments, id: \.subtype) { d in Button(d.name) { model.select(d) } }
} label: { Label(model.instrument?.name ?? "Instrument", systemImage: "pianokeys") }
Image(systemName: "arrow.right").foregroundColor(.gray)
Menu {
Button("No effect") { model.selectEffect(nil) }
ForEach(model.effects, id: \.subtype) { d in Button(d.name) { model.selectEffect(d) } }
} label: { Label(model.effect?.name ?? "No effect", systemImage: "slider.horizontal.3") }
Spacer()
if model.effect != nil {
Picker("Edit", selection: $model.editingEffect) {
Text("Instrument").tag(false)
Text("Effect").tag(true)
}.pickerStyle(.segmented).frame(width: 220)
}
if model.canLoadSample {
if model.instrument?.toolboxType == "SAMPLER" {
Stepper("Pad \(pad + 1)", value: $pad, in: 0...15).frame(width: 150)
}
Button("Load sample…") { importing = true }
}
}
}
@ViewBuilder private var editor: some View {
if let unit = model.editedUnit {
DeviceEditorView(unit: unit)
.id(ObjectIdentifier(unit))
.frame(maxHeight: .infinity)
} else {
Spacer()
}
}
private var reportSheet: some View {
VStack(alignment: .leading, spacing: 8) {
Text("Benchmark and plugin check").font(.headline)
ScrollView {
Text(check.lines.joined(separator: "\n"))
Text((model.report + [""] + check.lines).joined(separator: "\n"))
.font(.system(.footnote, design: .monospaced))
.frame(maxWidth: .infinity, alignment: .leading)
.textSelection(.enabled)
}
if model.busy { ProgressView() }
}
.padding()
.preferredColorScheme(.dark)
.onAppear { check.listInstalled() }
}
private var versionLine: String {
let v = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "?"
let b = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "?"
return "version \(v) (\(b)) · iOS \(ProcessInfo.processInfo.operatingSystemVersionString)"
return "\(v) (\(b))"
}
}