iOS 0.3.1: engine, model and file formats in C++, verified against Kotlin; longer settings

Engine (sequencer, mixer, FX chains, MIDI effects) renders four whole songs like
AudioEngine.kt (two bit-exact, two within 9e-6). ProjectIo / SngFormat / PresetIo
round-trip the Kotlin-written files; Float.toString is JDK 17's, checked on all
2^32 floats. Params now holds 255-character values (sample ids were cut).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Reactorcoremeltdown
2026-11-16 01:50:51 +01:00
co-authored by Claude Opus 5.5
parent b1dc5ed8db
commit 7bc54e6466
20 changed files with 3746 additions and 41 deletions
+29
View File
@@ -84,6 +84,35 @@ All fourteen together come to about 38% of one core; the A8 has two. The C++ DSP
cheap enough for the whole suite on this iPad. What made AUM struggle with a few
AUv3s is the per-plugin process round trip, which the in-app host avoids.
- 2026-11-15: the engine (`core/src/engine`, `sizzle::engine::Engine`): AudioEngine.kt's
sequencer, arrangement playlist with loop regions, note-offs, arpeggiator,
transposer, MIDI LFO, mixer, FX chains and master limiter. `core/tests/engine_test`
renders the four reference songs (demo, mix, waltz, midifx) and matches Kotlin
(demo and midifx bit for bit; mix and waltz within 1e-5, from the Tape Engine's
known one-ulp difference fed through the rest of the song). Not ported: audio
output (the app calls `fillBlock`), WAV writing (`MasterSink`), CoreMIDI (the
engine fills the outgoing queue, `pollMidiOut`), effect scope/playhead views.
Decisions: the voice pools are built in AudioEngine's field order from
`EngineGlobals` (clock and seed counters); swapped FX chains and playlists are
freed by a later main-thread rebuild once the audio thread has finished a block;
the live note calls touch voices directly like the Kotlin, so the app must call
them on the audio thread (or serialise them with it). The MIDI LFO writes its
value into the target slot as text every block, like Kotlin; that goes through
`kotlinFloatToChars` (no allocation).
- 2026-11-16: file formats (`core/src/io`, `sizzle::io`): `ProjectIo` (.szg),
`SngFormat` (.sng) and `PresetIo` (.szp), ported from io/*.kt with Kotlin's
string semantics (`io/KotlinText`: lineSequence, Unicode trim, toIntOrNull with
Unicode digits, toFloatOrNull with Java's parseFloat grammar). `core/tests/io_test`
re-writes every reference file byte for byte, except [TOOLBOX] pairs (Kotlin
writes ConcurrentHashMap order; compared as sets), and checks .szg -> .sng / .szp.
`model::kotlinFloatToString` is JDK 17's FloatingDecimal ported line for line and
was compared with JDK 17.0.14 on all 2^32 float bit patterns. Kotlin's own lossy
spots, kept as is: PresetIo.import drops NAME (fill() overwrites it); a .sng
`track` channel comes from the mixer, which import leaves alone; names with `;`,
values with `,` or `=` break a [TOOLBOX] line. `Params` caps keys at 23 bytes,
values at 31 and slots at 96 keys, so a long sample path would be cut short.
Notes for the engine port (from the voice ports):
- Kotlin seeds every new FrasilVoice and GrainCloud from global counters, and every
SynthVoice builds a FrasilVoice. The C++ engine owns one `frasil::FrasilSeeds`,