iOS 0.3.0: card editors like Android's for every plugin (knobs, switches, tabs, drawings)

Layouts exported from Android's DeviceLayouts (DeviceLayouts.json), iOS layouts
for the devices with hand-built Android editors, SwiftUI editor shared by the
extension and the app, Mac snapshot tool for the editors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Reactorcoremeltdown
2026-11-15 22:41:33 +01:00
co-authored by Claude Opus 5.5
parent 47588990ce
commit b6589ee792
22 changed files with 1052 additions and 161 deletions
@@ -6,6 +6,10 @@ package cc.tiredsysadmin.android.sizzle.audio
import cc.tiredsysadmin.android.sizzle.echofield.EchofieldDefs
import cc.tiredsysadmin.android.sizzle.frasil.FrasilDefs
import cc.tiredsysadmin.android.sizzle.model.AmbiencePresets
import cc.tiredsysadmin.android.sizzle.model.DelayDivisions
import cc.tiredsysadmin.android.sizzle.model.TimeDivision
import cc.tiredsysadmin.android.sizzle.ui.toolbox.DeviceLayouts
import cc.tiredsysadmin.android.sizzle.ui.toolbox.Viz
import cc.tiredsysadmin.android.sizzle.model.MixTightenerPresets
import cc.tiredsysadmin.android.sizzle.model.NesSynthPresets
import cc.tiredsysadmin.android.sizzle.wavetable.WaveDefs
@@ -40,6 +44,7 @@ class IosGoldenExport {
assumeTrue("set SIZZLE_GOLDEN_DIR to export", dir != null)
val out = File(dir!!).apply { mkdirs() }
System.getenv("SIZZLE_SPECS_OUT")?.let { File(it).writeText(specsHeader()) }
System.getenv("SIZZLE_LAYOUTS_OUT")?.let { File(it).writeText(layoutsJson()) }
val input = testSignal()
writeF32(File(out, "input.f32"), input)
@@ -160,6 +165,46 @@ class IosGoldenExport {
append("};\ninline constexpr int factoryPresetCount = ${all.size};\n\n} // namespace sizzle::gen\n")
}
private fun js(x: String) = "\"" + x.replace("\\", "\\\\").replace("\"", "\\\"") + "\""
/** Android's card layouts (DeviceLayouts.pagesFor) for every device, as JSON for
* the iOS editor, plus the value names some knobs show. A device with a bespoke
* Android editor comes out as Android's fallback (one card); iOS lays those out
* itself (ios/app/FX/Editor/BespokeLayouts.swift). */
private fun layoutsJson(): String = buildString {
append("{\n \"devices\": {\n")
ToolboxType.entries.forEachIndexed { ti, t ->
append(" ${js(t.name)}: [")
DeviceLayouts.pagesFor(t).forEachIndexed { pi, page ->
if (pi > 0) append(",")
append("\n {\"title\": ${js(page.title)}, \"panels\": [")
page.panels.forEachIndexed { ki, p ->
if (ki > 0) append(",")
append("\n {\"title\": ${js(p.title)}, \"tone\": ${js(p.tone.name)}, ")
append("\"keys\": [${p.keys.joinToString(", ") { js(it) }}]")
when (val v = p.viz) {
is Viz.Envelope -> append(", \"viz\": {\"kind\": \"envelope\", \"a\": ${js(v.a)}" +
(v.d?.let { ", \"d\": ${js(it)}" } ?: "") + (v.s?.let { ", \"s\": ${js(it)}" } ?: "") + ", \"r\": ${js(v.r)}}")
is Viz.Filter -> append(", \"viz\": {\"kind\": \"filter\"" + (v.type?.let { ", \"type\": ${js(it)}" } ?: "") +
", \"cutoff\": ${js(v.cutoff)}, \"reso\": ${js(v.reso)}}")
is Viz.Lfo -> append(", \"viz\": {\"kind\": \"lfo\", \"wave\": ${js(v.wave)}}")
is Viz.Wavetable -> append(", \"viz\": {\"kind\": \"wavetable\", \"osc\": ${v.osc}}")
null -> {}
}
if (p.labels.isNotEmpty()) append(", \"labels\": {${p.labels.entries.joinToString(", ") { "${js(it.key)}: ${js(it.value)}" }}}")
p.faders?.let { append(", \"faders\": [${it.joinToString(", ") { f -> js(f) }}], \"faderScale\": ${p.faderScale}") }
if (p.action != null) append(", \"action\": \"loadTable\"")
append("}")
}
append("]}")
}
append("\n ]").append(if (ti < ToolboxType.entries.size - 1) ",\n" else "\n")
}
append(" },\n")
append(" \"timeDivisions\": [${TimeDivision.entries.joinToString(", ") { js(it.label) }}],\n")
append(" \"delayDivisions\": [${DelayDivisions.entries.joinToString(", ") { js(it.first) }}]\n}\n")
}
private fun factoryPresets(): List<Triple<String, String, Map<String, String>>> {
val out = mutableListOf<Triple<String, String, Map<String, String>>>()
fun add(type: ToolboxType, name: String, apply: (ToolboxSlot) -> Unit) {
+12
View File
@@ -3,6 +3,18 @@
Sizzle for iOS/iPadOS (`cc.tiredsysadmin.ios.sizzle`). One entry per version in
`../versions.properties` (`ios.versionName` / `ios.versionCode`).
## 0.3.0 (build 6)
- Plugin editors like the Android app's: tabs of titled cards tinted by role,
knobs (slide up/down, double-tap to reset), switches for short choices, menus
for long ones, faders for the EQ, and live envelope, filter and LFO drawings.
The layouts come from the Android app's own DeviceLayouts; the devices whose
Android editor is hand-built (Synth, Tape Delay, Tape Engine, SF2/XI, Sampler,
Mix Tightener, Granular) get card layouts of their own. The same editor shows
in AUM and in the app.
- Not yet on iOS: the wavetable picture in the Wavetable's oscillator cards and
its LOAD TABLE button.
## 0.2.1 (build 5)
- Fix: switching instruments (e.g. to the Wavetable) killed the app. Rewiring the
+17 -1
View File
@@ -58,7 +58,7 @@ help:
# ------------------------------------------------------------------ core
golden:
cd .. && ANDROID_HOME=$(ANDROID_SDK) SIZZLE_GOLDEN_DIR=$(CURDIR)/$(GOLDEN) \
SIZZLE_SPECS_OUT=$(CURDIR)/$(SPECS_GEN) \
SIZZLE_SPECS_OUT=$(CURDIR)/$(SPECS_GEN) SIZZLE_LAYOUTS_OUT=$(CURDIR)/app/FX/DeviceLayouts.json \
./gradlew -q :app:testDebugUnitTest --tests '*IosGolden*' --rerun
@ls $(GOLDEN)/*.scn | wc -l | xargs echo "reference scenarios:"
@@ -86,6 +86,22 @@ au-test: build/core/au_test
@test -f $(GOLDEN)/input.f32 || $(MAKE) --no-print-directory golden
build/core/au_test $(GOLDEN)/input.f32
# Mac snapshots of the SwiftUI device editors (AUAudioUnit and SwiftUI exist on
# macOS too): the AU classes + core as a dylib, the editor Swift on top.
EDITOR_SWIFT := $(wildcard app/FX/Editor/*.swift)
build/snapshots/libsizzlesnap.dylib: $(AU_SRC) app/tests/SnapshotComponents.mm $(CORE_SRC) $(CORE_HDR)
mkdir -p build/snapshots
$(CXX) $(CXXFLAGS) -Wno-deprecated-declarations -fobjc-arc -Iapp/FX -dynamiclib -install_name @rpath/libsizzlesnap.dylib \
-o $@ $(AU_SRC) app/tests/SnapshotComponents.mm $(CORE_SRC) -framework AVFoundation -framework AudioToolbox -framework Foundation
build/snapshots/editor_snapshots: build/snapshots/libsizzlesnap.dylib $(EDITOR_SWIFT) app/tests/editor_snapshots.swift
swiftc -O -parse-as-library -import-objc-header app/tests/SnapshotBridging.h -Iapp/FX -Iapp/tests \
-o $@ $(EDITOR_SWIFT) app/tests/editor_snapshots.swift -Lbuild/snapshots -lsizzlesnap -Xlinker -rpath -Xlinker @executable_path
cp app/FX/DeviceLayouts.json build/snapshots/
editor-snapshots: build/snapshots/editor_snapshots
cd build/snapshots && ./editor_snapshots png
app/FX/Info.plist app/FX/Components.gen.h: app/components.txt tools/gen_components.py
python3 tools/gen_components.py app/components.txt app/FX/Info.plist app/FX/Components.gen.h
+2
View File
@@ -14,6 +14,8 @@ Makefile (`make -C ios help`).
| `app/FX/` | The plugin extension: `SizzleDeviceAU` (shared: parameters, presets, state), `SizzleEffectAU` (aufx), `SizzleInstrumentAU` (aumu), `SizzleFXViewController` (factory + editor). The app compiles the same classes to host them itself |
| `app/Host/` | The app: `SizzleHost` plays the devices in-process (instrument → effect → output, keyboard, MIDI in, samples, benchmark); `PluginCheck` checks the extension's plugins |
| `app/tests/au_test.mm` | Mac-side test of the AUv3 wrapper |
| `app/FX/Editor/` | The SwiftUI device editor (cards, knobs, drawings), from `DeviceLayouts.json` (exported from Android) and `BespokeLayouts.swift` |
| `app/tests/editor_snapshots.swift` | `make editor-snapshots`: renders every editor tab to PNG on the Mac |
| `tools/gen_components.py` | `components.txt` → the extension's Info.plist and `Components.gen.h` |
| `spike/` | The TrollStore AUv3 feasibility spike (see the end of this file) |
+1
View File
@@ -0,0 +1 @@
#import "SizzleDeviceAU.h"
+112
View File
@@ -0,0 +1,112 @@
{
"devices": {
"NES_SYNTH": [
{"title": "Synth", "panels": [
{"title": "Synth", "tone": "SOURCE", "keys": ["osc0wave", "osc0oct", "osc0semi", "osc0fine", "osc0level", "osc1wave", "osc1oct", "osc1semi", "osc1fine", "osc1level", "osc2wave", "osc2oct", "osc2semi", "osc2fine", "osc2level", "noise", "cutoff", "reso", "keytrack", "fenvamt", "fatk", "fdec", "fsus", "frel", "attack", "decay", "sustain", "release", "lfowave", "lfodiv", "lfophase", "m0src", "m0dst", "m0amt", "m1src", "m1dst", "m1amt", "m2src", "m2dst", "m2amt", "m3src", "m3dst", "m3amt"]}]}
],
"SAMPLER": [
{"title": "Sampler", "panels": [
{"title": "Sampler", "tone": "SOURCE", "keys": ["volume"]}]}
],
"SOUNDFONT": [
{"title": "SF2 / XI Loader", "panels": [
{"title": "SF2 / XI Loader", "tone": "SOURCE", "keys": ["program", "volume", "attack", "decay", "sustain", "release", "loop", "loopXfade"]}]}
],
"MORPH_PAD": [
{"title": "Sound", "panels": [
{"title": "Layer mix", "tone": "SOURCE", "keys": ["choir", "partials", "breath", "timbre", "warmth", "body"]},
{"title": "Envelope", "tone": "ENV", "keys": ["attack", "release", "velsens"], "viz": {"kind": "envelope", "a": "attack", "r": "release"}}]},
{"title": "Morph", "panels": [
{"title": "Morph", "tone": "MOD", "keys": ["morphTo", "morph", "mtime"], "labels": {"mtime": "Time"}},
{"title": "Motion", "tone": "MOD", "keys": ["motion", "mrate", "tide", "tperiod"], "labels": {"mrate": "Rate", "tperiod": "Tide Rate"}}]},
{"title": "Choir", "panels": [
{"title": "Choir voices", "tone": "SOURCE", "keys": ["interval", "detune", "shape", "soft"]},
{"title": "Choir filter", "tone": "FILTER", "keys": ["ctype", "cfilter", "creso"], "viz": {"kind": "filter", "type": "ctype", "cutoff": "cfilter", "reso": "creso"}, "labels": {"cfilter": "Cutoff", "ctype": "Type"}}]},
{"title": "Partials", "panels": [
{"title": "Partials", "tone": "SOURCE", "keys": ["tilt", "odd", "stretch", "evolve", "beat", "formant", "peak"]}]},
{"title": "Breath", "panels": [
{"title": "Breath", "tone": "SOURCE", "keys": ["bpitch", "bres", "color", "grain", "btone", "air"]}]}
],
"GRAIN_CLOUD": [
{"title": "Cloud", "panels": [
{"title": "Cloud", "tone": "SOURCE", "keys": ["source", "mode", "position", "texture", "scatter", "drift"]},
{"title": "Play", "tone": "OUT", "keys": ["freeze", "motion", "pitch", "harmony", "level"]}]},
{"title": "Grains", "panels": [
{"title": "Grains", "tone": "SOURCE", "keys": ["window", "size_mul", "dens_mul", "scan", "reverse", "grain_tone"], "labels": {"window": "Grain shape"}},
{"title": "Randomness", "tone": "MOD", "keys": ["pitch_rand", "size_rand"]}]},
{"title": "Keys", "panels": [
{"title": "Note envelope", "tone": "ENV", "keys": ["attack", "release", "velo"], "viz": {"kind": "envelope", "a": "attack", "r": "release"}},
{"title": "Sample region", "tone": "SOURCE", "keys": ["start", "end"]}]}
],
"WAVETABLE": [
{"title": "Osc 1", "panels": [
{"title": "Oscillator 1", "tone": "SOURCE", "keys": ["o1table", "wtframe", "o1pos", "o1level", "o1oct", "o1semi", "o1fine", "o1bend"], "viz": {"kind": "wavetable", "osc": 1}, "labels": {"wtframe": "Frame"}, "action": "loadTable"}]},
{"title": "Osc 2", "panels": [
{"title": "Oscillator 2", "tone": "SOURCE", "keys": ["o2table", "o2pos", "o2level", "o2oct", "o2semi", "o2fine", "o2bend"], "viz": {"kind": "wavetable", "osc": 2}}]},
{"title": "Voice", "panels": [
{"title": "Voice", "tone": "SOURCE", "keys": ["unison", "spread", "sub", "noise", "velsens"]}]},
{"title": "Filter", "panels": [
{"title": "Filter", "tone": "FILTER", "keys": ["ftype", "cutoff", "reso", "keytrack", "fenv", "drive"], "viz": {"kind": "filter", "type": "ftype", "cutoff": "cutoff", "reso": "reso"}, "labels": {"ftype": "Type", "fenv": "Env Amt"}}]},
{"title": "Amp", "panels": [
{"title": "Amp envelope", "tone": "ENV", "keys": ["attack", "decay", "sustain", "release"], "viz": {"kind": "envelope", "a": "attack", "d": "decay", "s": "sustain", "r": "release"}}]},
{"title": "Mod", "panels": [
{"title": "Mod envelope", "tone": "MOD", "keys": ["mattack", "mdecay", "msustain", "mrelease", "menvpos"], "viz": {"kind": "envelope", "a": "mattack", "d": "mdecay", "s": "msustain", "r": "mrelease"}}]},
{"title": "LFO", "panels": [
{"title": "LFO", "tone": "MOD", "keys": ["lfowave", "lfodiv", "lfopos", "lfopitch", "lfocut"], "viz": {"kind": "lfo", "wave": "lfowave"}, "labels": {"lfodiv": "Sync"}}]}
],
"ARPEGGIATOR": [
{"title": "Arp", "panels": [
{"title": "Pattern", "tone": "MOD", "keys": ["mode", "resetbar", "octaves", "division"], "labels": {"resetbar": "Restart every bar", "division": "Rate"}}]}
],
"TRANSPOSER": [
{"title": "Transpose", "panels": [
{"title": "Transpose", "tone": "SOURCE", "keys": ["octaves", "semitones"]}]}
],
"LFO": [
{"title": "LFO", "panels": [
{"title": "LFO", "tone": "MOD", "keys": ["wave", "depth", "phase", "division"], "viz": {"kind": "lfo", "wave": "wave"}, "labels": {"division": "Rate"}}]}
],
"DELAY": [
{"title": "Tape Delay", "panels": [
{"title": "Tape Delay", "tone": "SOURCE", "keys": ["feedback", "drywet", "tape", "head0On", "head0Div", "head1On", "head1Div", "head2On", "head2Div", "head3On", "head3Div"]}]}
],
"FILTER": [
{"title": "Filter", "panels": [
{"title": "Filter", "tone": "FILTER", "keys": ["type", "cutoff", "resonance", "warmth", "envamt"], "viz": {"kind": "filter", "type": "type", "cutoff": "cutoff", "reso": "resonance"}},
{"title": "Envelope", "tone": "ENV", "keys": ["attack", "decay", "sustain", "release"], "viz": {"kind": "envelope", "a": "attack", "d": "decay", "s": "sustain", "r": "release"}}]}
],
"EQ10": [
{"title": "EQ", "panels": [
{"title": "Graphic EQ · dB", "tone": "FILTER", "keys": ["band0", "band1", "band2", "band3", "band4", "band5", "band6", "band7", "band8", "band9"], "faders": ["31", "63", "125", "250", "500", "1k", "2k", "4k", "8k", "16k"], "faderScale": 12.0}]}
],
"BITCRUSHER": [
{"title": "Crush", "panels": [
{"title": "Crusher", "tone": "OUT", "keys": ["bits", "downsample", "drive"]}]}
],
"AMBIENCE": [
{"title": "Space", "panels": [
{"title": "Space", "tone": "SOURCE", "keys": ["algo", "predelay", "roomsize", "decay"], "labels": {"algo": "Algorithm"}},
{"title": "Mix", "tone": "OUT", "keys": ["wet", "dry"]}]},
{"title": "Tone", "panels": [
{"title": "Tone", "tone": "FILTER", "keys": ["hfdamp", "lfabsorb", "diffusion"]},
{"title": "Character", "tone": "SOURCE", "keys": ["erlevel", "saturation"]},
{"title": "Modulation", "tone": "MOD", "keys": ["modamt", "modrate"]}]},
{"title": "Ducking", "panels": [
{"title": "Ducking", "tone": "ENV", "keys": ["duckamt", "duckthresh", "duckattack", "duckrelease"], "labels": {"duckamt": "Amount", "duckattack": "Attack", "duckrelease": "Release"}}]}
],
"MIX_TIGHTENER": [
{"title": "Mix Tightener", "panels": [
{"title": "Mix Tightener", "tone": "SOURCE", "keys": ["strength"]}]}
],
"TAPE_ENGINE": [
{"title": "Tape Engine", "panels": [
{"title": "Tape Engine", "tone": "SOURCE", "keys": ["speed", "wow", "flutter", "hiss", "division"]}]}
],
"GRANULAR": [
{"title": "Granular Glitch", "panels": [
{"title": "Granular Glitch", "tone": "SOURCE", "keys": ["intensity"]}]}
]
},
"timeDivisions": ["1/1", "1/2", "1/4", "1/8", "1/16", "1/32", "1/8."],
"delayDivisions": ["1/1", "1/2.", "1/2", "1/4.", "1/2T", "1/4", "1/8.", "1/4T", "1/8", "1/16.", "1/8T", "1/16", "1/16T"]
}
+77
View File
@@ -0,0 +1,77 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
/// Card layouts for the devices whose Android editor is hand-built (Android's
/// DeviceLayouts only has a one-card fallback for them), grouped the way those
/// Android editors group their controls.
enum BespokeLayouts {
typealias P = LayoutPanel
typealias V = LayoutPanel.Viz
static let pages: [String: [LayoutPage]] = [
"NES_SYNTH": [
LayoutPage(title: "Osc", panels: (0..<3).map { i in
P(title: "Oscillator \(i + 1)", tone: .SOURCE,
keys: ["osc\(i)wave", "osc\(i)level", "osc\(i)oct", "osc\(i)semi", "osc\(i)fine"])
} + [P(title: "Noise", tone: .SOURCE, keys: ["noise"])]),
LayoutPage(title: "Filter", panels: [
P(title: "Filter", tone: .FILTER, keys: ["cutoff", "reso", "keytrack", "fenvamt"],
viz: V(kind: "filter", cutoff: "cutoff", reso: "reso"), labels: ["fenvamt": "Env Amt"]),
P(title: "Filter envelope", tone: .ENV, keys: ["fatk", "fdec", "fsus", "frel"],
viz: V(kind: "envelope", a: "fatk", d: "fdec", s: "fsus", r: "frel")),
]),
LayoutPage(title: "Amp", panels: [
P(title: "Amp envelope", tone: .ENV, keys: ["attack", "decay", "sustain", "release"],
viz: V(kind: "envelope", a: "attack", d: "decay", s: "sustain", r: "release")),
]),
LayoutPage(title: "LFO", panels: [
P(title: "LFO", tone: .MOD, keys: ["lfowave", "lfodiv", "lfophase"],
viz: V(kind: "lfo", wave: "lfowave"), labels: ["lfodiv": "Rate", "lfophase": "Phase"]),
]),
LayoutPage(title: "Mod", panels: (0..<4).map { i in
P(title: "Mod slot \(i + 1)", tone: .MOD, keys: ["m\(i)src", "m\(i)dst", "m\(i)amt"],
labels: ["m\(i)src": "Source", "m\(i)dst": "Target", "m\(i)amt": "Amount"])
}),
],
"DELAY": [
LayoutPage(title: "Delay", panels: [
P(title: "Tape heads", tone: .MOD,
keys: (0..<4).flatMap { ["head\($0)On", "head\($0)Div"] },
labels: Dictionary(uniqueKeysWithValues: (0..<4).flatMap {
[("head\($0)On", "Head \($0 + 1)"), ("head\($0)Div", "Head \($0 + 1)")]
})),
P(title: "Loop", tone: .OUT, keys: ["feedback", "drywet", "tape"],
labels: ["drywet": "Mix", "tape": "Tape"]),
]),
],
"TAPE_ENGINE": [
LayoutPage(title: "Tape", panels: [
P(title: "Transport", tone: .SOURCE, keys: ["speed", "division"], labels: ["division": "Wow Sync"]),
P(title: "Wear", tone: .MOD, keys: ["wow", "flutter", "hiss"]),
]),
],
"MIX_TIGHTENER": [
LayoutPage(title: "Tightener", panels: [
P(title: "Strength", tone: .OUT, keys: ["strength"]),
]),
],
"GRANULAR": [
LayoutPage(title: "Glitch", panels: [
P(title: "Glitch", tone: .MOD, keys: ["intensity"]),
]),
],
"SAMPLER": [
LayoutPage(title: "Sampler", panels: [
P(title: "Output", tone: .OUT, keys: ["volume"]),
]),
],
"SOUNDFONT": [
LayoutPage(title: "Loader", panels: [
P(title: "Sample", tone: .SOURCE, keys: ["program", "loop", "loopXfade", "volume"],
labels: ["loopXfade": "Loop Fade"]),
P(title: "Envelope", tone: .ENV, keys: ["attack", "decay", "sustain", "release"],
viz: V(kind: "envelope", a: "attack", d: "decay", s: "sustain", r: "release")),
]),
],
]
}
+208
View File
@@ -0,0 +1,208 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
import SwiftUI
/// Sizzle's dark retro palette (Android's default theme) and the card tones.
enum Theme {
static let background = Color(red: 0.07, green: 0.08, blue: 0.09)
static let surface = Color(red: 0.11, green: 0.12, blue: 0.14)
static let grid = Color(white: 0.24)
static let text = Color(white: 0.92)
static let dim = Color(white: 0.58)
static let accent = Color(red: 0.96, green: 0.76, blue: 0.29)
static func tone(_ t: LayoutPanel.Tone) -> Color {
switch t {
case .SOURCE: return accent
case .FILTER: return Color(red: 0.45, green: 0.85, blue: 0.55)
case .ENV: return Color(red: 0.96, green: 0.56, blue: 0.69)
case .MOD: return Color(red: 0.70, green: 0.62, blue: 1.0)
case .OUT: return text
}
}
static func mono(_ size: CGFloat) -> Font { .system(size: size, design: .monospaced) }
}
/// A rotary knob like Android's: slide up/down to turn (a full sweep takes 280 pt,
/// independent of the knob's size, so fine moves are easy), double-tap to reset.
/// Bipolar ranges fill from the centre.
struct KnobView: View {
let label: String
let valueText: String
let value: Float
let min: Float
let max: Float
let def: Float
let tone: Color
let onChange: (Float) -> Void
@State private var dragStart: Float?
private let travel: Float = 280
var body: some View {
let span = max > min ? max - min : 1
let frac = CGFloat(Swift.min(1, Swift.max(0, (value - min) / span)))
let zero = CGFloat(Swift.min(1, Swift.max(0, (0 - min) / span)))
let bipolar = min < 0 && max > 0
VStack(spacing: 3) {
Text(valueText).font(Theme.mono(10)).foregroundColor(Theme.text).lineLimit(1).minimumScaleFactor(0.7)
ZStack {
Arc(from: 0, to: 1).stroke(Theme.grid, style: StrokeStyle(lineWidth: 4, lineCap: .round))
Arc(from: bipolar ? Swift.min(zero, frac) : 0, to: bipolar ? Swift.max(zero, frac) : frac)
.stroke(tone, style: StrokeStyle(lineWidth: 4, lineCap: .round))
Pointer(frac: frac).stroke(Theme.text, style: StrokeStyle(lineWidth: 2, lineCap: .round))
}
.frame(width: 46, height: 46)
.contentShape(Rectangle())
.gesture(DragGesture(minimumDistance: 1)
.onChanged { g in
if dragStart == nil { dragStart = value }
let v = (dragStart ?? value) - Float(g.translation.height) / travel * span
onChange(Swift.min(max, Swift.max(min, v)))
}
.onEnded { _ in dragStart = nil })
.onTapGesture(count: 2) { onChange(def) }
Text(label.uppercased()).font(Theme.mono(9)).foregroundColor(Theme.dim).lineLimit(1).minimumScaleFactor(0.7)
}
.frame(maxWidth: .infinity)
}
/// 270° arc from bottom-left (135°) clockwise, between fractions [from]..[to].
private struct Arc: Shape {
let from: CGFloat, to: CGFloat
func path(in r: CGRect) -> Path {
var p = Path()
let c = CGPoint(x: r.midX, y: r.midY), rad = Swift.min(r.width, r.height) / 2 - 2
p.addArc(center: c, radius: rad, startAngle: .degrees(135 + 270 * from),
endAngle: .degrees(135 + 270 * to), clockwise: false)
return p
}
}
private struct Pointer: Shape {
let frac: CGFloat
func path(in r: CGRect) -> Path {
let c = CGPoint(x: r.midX, y: r.midY), rad = Swift.min(r.width, r.height) / 2 * 0.8
let a = (135 + 270 * frac) * .pi / 180
var p = Path()
p.move(to: c)
p.addLine(to: CGPoint(x: c.x + rad * cos(a), y: c.y + rad * sin(a)))
return p
}
}
}
/// A short choice list as a row of buttons.
struct SegmentedView: View {
let label: String
let choices: [String]
let selected: Int
let tone: Color
let onSelect: (Int) -> Void
var body: some View {
VStack(alignment: .leading, spacing: 3) {
Text(label.uppercased()).font(Theme.mono(9)).foregroundColor(Theme.dim)
HStack(spacing: 0) {
ForEach(choices.indices, id: \.self) { i in
let on = i == selected
Text(choices[i]).font(Theme.mono(11)).lineLimit(1).minimumScaleFactor(0.6)
.foregroundColor(on ? tone : Theme.dim)
.frame(maxWidth: .infinity, minHeight: 30)
.background(on ? tone.opacity(0.22) : Color.clear)
.overlay(Rectangle().stroke(on ? tone : Theme.grid.opacity(0.6), lineWidth: 0.5))
.contentShape(Rectangle())
.onTapGesture { onSelect(i) }
}
}
.overlay(Rectangle().stroke(Theme.grid, lineWidth: 1))
}
}
}
/// A long choice list as a menu.
struct ChoiceMenu: View {
let label: String
let choices: [String]
let selected: Int
let tone: Color
let onSelect: (Int) -> Void
var body: some View {
Menu {
ForEach(choices.indices, id: \.self) { i in Button(choices[i]) { onSelect(i) } }
} label: {
HStack {
Text(label.uppercased() + ":").foregroundColor(Theme.dim)
Text(choices.indices.contains(selected) ? choices[selected] : "").foregroundColor(Theme.text)
Spacer(minLength: 4)
Text("▾").foregroundColor(tone)
}
.font(Theme.mono(11))
.padding(.horizontal, 8).frame(minHeight: 30)
.overlay(Rectangle().stroke(Theme.grid, lineWidth: 1))
}
}
}
/// An on/off switch (stored as 0 / 1).
struct ToggleChip: View {
let label: String
let on: Bool
let tone: Color
let onToggle: () -> Void
var body: some View {
Text(label.uppercased()).font(Theme.mono(10)).lineLimit(1)
.foregroundColor(on ? tone : Theme.dim)
.frame(maxWidth: .infinity, minHeight: 30)
.background(on ? tone.opacity(0.22) : Color.clear)
.overlay(Rectangle().stroke(on ? tone : Theme.grid, lineWidth: 1))
.contentShape(Rectangle())
.onTapGesture(perform: onToggle)
}
}
/// Vertical bipolar faders (the graphic EQ): drag or tap to set, double-tap to zero.
struct FaderBank: View {
let infos: [ParamInfo]
let captions: [String]
let scale: Float
let tone: Color
@ObservedObject var model: DeviceModel
var body: some View {
HStack(spacing: 3) {
ForEach(infos.indices, id: \.self) { i in
let p = infos[i]
let v = model.value(p.key)
VStack(spacing: 2) {
let shown = v * scale
Text((shown > 0.05 ? "+" : "") + String(format: "%.0f", shown)).font(Theme.mono(9)).foregroundColor(Theme.text)
GeometryReader { g in
let span = p.max - p.min
let zeroY = g.size.height * CGFloat(1 - (0 - p.min) / span)
let y = g.size.height * CGFloat(1 - (v - p.min) / span)
ZStack(alignment: .topLeading) {
Rectangle().fill(Theme.background)
Rectangle().fill(tone.opacity(0.45))
.frame(height: abs(zeroY - y)).offset(y: Swift.min(y, zeroY))
Rectangle().fill(tone).frame(height: 4).offset(y: y - 2)
}
.overlay(Rectangle().stroke(Theme.grid, lineWidth: 1))
.contentShape(Rectangle())
.gesture(DragGesture(minimumDistance: 0).onChanged { d in
let f = Float(1 - Swift.min(1, Swift.max(0, d.location.y / g.size.height)))
model.set(p.key, p.min + f * span)
})
.onTapGesture(count: 2) { model.set(p.key, p.def) }
}
.frame(height: 140)
Text(i < captions.count ? captions[i] : "").font(Theme.mono(9)).foregroundColor(Theme.dim)
}
}
}
}
}
+148
View File
@@ -0,0 +1,148 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
import SwiftUI
#if canImport(UIKit)
import UIKit
#endif
/// A device's editor, like the Android app's: tabs of titled cards, each tinted by
/// its role, with knobs for numbers, switches for short choices, menus for long
/// ones, faders for the EQ and live drawings. Used by the plugin extension and by
/// the app for the devices it hosts.
struct DeviceEditor: View {
@StateObject var model: DeviceModel
@State var page = 0
/// Render without a ScrollView (the Mac snapshot tool; ImageRenderer can't draw one).
static var snapshot = false
var body: some View {
let pages = Layouts.pages(for: model.au.toolboxType, allKeys: model.order)
VStack(alignment: .leading, spacing: 8) {
HStack {
Text(model.au.displayName.uppercased()).font(Theme.mono(15)).foregroundColor(Theme.accent)
Spacer()
if let presets = model.au.factoryPresets, !presets.isEmpty {
Menu {
ForEach(presets, id: \.number) { p in Button(p.name) { model.applyPreset(p) } }
} label: {
Text("PRESET: \(model.presetName ?? "—") ▾").font(Theme.mono(12)).foregroundColor(Theme.accent)
}
}
}
if pages.count > 1 {
HStack(spacing: 4) {
ForEach(pages.indices, id: \.self) { i in
let on = i == page
let tone = Theme.tone(pages[i].panels.first?.tone ?? .SOURCE)
Text(pages[i].title.uppercased()).font(Theme.mono(pages.count > 5 ? 10 : 12))
.lineLimit(1).minimumScaleFactor(0.7)
.foregroundColor(on ? tone : Theme.dim)
.frame(maxWidth: .infinity, minHeight: 30)
.background(on ? tone.opacity(0.22) : Theme.surface)
.overlay(Rectangle().stroke(on ? tone : Theme.grid, lineWidth: 1))
.contentShape(Rectangle())
.onTapGesture { page = i }
}
}
}
let cards = VStack(spacing: 8) {
ForEach(pages[Swift.min(page, pages.count - 1)].panels) { panel in
CardView(panel: panel, model: model)
}
}
if DeviceEditor.snapshot { cards; Spacer(minLength: 0) } else { ScrollView { cards } }
}
.padding(10)
.background(Theme.background)
}
}
/// One card: header, optional drawing, then choices, switches and knobs (or faders).
struct CardView: View {
let panel: LayoutPanel
@ObservedObject var model: DeviceModel
var body: some View {
let tone = Theme.tone(panel.tone)
let infos = panel.keys.compactMap { model.params[$0] }
let enums = infos.filter { $0.isEnum }
let segmented = enums.filter { $0.choices.count <= 6 && $0.choices.joined().count <= 34 }
let menus = enums.filter { !($0.choices.count <= 6 && $0.choices.joined().count <= 34) }
let toggles = infos.filter { $0.isToggle }
let knobs = infos.filter { !$0.isEnum && !$0.isToggle }
VStack(alignment: .leading, spacing: 7) {
HStack(spacing: 6) {
Rectangle().fill(tone).frame(width: 8, height: 8)
Text(panel.title.uppercased()).font(Theme.mono(11)).foregroundColor(tone)
}
if let viz = panel.viz, viz.kind != "wavetable" {
VizView(viz: viz, tone: tone, model: model)
}
if let captions = panel.faders {
FaderBank(infos: infos, captions: captions, scale: panel.faderScale ?? 1, tone: tone, model: model)
} else {
ForEach(Array(stride(from: 0, to: menus.count, by: 2)), id: \.self) { i in
HStack(spacing: 8) {
ForEach(menus[i..<Swift.min(i + 2, menus.count)], id: \.key) { p in
ChoiceMenu(label: Format.shortLabel(p, labels: panel.labels), choices: p.choices,
selected: Int(model.value(p.key).rounded()), tone: tone) { model.set(p.key, Float($0)) }
}
}
}
ForEach(segmented, id: \.key) { p in
SegmentedView(label: Format.shortLabel(p, labels: panel.labels), choices: p.choices,
selected: Int(model.value(p.key).rounded()), tone: tone) { model.set(p.key, Float($0)) }
}
if !toggles.isEmpty {
HStack(spacing: 6) {
ForEach(toggles, id: \.key) { p in
ToggleChip(label: Format.shortLabel(p, labels: panel.labels), on: model.value(p.key) >= 0.5,
tone: tone) { model.set(p.key, model.value(p.key) >= 0.5 ? 0 : 1) }
}
}
}
knobRows(knobs, tone: tone)
}
}
.padding(.horizontal, 8).padding(.vertical, 7)
.background(Theme.surface)
.overlay(Rectangle().stroke(tone.opacity(0.35), lineWidth: 1))
}
/// Up to six knobs a row, rows evenly filled, centred (Android's PanelCard).
@ViewBuilder private func knobRows(_ knobs: [ParamInfo], tone: Color) -> some View {
let n = knobs.count
if n > 0 {
let perRow = n <= 6 ? n : Int(ceil(Double(n) / ceil(Double(n) / 6)))
let slots = Swift.max(perRow, 4)
ForEach(Array(stride(from: 0, to: n, by: perRow)), id: \.self) { start in
let row = Array(knobs[start..<Swift.min(start + perRow, n)])
HStack(spacing: 4) {
let pad = slots - row.count
ForEach(0..<(pad / 2), id: \.self) { _ in Color.clear.frame(maxWidth: .infinity, maxHeight: 1) }
ForEach(row, id: \.key) { p in
KnobView(label: Format.shortLabel(p, labels: panel.labels),
valueText: Format.value(p, model.value(p.key)),
value: model.value(p.key), min: p.min, max: p.max, def: p.def, tone: tone) { model.set(p.key, $0) }
}
ForEach(0..<(pad - pad / 2), id: \.self) { _ in Color.clear.frame(maxWidth: .infinity, maxHeight: 1) }
}
}
}
}
}
#if canImport(UIKit)
/// For the Objective-C view controller: the editor for [au] in a hosting controller.
@objc(SizzleEditorFactory)
@MainActor
public final class SizzleEditorFactory: NSObject {
@objc public static func makeEditor(for au: SizzleDeviceAU) -> UIViewController {
let vc = UIHostingController(rootView: DeviceEditor(model: DeviceModel(au: au)))
vc.view.backgroundColor = UIColor(red: 0.07, green: 0.08, blue: 0.09, alpha: 1)
return vc
}
}
#endif
+86
View File
@@ -0,0 +1,86 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
import AudioToolbox
import Foundation
/// One parameter as the editor sees it: the AU parameter plus what Sizzle's spec
/// says about it (default, whole numbers, label).
struct ParamInfo {
let param: AUParameter
let key: String
let label: String
let min: Float
let max: Float
let def: Float
let isInt: Bool
let choices: [String]
var isEnum: Bool { !choices.isEmpty }
/// On/off switches stored as 0..1 numbers (the Tape Delay's "Head N On").
var isToggle: Bool { !isEnum && key.hasSuffix("On") && min == 0 && max == 1 }
}
/// The editor's view of a SizzleDeviceAU: every parameter's value, kept in step
/// with the AU (host automation, presets) through a parameter observer.
@MainActor
final class DeviceModel: ObservableObject {
let au: SizzleDeviceAU
let params: [String: ParamInfo]
let order: [String]
@Published private(set) var values: [String: Float] = [:]
@Published var presetName: String?
private var token: AUParameterObserverToken?
init(au: SizzleDeviceAU) {
self.au = au
var params: [String: ParamInfo] = [:]
var order: [String] = []
var values: [String: Float] = [:]
for p in au.parameterTree?.allParameters ?? [] {
let info = ParamInfo(param: p, key: p.identifier, label: au.specLabel(for: p),
min: p.minValue, max: p.maxValue, def: au.defaultValue(for: p),
isInt: au.isIntegerParameter(p), choices: p.valueStrings ?? [])
params[p.identifier] = info
order.append(p.identifier)
values[p.identifier] = p.value
}
self.params = params
self.order = order
self.values = values
presetName = au.currentPreset?.name
token = au.parameterTree?.token(byAddingParameterObserver: { [weak self] address, value in
DispatchQueue.main.async { self?.observed(address: address, value: value) }
})
}
deinit {
if let token = token { au.parameterTree?.removeParameterObserver(token) }
}
private func observed(address: AUParameterAddress, value: AUValue) {
guard let p = au.parameterTree?.parameter(withAddress: address) else { return }
values[p.identifier] = value
}
func value(_ key: String) -> Float { values[key] ?? params[key]?.def ?? 0 }
func set(_ key: String, _ v: Float) {
guard let info = params[key] else { return }
var x = Swift.min(Swift.max(v, info.min), info.max)
if info.isInt { x = x.rounded() }
values[key] = x
info.param.setValue(x, originator: token)
}
func choice(_ key: String) -> String {
guard let info = params[key], info.isEnum else { return "" }
let i = Int(value(key).rounded())
return info.choices[Swift.max(0, Swift.min(info.choices.count - 1, i))]
}
func applyPreset(_ preset: AUAudioUnitPreset) {
au.currentPreset = preset
presetName = preset.name
for (key, info) in params { values[key] = info.param.value }
}
}
+56
View File
@@ -0,0 +1,56 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
import Foundation
/// Captions and value text, as Android's Panels.kt shortLabel() / formatParam().
enum Format {
private static let prefix = try! NSRegularExpression(pattern: "^(Osc\\s?\\d|Mod\\d?|LFO|Duck|F\\.)\\s+")
private static let unit = try! NSRegularExpression(pattern: "\\s*\\((dB|ms|s)\\)|\\s+s$")
private static let arrow = try! NSRegularExpression(pattern: "^.*>\\s*")
private static let timeKeys: Set<String> = ["attack", "decay", "release", "mattack", "mdecay", "mrelease", "fatk", "fdec", "frel"]
private static let divisionKeys: Set<String> = ["division", "lfodiv"]
private static let keyUnits: [String: String] = [
"predelay": "ms", "modrate": "Hz", "mtime": "s", "loopXfade": "ms",
"pitch": "st", "pitch_rand": "st", "semitones": "st", "o1semi": "st", "o2semi": "st",
"o1fine": "ct", "o2fine": "ct", "roomsize": "×",
]
private static func replace(_ re: NSRegularExpression, _ s: String, _ with: String) -> String {
re.stringByReplacingMatches(in: s, range: NSRange(s.startIndex..., in: s), withTemplate: with)
}
/// A control's caption: the card's override, else the label without its section
/// prefix ("Osc1 Level" → "Level", "LFO > Pitch" → "→ Pitch") or unit.
static func shortLabel(_ p: ParamInfo, labels: [String: String]?) -> String {
if let l = labels?[p.key] { return l }
return replace(arrow, replace(prefix, replace(unit, p.label, ""), ""), "→ ")
}
private static func roundToInt(_ v: Float) -> Int { Int((Double(v) + 0.5).rounded(.down)) }
/// How a value reads under its knob: time in ms / s, 0..1 as %, divisions by name.
static func value(_ p: ParamInfo, _ v: Float) -> String {
if p.isEnum { let i = max(0, min(p.choices.count - 1, roundToInt(v))); return p.choices[i] }
if p.key.hasSuffix("Div"), let names = Layouts.file?.delayDivisions {
return names[max(0, min(names.count - 1, Int(v)))]
}
if divisionKeys.contains(p.key), let names = Layouts.file?.timeDivisions {
return names[max(0, min(names.count - 1, roundToInt(v)))]
}
let u = keyUnits[p.key] ?? (p.label.contains("(dB)") ? "dB" : p.label.contains("(ms)") ? "ms" : "")
func signed(_ s: String, _ x: Float) -> String { p.min < 0 && x > 0 ? "+" + s : s }
if p.isInt { return signed("\(roundToInt(v))", v) + u }
if timeKeys.contains(p.key) && p.max > 1 {
if v < 1 { return "\(roundToInt(v * 1000))ms" }
return String(format: v < 10 ? "%.2fs" : "%.1fs", v)
}
if !u.isEmpty {
let f = (u == "ms" || u == "ct" || abs(v) >= 100) ? "%.0f" : (u == "Hz" || u == "×") ? "%.2f" : "%.1f"
return signed(String(format: f, v), v) + u
}
if p.min == 0 && p.max == 1 { return "\(roundToInt(v * 100))%" }
if p.min == -1 && p.max == 1 { return signed("\(roundToInt(v * 100))", v) + "%" }
return signed(String(format: "%.2f", v), v)
}
}
+57
View File
@@ -0,0 +1,57 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
import Foundation
/// A device editor's tabs and cards, as Android's DeviceLayouts describes them
/// (exported to DeviceLayouts.json by IosGoldenExport) or, for devices whose
/// Android editor is hand-built, as BespokeLayouts.swift lays them out.
struct LayoutPage: Decodable, Identifiable {
let title: String
let panels: [LayoutPanel]
var id: String { title }
}
struct LayoutPanel: Decodable, Identifiable {
enum Tone: String, Decodable { case SOURCE, FILTER, ENV, MOD, OUT }
struct Viz: Decodable {
let kind: String // envelope | filter | lfo | wavetable
var a: String? = nil, d: String? = nil, s: String? = nil, r: String? = nil
var type: String? = nil, cutoff: String? = nil, reso: String? = nil
var wave: String? = nil
var osc: Int? = nil
}
let title: String
let tone: Tone
let keys: [String]
var viz: Viz? = nil
var labels: [String: String]? = nil
var faders: [String]? = nil
var faderScale: Float? = nil
var action: String? = nil
var id: String { title }
}
struct DeviceLayoutsFile: Decodable {
let devices: [String: [LayoutPage]]
let timeDivisions: [String]
let delayDivisions: [String]
}
enum Layouts {
/// Bundled with both the extension and the app (each finds its own copy).
static let file: DeviceLayoutsFile? = {
let bundle = Bundle(for: SizzleDeviceAU.self)
guard let url = bundle.url(forResource: "DeviceLayouts", withExtension: "json"),
let data = try? Data(contentsOf: url) else { return nil }
return try? JSONDecoder().decode(DeviceLayoutsFile.self, from: data)
}()
static func pages(for type: String, allKeys: [String]) -> [LayoutPage] {
if let bespoke = BespokeLayouts.pages[type] { return bespoke }
if let pages = file?.devices[type], !pages.isEmpty { return pages }
return [LayoutPage(title: type, panels: [LayoutPanel(title: type, tone: .SOURCE, keys: allKeys)])]
}
}
+97
View File
@@ -0,0 +1,97 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
import SwiftUI
/// The live drawing at the top of a card (Android's VizCanvas): an envelope's
/// shape, a filter's response, or two cycles of an LFO wave.
struct VizView: View {
let viz: LayoutPanel.Viz
let tone: Color
@ObservedObject var model: DeviceModel
private func num(_ key: String?) -> Float? {
guard let k = key, let p = model.params[k] else { return nil }
return Swift.min(p.max, Swift.max(p.min, model.value(k)))
}
private func frac(_ key: String?) -> Float? {
guard let k = key, let p = model.params[k], let v = num(k) else { return nil }
return (v - p.min) / (p.max - p.min)
}
var body: some View {
Canvas { ctx, size in
let w = size.width, h = size.height
let top = h * 0.12, bottom = h * 0.92
var path = Path()
switch viz.kind {
case "envelope":
let a = CGFloat(sqrt(frac(viz.a) ?? 0)) + 0.02
let d = viz.d != nil ? CGFloat(sqrt(frac(viz.d) ?? 0)) + 0.02 : 0
let s = viz.s != nil ? CGFloat(num(viz.s) ?? 1) : 1
let r = CGFloat(sqrt(frac(viz.r) ?? 0)) + 0.02
let hold: CGFloat = 0.45
let k = w / (a + d + hold + r)
let sy = bottom - (bottom - top) * s
path.move(to: CGPoint(x: 0, y: bottom))
path.addLine(to: CGPoint(x: a * k, y: top))
path.addLine(to: CGPoint(x: (a + d) * k, y: sy))
path.addLine(to: CGPoint(x: (a + d + hold) * k, y: sy))
path.addLine(to: CGPoint(x: w, y: bottom))
line(ctx, CGPoint(x: (a + d + hold) * k, y: top), CGPoint(x: (a + d + hold) * k, y: bottom))
case "filter":
let fc = Double(frac(viz.cutoff) ?? 0.5)
let q = 0.6 + Double(frac(viz.reso) ?? 0) * 9
let kind = viz.type.map { model.choice($0).uppercased().first ?? "L" } ?? "L"
for i in 0...96 {
let x = Double(i) / 96
let r = pow(2.0, (x - fc) * 10)
let den = sqrt(pow(1 - r * r, 2) + pow(r / q, 2))
let mag = kind == "H" ? r * r / den : kind == "B" ? (r / q) / den : 1 / den
let db = Swift.min(20, Swift.max(-30, 20 * log10(Swift.max(mag, 1e-4))))
let y = top + CGFloat((20 - db) / 50) * (bottom - top)
if i == 0 { path.move(to: CGPoint(x: 0, y: y)) } else { path.addLine(to: CGPoint(x: CGFloat(x) * w, y: y)) }
}
let zeroY = top + 20 / 50 * (bottom - top)
line(ctx, CGPoint(x: 0, y: zeroY), CGPoint(x: w, y: zeroY))
line(ctx, CGPoint(x: CGFloat(fc) * w, y: top), CGPoint(x: CGFloat(fc) * w, y: bottom))
case "lfo":
let name = viz.wave.map { model.choice($0).lowercased() } ?? "sine"
let sh: [CGFloat] = [0.6, -0.3, 0.9, -0.8, 0.2, -0.5, 0.75, -0.1]
for i in 0...160 {
let x = CGFloat(i) / 160
let p = (x * 2).truncatingRemainder(dividingBy: 1)
let v: CGFloat
if name.hasPrefix("tri") { v = 1 - 4 * abs(p - 0.5) }
else if name.hasPrefix("saw") { v = 1 - 2 * p }
else if name.hasPrefix("sq") { v = p < 0.5 ? 1 : -1 }
else if name.hasPrefix("s&h") || name.hasPrefix("sample") { v = sh[Swift.min(7, Int(x * 8))] }
else { v = sin(2 * .pi * p) }
let y = (top + bottom) / 2 - v * (bottom - top) / 2
if i == 0 { path.move(to: CGPoint(x: 0, y: y)) } else { path.addLine(to: CGPoint(x: x * w, y: y)) }
}
line(ctx, CGPoint(x: 0, y: (top + bottom) / 2), CGPoint(x: w, y: (top + bottom) / 2))
default:
return
}
if viz.kind != "lfo" {
var fill = path
fill.addLine(to: CGPoint(x: w, y: h))
fill.addLine(to: CGPoint(x: 0, y: h))
fill.closeSubpath()
ctx.fill(fill, with: .color(tone.opacity(0.15)))
}
ctx.stroke(path, with: .color(tone), lineWidth: 2)
}
.frame(height: 56)
.background(Theme.background)
.overlay(Rectangle().stroke(Theme.grid, lineWidth: 1))
}
private func line(_ ctx: GraphicsContext, _ a: CGPoint, _ b: CGPoint) {
var p = Path()
p.move(to: a)
p.addLine(to: b)
ctx.stroke(p, with: .color(Theme.grid), lineWidth: 1)
}
}
+7
View File
@@ -31,6 +31,13 @@ NS_ASSUME_NONNULL_BEGIN
/// Formats a parameter value the way Sizzle's editor does (units, %, choices).
- (NSString *)stringForParameter:(AUParameter *)param value:(AUValue)value;
/// The parameter's default (Android's ParamSpec.default; a choice index for lists).
- (AUValue)defaultValueForParameter:(AUParameter *)param;
/// Whether the parameter takes whole numbers only.
- (BOOL)isIntegerParameter:(AUParameter *)param;
/// Its label in Sizzle's spec, e.g. "Osc1 Level", "Wet (dB)" (displayName is the same).
- (NSString *)specLabelForParameter:(AUParameter *)param;
@end
NS_ASSUME_NONNULL_END
+16
View File
@@ -144,6 +144,22 @@ static NSString *const kStateKey = @"sizzleValues";
return [NSString stringWithFormat:@"%.2f", value];
}
- (AUValue)defaultValueForParameter:(AUParameter *)param {
if (param.address >= (AUParameterAddress)_k->spec->paramCount) return 0;
return _k->spec->params[param.address].def;
}
- (BOOL)isIntegerParameter:(AUParameter *)param {
if (param.address >= (AUParameterAddress)_k->spec->paramCount) return NO;
const ParamSpec &s = _k->spec->params[param.address];
return s.isInt || s.isEnum();
}
- (NSString *)specLabelForParameter:(AUParameter *)param {
if (param.address >= (AUParameterAddress)_k->spec->paramCount) return @"";
return @(_k->spec->params[param.address].label);
}
#pragma mark - presets and state
- (void)buildFactoryPresets {
+23 -158
View File
@@ -2,31 +2,26 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// The extension's principal class: the factory for every device listed in
// components.txt (picked by subtype; instruments and effects) and a generic editor
// for its parameters
// (sliders, segmented switches for short choice lists, menus for long ones).
// The card-style editors of the Android app come later; this keeps every
// parameter reachable meanwhile.
// components.txt (picked by subtype; instruments and effects), and its editor:
// the SwiftUI card editor (Editor/DeviceEditor.swift), as in the Android app.
// The app hosts the same editor for the devices it plays itself.
#import <CoreAudioKit/CoreAudioKit.h>
#import <UIKit/UIKit.h>
#import "Components.gen.h"
#import "SizzleFXViewController.h"
static UIColor *Amber(void) { return [UIColor colorWithRed:0.96 green:0.76 blue:0.29 alpha:1]; }
static UIColor *Dim(void) { return [UIColor colorWithWhite:0.62 alpha:1]; }
// The Swift side's generated header: named after the target that compiles this file.
#if __has_include("SizzleFX-Swift.h")
#import "SizzleFX-Swift.h"
#else
#import "Sizzle-Swift.h"
#endif
@implementation SizzleFXViewController {
SizzleDeviceAU *_au;
UIStackView *_stack;
NSMutableDictionary<NSNumber *, UIControl *> *_controls;
NSMutableDictionary<NSNumber *, UILabel *> *_valueLabels;
AUParameterObserverToken _token;
BOOL _built;
}
#pragma mark - factory
- (AUAudioUnit *)createAudioUnitWithComponentDescription:(AudioComponentDescription)desc error:(NSError **)error {
_au = [[[SizzleDeviceAU classForComponentType:desc.componentType] alloc]
initWithComponentDescription:desc options:0 error:error];
@@ -39,158 +34,28 @@ static UIColor *Dim(void) { return [UIColor colorWithWhite:0.62 alpha:1]; }
[self buildIfReady];
}
#pragma mark - view
- (void)viewDidLoad {
[super viewDidLoad];
self.preferredContentSize = CGSizeMake(520, 420);
self.preferredContentSize = CGSizeMake(560, 460);
self.view.backgroundColor = [UIColor colorWithRed:0.07 green:0.08 blue:0.09 alpha:1];
UIScrollView *scroll = [UIScrollView new];
scroll.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:scroll];
_stack = [UIStackView new];
_stack.axis = UILayoutConstraintAxisVertical;
_stack.spacing = 10;
_stack.translatesAutoresizingMaskIntoConstraints = NO;
[scroll addSubview:_stack];
UILayoutGuide *g = self.view.safeAreaLayoutGuide;
[NSLayoutConstraint activateConstraints:@[
[scroll.leadingAnchor constraintEqualToAnchor:g.leadingAnchor],
[scroll.trailingAnchor constraintEqualToAnchor:g.trailingAnchor],
[scroll.topAnchor constraintEqualToAnchor:g.topAnchor],
[scroll.bottomAnchor constraintEqualToAnchor:g.bottomAnchor],
[_stack.leadingAnchor constraintEqualToAnchor:scroll.contentLayoutGuide.leadingAnchor constant:14],
[_stack.trailingAnchor constraintEqualToAnchor:scroll.contentLayoutGuide.trailingAnchor constant:-14],
[_stack.topAnchor constraintEqualToAnchor:scroll.contentLayoutGuide.topAnchor constant:12],
[_stack.bottomAnchor constraintEqualToAnchor:scroll.contentLayoutGuide.bottomAnchor constant:-12],
[_stack.widthAnchor constraintEqualToAnchor:scroll.frameLayoutGuide.widthAnchor constant:-28],
]];
[self buildIfReady];
}
- (UILabel *)label:(NSString *)text size:(CGFloat)size color:(UIColor *)color {
UILabel *l = [UILabel new];
l.text = text;
l.font = [UIFont monospacedSystemFontOfSize:size weight:UIFontWeightRegular];
l.textColor = color;
return l;
}
- (void)buildIfReady {
if (_built || !_au || !_stack) return;
if (_built || !_au || !self.isViewLoaded) return;
_built = YES;
_controls = [NSMutableDictionary dictionary];
_valueLabels = [NSMutableDictionary dictionary];
[_stack addArrangedSubview:[self label:_au.displayName.uppercaseString size:15 color:Amber()]];
if (_au.factoryPresets.count > 0) {
UIButton *presets = [UIButton buttonWithType:UIButtonTypeSystem];
[presets setTitle:@"PRESET ▾" forState:UIControlStateNormal];
presets.titleLabel.font = [UIFont monospacedSystemFontOfSize:13 weight:UIFontWeightRegular];
presets.tintColor = Amber();
presets.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
NSMutableArray<UIAction *> *items = [NSMutableArray array];
__weak SizzleDeviceAU *au = _au;
__weak UIButton *weakButton = presets;
for (AUAudioUnitPreset *p in _au.factoryPresets) {
[items addObject:[UIAction actionWithTitle:p.name image:nil identifier:nil handler:^(UIAction *a) {
au.currentPreset = p;
[weakButton setTitle:[NSString stringWithFormat:@"PRESET: %@ ▾", p.name] forState:UIControlStateNormal];
}]];
}
presets.menu = [UIMenu menuWithChildren:items];
presets.showsMenuAsPrimaryAction = YES;
[_stack addArrangedSubview:presets];
}
for (AUParameter *p in _au.parameterTree.allParameters) [self addRowFor:p];
__weak SizzleFXViewController *weakSelf = self;
_token = [_au.parameterTree tokenByAddingParameterObserver:^(AUParameterAddress address, AUValue value) {
dispatch_async(dispatch_get_main_queue(), ^{ [weakSelf show:address value:value]; });
}];
}
- (void)addRowFor:(AUParameter *)p {
NSNumber *addr = @(p.address);
UIStackView *head = [UIStackView new];
head.axis = UILayoutConstraintAxisHorizontal;
[head addArrangedSubview:[self label:p.displayName.uppercaseString size:11 color:Dim()]];
UILabel *value = [self label:[_au stringForParameter:p value:p.value] size:11 color:UIColor.whiteColor];
value.textAlignment = NSTextAlignmentRight;
[head addArrangedSubview:value];
_valueLabels[addr] = value;
UIControl *control;
NSArray<NSString *> *choices = p.valueStrings;
NSUInteger chars = [[choices componentsJoinedByString:@""] length];
__weak SizzleFXViewController *weakSelf = self;
if (choices.count > 0 && choices.count <= 6 && chars <= 34) {
UISegmentedControl *seg = [[UISegmentedControl alloc] initWithItems:choices];
seg.selectedSegmentIndex = (NSInteger)lroundf(p.value);
seg.selectedSegmentTintColor = Amber();
[seg addAction:[UIAction actionWithHandler:^(UIAction *a) {
[weakSelf set:p value:(AUValue)seg.selectedSegmentIndex];
}] forControlEvents:UIControlEventValueChanged];
control = seg;
} else if (choices.count > 0) {
UIButton *b = [UIButton buttonWithType:UIButtonTypeSystem];
b.tintColor = Amber();
b.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
NSMutableArray<UIAction *> *items = [NSMutableArray array];
[choices enumerateObjectsUsingBlock:^(NSString *name, NSUInteger i, BOOL *stop) {
[items addObject:[UIAction actionWithTitle:name image:nil identifier:nil handler:^(UIAction *a) {
[weakSelf set:p value:(AUValue)i];
}]];
}];
b.menu = [UIMenu menuWithChildren:items];
b.showsMenuAsPrimaryAction = YES;
[b setTitle:[NSString stringWithFormat:@"%@ ▾", choices[(NSUInteger)lroundf(p.value)]] forState:UIControlStateNormal];
control = b;
} else {
UISlider *s = [UISlider new];
s.minimumValue = p.minValue;
s.maximumValue = p.maxValue;
s.value = p.value;
s.minimumTrackTintColor = Amber();
BOOL isInt = p.unit == kAudioUnitParameterUnit_Indexed;
[s addAction:[UIAction actionWithHandler:^(UIAction *a) {
AUValue v = isInt ? roundf(s.value) : s.value;
[weakSelf set:p value:v];
}] forControlEvents:UIControlEventValueChanged];
control = s;
}
_controls[addr] = control;
UIStackView *row = [[UIStackView alloc] initWithArrangedSubviews:@[head, control]];
row.axis = UILayoutConstraintAxisVertical;
row.spacing = 4;
[_stack addArrangedSubview:row];
}
- (void)set:(AUParameter *)p value:(AUValue)v {
[p setValue:v originator:_token];
[self show:p.address value:v];
}
- (void)show:(AUParameterAddress)address value:(AUValue)value {
AUParameter *p = [_au.parameterTree parameterWithAddress:address];
if (!p) return;
_valueLabels[@(address)].text = [_au stringForParameter:p value:value];
UIControl *c = _controls[@(address)];
if ([c isKindOfClass:[UISlider class]]) {
if (!c.isTracking) ((UISlider *)c).value = value;
} else if ([c isKindOfClass:[UISegmentedControl class]]) {
((UISegmentedControl *)c).selectedSegmentIndex = (NSInteger)lroundf(value);
} else if ([c isKindOfClass:[UIButton class]] && p.valueStrings.count) {
NSUInteger i = MIN((NSUInteger)lroundf(value), p.valueStrings.count - 1);
[(UIButton *)c setTitle:[NSString stringWithFormat:@"%@ ▾", p.valueStrings[i]] forState:UIControlStateNormal];
}
}
- (void)dealloc {
if (_token && _au) [_au.parameterTree removeParameterObserver:_token];
UIViewController *editor = [SizzleEditorFactory makeEditorFor:_au];
[self addChildViewController:editor];
editor.view.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:editor.view];
UILayoutGuide *g = self.view.safeAreaLayoutGuide;
[NSLayoutConstraint activateConstraints:@[
[editor.view.leadingAnchor constraintEqualToAnchor:g.leadingAnchor],
[editor.view.trailingAnchor constraintEqualToAnchor:g.trailingAnchor],
[editor.view.topAnchor constraintEqualToAnchor:g.topAnchor],
[editor.view.bottomAnchor constraintEqualToAnchor:g.bottomAnchor],
]];
[editor didMoveToParentViewController:self];
}
@end
+3
View File
@@ -41,6 +41,7 @@ targets:
PRODUCT_BUNDLE_IDENTIFIER: cc.tiredsysadmin.ios.sizzle.fx
CODE_SIGN_ENTITLEMENTS: FX/FX.entitlements
INFOPLIST_FILE: FX/Info.plist
SWIFT_OBJC_BRIDGING_HEADER: FX/Bridging.h
# force_load: the effects are found through weak placeholder makers (Registry.cpp),
# so without it the linker keeps the placeholders and skips the real ports.
OTHER_LDFLAGS: ["-lc++", "-force_load", "$(BUILT_PRODUCTS_DIR)/libSizzleCore.a"]
@@ -59,6 +60,8 @@ targets:
- FX/SizzleEffectAU.mm
- FX/SizzleInstrumentAU.mm
- FX/SizzleFXViewController.mm
- FX/Editor
- FX/DeviceLayouts.json
dependencies:
- target: SizzleFX
embed: true
+2
View File
@@ -0,0 +1,2 @@
#import "SizzleDeviceAU.h"
#import "SnapshotComponents.h"
+20
View File
@@ -0,0 +1,20 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// components.txt for the Swift snapshot tool (editor_snapshots.swift).
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface SizzleComponentInfo : NSObject
@property (nonatomic) OSType type;
@property (nonatomic) OSType subtype;
@property (nonatomic, copy) NSString *name;
@end
@interface SizzleComponentList : NSObject
+ (NSArray<SizzleComponentInfo *> *)all;
@end
NS_ASSUME_NONNULL_END
+22
View File
@@ -0,0 +1,22 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
#import "SnapshotComponents.h"
#import "Components.gen.h"
@implementation SizzleComponentInfo
@end
@implementation SizzleComponentList
+ (NSArray<SizzleComponentInfo *> *)all {
NSMutableArray *list = [NSMutableArray array];
for (int i = 0; i < kSizzleComponentCount; ++i) {
SizzleComponentInfo *c = [SizzleComponentInfo new];
c.type = kSizzleComponents[i].type;
c.subtype = kSizzleComponents[i].subtype;
c.name = @(kSizzleComponents[i].name);
[list addObject:c];
}
return list;
}
@end
+39
View File
@@ -0,0 +1,39 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// Renders every device's editor (each tab) to PNG on the Mac, to look at the
// layouts without a device: `make -C ios editor-snapshots` → build/snapshots/png/.
import AppKit
import AudioToolbox
import SwiftUI
@main
struct EditorSnapshots {
@MainActor static func main() {
DeviceEditor.snapshot = true
let out = URL(fileURLWithPath: CommandLine.arguments.count > 1 ? CommandLine.arguments[1] : "png")
try? FileManager.default.createDirectory(at: out, withIntermediateDirectories: true)
for c in SizzleComponentList.all() {
let desc = AudioComponentDescription(componentType: c.type, componentSubType: c.subtype,
componentManufacturer: 0x5473_7973, componentFlags: 0, componentFlagsMask: 0)
guard let cls = SizzleDeviceAU.class(forComponentType: c.type) as? SizzleDeviceAU.Type,
let au = try? cls.init(componentDescription: desc, options: []) else { print("FAIL \(c.name)"); continue }
let model = DeviceModel(au: au)
let pages = Layouts.pages(for: au.toolboxType, allKeys: model.order)
for (i, page) in pages.enumerated() {
let view = DeviceEditor(model: model, page: i)
.frame(width: 560)
.fixedSize(horizontal: false, vertical: true)
.environment(\.colorScheme, .dark)
let r = ImageRenderer(content: view)
r.scale = 2
guard let img = r.cgImage else { print("FAIL render \(c.name)"); continue }
let rep = NSBitmapImageRep(cgImage: img)
let name = "\(au.toolboxType)_\(i)_\(page.title.replacingOccurrences(of: " ", with: "_")).png"
try? rep.representation(using: .png, properties: [:])?.write(to: out.appendingPathComponent(name))
print("wrote \(name)")
}
}
}
}
+2 -2
View File
@@ -17,8 +17,8 @@ android.versionCode = 70
# iOS/iPadOS (cc.tiredsysadmin.ios.sizzle): the AUv3 plugin app in ios/app; the
# Makefile there passes these to Xcode and names the .ipa by versionCode. (The
# TrollStore spike in ios/spike keeps its own version in its project.yml.)
ios.versionName = 0.2.1
ios.versionCode = 5
ios.versionName = 0.3.0
ios.versionCode = 6
macos.versionName = -
linux.versionName = -
bsd.versionName = -