Files
sizzletracker-android/ios/README.md
T
ReactorcoremeltdownandClaude Opus 5.5 7f231c8f79 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>
2026-11-15 22:17:47 +01:00

192 lines
10 KiB
Markdown

# Sizzle for iOS/iPadOS
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`).
| Path | What it is |
|---|---|
| `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 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 |
| `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) |
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.
## 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. It also calls the
render block directly with an upstream that points the input buffers at its own
memory instead of filling the plugin's, with and without host output buffers.
All pass bit-exact.
That last check exists because AVAudioEngine in-process copies the input into the
plugin's buffers, but out of process (every real host on iOS) the input arrives
by pointer. 0.1.0 read its own buffers and was silent on the iPad while every Mac
test passed. Render code must read the input from the pulled AudioBufferList,
never from the buffers it offered.
## 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.sizzle_<versionCode>.ipa
make -C ios core-test # C++ core vs Kotlin reference
make -C ios au-test # the AUv3 wrapper on the Mac
```
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.
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.
### Open problem: plugin registration stopped on the test iPad (2026-11-14)
On the iPad mini 4 (iOS 15.8.8, TrollStore 2), iOS stopped registering AUv3
plugins from TrollStore-installed apps partway through the evening:
- 0.1.0 (fresh install) and 0.1.1 (update) registered: mediaserverd listed all 8
`Tsys` effects, and AUM saw them (log at 21:08:46).
- Installing 0.1.2 as an update (21:11:51): mediaserverd's AUExtensionScanner
logged "NSExtensions changed for com.apple.AudioUnit-UI … added 0, removed 8".
Since then no newly installed TrollStore AUv3 is added. That includes Sizzle
0.1.0 reinstalled fresh, the extension under a new bundle ID, and the spike
reinstalled, with System or User registration. The install itself works
(LaunchServices registers the app; the plugin's data container is created);
only the audio system never sees the components. A restart and TrollStore's
"Refresh App Registrations" didn't change it.
- The package is not the cause: 0.1.0 and 0.1.2 differ only in version numbers and code.
Not yet known: whether a fresh App Store AUv3 install still registers (i.e.
whether this is TrollStore-specific), and what state the 0.1.2 update left
behind. The effects' silence fix (0.1.1) and the crash-proof check (0.1.2) are
therefore not confirmed on the device yet.
### Test on the iPad
1. Install the newest `cc.tiredsysadmin.ios.sizzle_<n>.ipa` with TrollStore.
2. Open **Sizzle**, tap **Check all plugins**: 8/8 should pass. With the iPad on
USB, `idevicesyslog` (`brew install libimobiledevice`) shows the plugin
process as `SizzleFX` and the host side as `Sizzle(AudioToolboxCore)`;
`idevicecrashreport -k -e <dir>` copies crash reports without deleting them.
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
- **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.