iOS milestone 3 groundwork: SizzleSession bridge, app shell with tabs, slot-backed editors, screen snapshots
SizzleSession owns the song, engine (192-frame chunks, try-lock on the audio thread), samples and audio output; AppModel/RootView give the four tabs; DeviceModel now works on toolbox slots too; make screen-snapshots renders the app's tabs on the Mac. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
7bc54e6466
commit
29650b88d7
@@ -0,0 +1,112 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import SwiftUI
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
/// 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 DeviceLabView: 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: 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(versionLine).font(.system(.caption, design: .monospaced)).foregroundColor(.gray)
|
||||
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((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)
|
||||
}
|
||||
|
||||
private var versionLine: String {
|
||||
let v = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "?"
|
||||
let b = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "?"
|
||||
return "\(v) (\(b))"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user