PORTING.md: native SwiftUI app on a C++ engine verified against Kotlin. IosGoldenInstruments renders note scripts through the Kotlin voices; the C++ runner plays the same scripts through TestVoice makers (weak placeholders until each port lands). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4.0 KiB
4.0 KiB
Porting Sizzle to iOS/iPadOS
The whole Android app (../app, ~20k lines of Kotlin) as a native iOS/iPadOS 15+
app. Target hardware includes the iPad mini 4 (A8, 2 GB RAM). Decided 2026-11-15:
- Interface: native, SwiftUI with UIKit where SwiftUI is too slow on an A8 (the tracker grid). Written fresh, following the Android screens.
- Engine, model and file formats: C++ in
core/, each part checked against the Kotlin app's own output (reference audio and reference files), like the effects in 0.1.x. Swift talks to the core through an Objective-C++ facade. - Plugins: the AUv3 extension keeps shipping Sizzle's devices to other hosts; the app itself hosts the same code in-process (no per-plugin process cost, no dependence on the system plugin registry).
The Kotlin app stays the reference. When it changes, the reference files are
regenerated (make -C ios golden) and the C++ follows.
Map: Android → iOS
| Android (Kotlin) | Lines | iOS | How it's checked |
|---|---|---|---|
audio/Effects.kt, AmbienceReverb.kt |
1,150 | core/src/fx (done in 0.1.0) |
reference audio per effect |
audio/SynthVoice.kt, SynthPatch.kt |
500 | core/src/synth |
reference audio per voice |
frasil/ (Morph Pad) |
950 | core/src/frasil |
reference audio per voice |
wavetable/ |
730 | core/src/wavetable |
reference audio per voice, table data |
echofield/, audio/GrainSources.kt (Grain Cloud) |
1,100 | core/src/echofield |
reference audio per voice |
audio/SampleVoice.kt, SampleStore.kt, SoundFontLoader.kt |
570 | core/src/sampler |
reference audio with generated samples / test SF2 |
model/ |
1,360 | core/src/model |
via file round trips and full-song renders |
audio/AudioEngine.kt (sequencer, mixer, routing, arp, clock) |
1,680 | core/src/engine |
full-song renders (samples/*.sng, generated songs) |
io/ (.sng, projects, presets, bundles, backups) |
1,800 | core/src/io |
Kotlin-written files parsed and re-written byte-identical |
input/ (MIDI in/out, clock, gamepad, key bindings) |
1,350 | CoreMIDI, GameController (Obj-C++/Swift) | unit tests on the parsers; on device |
playback/ (background service, sound module) |
430 | AVAudioSession, background audio | on device |
ui/ + AppViewModel |
8,000 | app/ SwiftUI |
on device / simulator screenshots |
Milestones
Each milestone ends with a build that runs on the iPad.
- Instruments in C++. Synth, Morph Pad, Wavetable, Grain Cloud, then Sampler
and SF2/XI, each matching Kotlin voice renders. Plus AUv3 instruments (
aumu) and the in-app host's first form: a device list with a keyboard, so each one can be played on the iPad and measured on the A8. - Model, files and engine. Project model, .sng / project / preset formats (byte-identical round trips with Kotlin-written files), and the sequencer and mixer engine (full-song renders match Kotlin). MIDI effects (arp, transposer, LFO) come with the engine.
- App shell and tracker. Tabs (Tracker, Mix, Toolbox, Setup), transport, pattern grid, arrangement roll, keyboards, song load/save. Audio through AVAudioEngine; background audio.
- Toolbox and mixer. Device editors (cards from the DeviceLayouts data, then the bespoke editors), presets, mixer with FX routing.
- Everything else. MIDI in/out and clock sync, gamepad and key bindings, recording, sample recorder, sharing/import, backups, themes, settings.
Rules for ports
- Translate line for line and keep Kotlin's types (
Float→float,Double→double); usecore/src/fx/KotlinMath.hppfor kotlin.math semantics;uint32_tfor xorshift; portjava.util.Randomexactly where it is seeded. - No allocation or locks on the audio path; allocate in constructors /
prepare. - A port is done when its reference scenarios pass (
make -C ios core-test). Never loosen the tolerance; find the precision difference instead. - Global Kotlin state (e.g.
FrasilClock) becomes explicit state passed in or owned by the engine, and the reference files record its starting value.