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
+59
View File
@@ -0,0 +1,59 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
import SwiftUI
/// Two octaves of piano keys from C of [octave] (MIDI 60 = C4). Each key tracks its
/// own touch, so chords work; a key sends note-on on touch and note-off on release.
struct KeyboardView: View {
let octave: Int
let noteOn: (Int) -> Void
let noteOff: (Int) -> Void
private let whiteSteps = [0, 2, 4, 5, 7, 9, 11]
private let blackSteps: [(step: Int, afterWhite: Int)] = [(1, 0), (3, 1), (6, 3), (8, 4), (10, 5)]
var body: some View {
GeometryReader { geo in
let whites = 14
let w = geo.size.width / CGFloat(whites)
let base = (octave + 1) * 12
ZStack(alignment: .topLeading) {
HStack(spacing: 1) {
ForEach(0..<whites, id: \.self) { i in
Key(note: base + (i / 7) * 12 + whiteSteps[i % 7], black: false, noteOn: noteOn, noteOff: noteOff)
.frame(width: w - 1, height: geo.size.height)
}
}
ForEach(0..<10, id: \.self) { i in
let o = i / 5, b = blackSteps[i % 5]
Key(note: base + o * 12 + b.step, black: true, noteOn: noteOn, noteOff: noteOff)
.frame(width: w * 0.6, height: geo.size.height * 0.6)
.offset(x: CGFloat(o * 7 + b.afterWhite + 1) * w - w * 0.3)
}
}
}
}
private struct Key: View {
let note: Int
let black: Bool
let noteOn: (Int) -> Void
let noteOff: (Int) -> Void
@State private var down = false
var body: some View {
Rectangle()
.fill(down ? Color.orange : (black ? Color(white: 0.12) : Color(white: 0.92)))
.overlay(alignment: .bottom) {
if !black && note % 12 == 0 {
Text("C\(note / 12 - 1)").font(.system(size: 10, design: .monospaced))
.foregroundColor(.gray).padding(.bottom, 4)
}
}
.gesture(DragGesture(minimumDistance: 0)
.onChanged { _ in if !down { down = true; noteOn(note) } }
.onEnded { _ in down = false; noteOff(note) })
}
}
}