iOS 0.1.0: the eight audio effects as AUv3 plugins on a C++ core

C++ ports of the Kotlin effects, checked against audio the Kotlin code renders
(25 scenarios, IosGoldenExport); an Objective-C++ AUv3 wrapper checked on the
Mac against the core (parameters, presets, saved state); a container app that
checks each plugin on the device. Built as a TrollStore .ipa.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Reactorcoremeltdown
2026-11-14 20:47:06 +01:00
co-authored by Claude Opus 5.5
parent c9ad186de1
commit dcf85ba915
44 changed files with 3542 additions and 127 deletions
+139 -79
View File
@@ -1,97 +1,157 @@
# Sizzle for iOS/iPadOS — staging tree
# Sizzle for iOS/iPadOS
This tree is separate from the Android app (its own Makefile, nothing shared yet).
The plan is to ship every Sizzle instrument and effect as AUv3 plugins inside one
app (iOS/iPadOS 15+), installed with TrollStore. Before porting anything, the
**spike** in `spike/` answers the one question that could sink the plan: do hosts
(AUM, GarageBand, Loopy…) list AUv3 plugins from a TrollStore-installed app, and do
App Groups work there?
Sizzle's instruments and effects as AUv3 plugins for hosts such as AUM, GarageBand
and Loopy, in one app (`cc.tiredsysadmin.ios.sizzle`, iOS/iPadOS 15+) installed
with TrollStore. This tree is separate from the Android app and has its own
Makefile (`make -C ios help`).
## The spike
| Piece | What it is |
| Path | What it is |
|---|---|
| `spike/project.yml` | XcodeGen spec; `make project` generates the Xcode project (git-ignored) |
| `spike/App/` | SwiftUI host app `cc.tiredsysadmin.ios.sizzlespike` with a self-test (Run self-test button) |
| `spike/AU/` | App extension `…sizzlespike.au`: one AUv3 instrument (`aumu` / `sSpk` / `Tsys`), "Tired Sysadmin: Sizzle Spike Sine", a sine voice with a Gain parameter |
| `spike/Shared/Spike.swift` | The App Group id, the component description, and the App Group probe both sides run |
| `core/` | The C++ DSP core: a port of the Android app's Kotlin DSP |
| `core/include/sizzle/DeviceSpecs.gen.hpp` | Every device's parameters, generated from `ToolboxType` (Kotlin) |
| `core/tests/golden_test.cpp` | Compares the core with audio the Kotlin code renders |
| `app/components.txt` | The plugin list (AU type, subtype, device, name) |
| `app/FX/` | The effects extension: `SizzleEffectAU` (the AUv3) and `SizzleFXViewController` (factory + editor) |
| `app/Host/` | The container app: lists the plugins, checks each one on the device |
| `app/tests/au_test.mm` | Mac-side test of the AUv3 wrapper |
| `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) |
The self-test shows three checks:
Versions: `ios.versionName` / `ios.versionCode` in `../versions.properties`
(`make -C ios bump-minor` etc.); the .ipa is named by versionCode. Changes are
listed in `CHANGELOG.md` here.
1. **[1] Registered components:** what `AVAudioUnitComponentManager` lists for
`Tsys/sSpk`. That is the same registry hosts read, so a FAIL here means no host
will see the plugin.
2. **[2] Instantiated out of process / Rendered 1 s offline:** iOS launches the
extension and its render block produces sound (silent, offline render; peak > 0.05).
"Play tone (1 s)" does the same through the speaker.
3. **[3] App Group:** the app writes `app.txt`, the extension writes `au.txt` when it is
created (and `au-view.txt` when a host opens its view), and each side lists what's
there. After [2], seeing `au.txt` in the app's list proves both sides share files,
which is how the real port will hand samples and SF2 files to the plugins.
## How the port is verified
The Kotlin DSP is the reference. `make golden` runs `IosGoldenExport` (a JVM unit
test in the Android app, skipped by the normal `make check`), which:
- writes `DeviceSpecs.gen.hpp`, so iOS uses the same parameter definitions
(keys, labels, ranges, defaults, choices) and the Mix Tightener presets;
- renders a fixed 1.5 s test signal (decaying saw burst, noise, sine sweep,
silences for tails) through every effect at its defaults and two variants that
move every parameter (the Mix Tightener uses three of its presets instead), into
`core/golden/` (not committed; regenerate any time).
`make core-test` renders the same scenarios through the C++ core and requires a
largest difference below 1e-4. Today all 25 pass; most are bit-exact, the rest
differ by about one float ulp. Porting rules that make this possible:
- translate line for line, keeping Kotlin's types: `Float` → `float`,
`Double` → `double`, so every expression runs in the same precision;
- `kotlin.math` on a Float goes through Java's double `Math` and rounds back:
use the helpers in `core/src/fx/KotlinMath.hpp` (`roundToInt` is floor(x+0.5),
`toInt` truncates and saturates);
- Kotlin `Int` wraps and `ushr` is a logical shift: use `uint32_t` for the
xorshift generators;
- settings are text, as in `ToolboxSlot`: `Params::f()` / `Params::s()` read
exactly what `slot.float()` / `slot.string()` would.
Known gap: the Tape Delay "low" variant switches all four heads off (on-values
below 0.5), so it only tests the dry path; add a scenario with heads on.
`make au-test` then checks the AUv3 wrapper on the Mac (AUAudioUnit exists on
macOS): every effect is registered in-process and driven through AVAudioEngine.
The output must equal the core's at defaults and after moving every parameter
through the AU, a Mix Tightener factory preset must equal the core with that
preset, and `fullState` must restore into a fresh instance. All pass bit-exact.
## The plugins (0.1.0: the eight audio effects)
All eight are `aufx` plugins from one extension (`SizzleFX.appex`), manufacturer
`Tsys`, named "Tired Sysadmin: Sizzle <device>". The extension's factory picks
the device by subtype; subtypes are in `app/components.txt` and must never change
once shipped, since hosts save projects by them.
`SizzleEffectAU` (Objective-C++, no Swift on the audio path):
- **Parameters** come from the generated specs: address = index in the device's
parameter list; choices become indexed parameters with value strings; whole
numbers use the indexed unit.
- **Stereo:** the Kotlin effects are mono (Sizzle's mixer is mono), so each
channel runs its own instance (dual mono). Mono and stereo buses are accepted.
- **Threads:** AU parameter changes (host, automation events, the editor) go into
one atomic float per parameter. Whole settings (presets, restored state,
hidden keys such as the Mix Tightener's) go through a two-slot mailbox. The
render thread copies, overlays the parameter values, and calls
`Effect::update` only when something changed or the host tempo moved. No locks
on the audio thread. (Applying changes formats and parses text with
`snprintf`/`strtof` on the audio thread, only when something changed; a
numeric fast path can replace that later.)
- **Tempo** comes from the host's musical context (120 BPM without one), for the
tempo-synced Delay and Tape Engine.
- **Presets:** the Mix Tightener's factory presets are AU factory presets; user
presets use the AU's `fullState`, which stores every key as text
(`sizzleValues`), hidden ones included.
- **Bypass** passes the input through; non-finite output samples are zeroed.
The editor is generic for now (sliders, segmented switches for short choice
lists, menus for long ones, a preset menu); the card editors of the Android app
come later.
The container app lists the registered plugins, and **Check all plugins** loads
each one out of process (as a host does), renders a test signal offline and
reports PASS (finite, not silent) or FAIL.
### Build
```sh
make -C ios ipa # → ios/dist/cc.tiredsysadmin.ios.sizzlespike_<build>.ipa
make -C ios ipa # → ios/dist/cc.tiredsysadmin.ios.sizzle_<versionCode>.ipa
make -C ios core-test # C++ core vs Kotlin reference
make -C ios au-test # the AUv3 wrapper on the Mac
```
Needs Xcode and XcodeGen. The device build is unsigned, then ad-hoc signed inside-out
(extension first) with each target's entitlements, and zipped as `Payload/`.
TrollStore re-signs at install time and keeps the entitlements it finds; ldid
isn't needed. Checked on the Mac: arm64, minimum OS 15.0 for the app and the
extension, App Group entitlement on both, extension entry point `NSExtensionMain`,
extension point `com.apple.AudioUnit-UI`.
The device build is unsigned, then ad-hoc signed inside-out (extension first)
with each target's entitlements and zipped as `Payload/`. TrollStore re-signs at
install and keeps the entitlements.
`make sim` / `make sim-run` build and run it in the Simulator, but no Simulator
runtime was installed when the spike was written, so it hasn't been run there.
The extension links the core with `-force_load`: effect makers are found through
weak placeholders in `Registry.cpp` (so the core test can link before every port
exists), and from a static library the linker would otherwise keep the
placeholders and leave the real ports out. That happened once; the symptom would
have been every plugin failing to start.
### Test on the iPad
1. AirDrop or copy the newest `cc.tiredsysadmin.ios.sizzlespike_<build>.ipa` to the
iPad, open it with TrollStore, install.
2. Open **Sizzle Spike**, tap **Run self-test**, and note [1]–[3] (screenshot).
3. In AUM (or GarageBand → Audio Units, Loopy, Drambo…), add an instrument and look
for **Tired Sysadmin: Sizzle Spike Sine**. Load it, play notes, open its view (it
lists the App Group files).
4. Back in Sizzle Spike, **Run self-test** again: `au-view.txt` should now be listed.
What the outcomes mean:
- [1] PASS and the host lists it: the plan works as designed.
- [1] PASS but no host lists it: hosts filter TrollStore apps somehow; investigate
before porting.
- [1] FAIL: iOS didn't register the extension (pluginkit); try re-launching the app,
then a respring, then reinstall.
- [3] NOT AVAILABLE: App Groups don't survive TrollStore signing. The fallback is
passing sample data through the plugin's saved state, or having the plugin
pick files with a document picker.
### Results so far
- **Build 1 (0.1.0):** AUM lists the plugin, loads it, and it plays from a MIDI
keyboard, so hosts do see AUv3 plugins from a TrollStore install. AUM showed a
red X as its icon (the app had no icon), and the app itself closed right after
opening (it ran the self-test at launch).
- **Build 2 (0.1.1):** adds an app icon, the SwiftUI scene manifest, and makes the
self-test crash-proof for diagnosis. It runs only on the button. Each step is
saved before it runs, so the next launch says where a crash happened
("The previous run stopped during: …"). AVAudioEngine's Objective-C exceptions
are caught by `App/ObjC/SPKTry.m` and printed instead of killing the app.
If the app still closes before showing anything, the crash is at launch. Its log
is in Settings → Privacy & Security → Analytics & Improvements → Analytics Data,
in a file named `SizzleSpike-<date>.ips`.
1. Install the newest `cc.tiredsysadmin.ios.sizzle_<n>.ipa` with TrollStore.
2. Open **Sizzle**, tap **Check all plugins**: 8/8 should pass.
3. In AUM, add an audio track or a synth, then an effect slot: the plugins are
listed as "Tired Sysadmin: Sizzle …". Try the editor, a Mix Tightener preset,
and saving and reopening an AUM session (restores `fullState`).
## Decisions
- **XcodeGen, not a checked-in .xcodeproj:** the project is text you can diff and
review; the generated project is git-ignored.
- **Swift render block in the spike:** good enough for one sine voice (no allocation
or locks in the render block). The real port puts the DSP in a C++ core (see the
conversation that planned it: Kotlin DSP → C++ verified against reference audio
rendered by the Kotlin code).
- **One extension, factory dispatch:** the real port will list many
`AudioComponents` in one or a few extensions and pick the unit in
`createAudioUnit(with:)` by subtype, instead of one extension per device.
- **Versions:** the spike's version lives in `spike/project.yml`
(`MARKETING_VERSION` 0.1.0, `CURRENT_PROJECT_VERSION` 1, which names the .ipa).
- **C++ core, not Kotlin/Native:** an AUv3 render callback must not allocate,
lock or wait for a garbage collector; plain C++ with preallocated state meets
that, and can later replace the Kotlin DSP on Android through JNI.
- **Reference audio instead of reading the code twice:** the Kotlin output is the
specification, so ports can be done by anyone (including parallel agents) and
checked mechanically.
- **XcodeGen:** projects are text (`app/project.yml`); generated projects are
git-ignored. Generated sources that iOS needs to build without the Android
toolchain (`DeviceSpecs.gen.hpp`, `FX/Info.plist`, `Components.gen.h`) are
committed.
- **One extension, factory dispatch** instead of one extension per device.
- **Generic editor first:** every parameter is reachable now; the card editors
(tabs, knobs, drawings) are a separate step.
## Next steps
1. Instruments (Synth, Wavetable, Morph Pad, Grain Cloud, Sampler, SF2/XI) as
`aumu` plugins, through the same reference-audio route (the export will need
note scripts, not just an input signal).
2. MIDI effects (Arpeggiator, Transposer, LFO) as `aumi` plugins.
3. The card editors in SwiftUI from the `DeviceLayouts` data.
4. Sample and SF2 files through the App Group (`group.cc.tiredsysadmin.ios.sizzle`).
## The TrollStore spike (spike/)
A host app with one sine AUv3 instrument and an App Group self-test, built to check
feasibility before porting (`make -C ios spike-ipa`).
- **Build 1:** AUM listed the plugin, loaded it and played it from a MIDI
keyboard, so hosts do see AUv3 plugins from a TrollStore install. The app
closed right after opening, and AUM showed a red X instead of an icon.
- **Build 2:** added an app icon (AUM's red X went away), the SwiftUI scene
manifest, and a crash-proof self-test on a button. Confirmed on the iPad: the
self-test works, the icon shows, sound works.