0.37.0 (71): one engine, one version for Android and iOS

- Three source trees: core/ (shared C++ engine, moved from ios/core),
  app/ (Android UI), ios/app/ (iOS UI)
- Android plays through core/ via JNI (EngineHost, jni_engine.cpp): the Oboe
  callback renders natively; the Kotlin model is mirrored as project text and
  applied as a diff, so playback continues through edits
- The Kotlin engine moves to the unit tests as ReferenceEngine (golden reference)
- Shared MasterRecorder in core/src/host, used by both apps; host_test
- versions.properties: one versionName/versionCode for both platforms,
  continuing Android's numbering (iOS 0.6.0/11 -> 0.37.0/71)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Reactorcoremeltdown
2026-11-16 14:49:46 +01:00
co-authored by Claude Opus 5.5
parent 64e21e0bcc
commit 2bc5cb1cbb
107 changed files with 2921 additions and 1880 deletions
+73
View File
@@ -0,0 +1,73 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// sizzle/Midi.hpp against the behaviour the Android unit tests pin down
// (MidiByteParserTest, MidiSoundModuleTest) and MidiClock's tempo follow.
#include "sizzle/Midi.hpp"
#include <cstdio>
#include <string>
#include <vector>
using namespace sizzle::midi;
static int failures = 0;
#define CHECK(c) do { if (!(c)) { std::printf("FAIL %s:%d %s\n", __FILE__, __LINE__, #c); ++failures; } } while (0)
struct Rec : NoteSink {
std::vector<std::string> log;
void busNoteOn(int ch, int n, int v) override { log.push_back("on " + std::to_string(ch) + " " + std::to_string(n) + " " + std::to_string(v)); }
void busNoteOff(int ch, int n) override { log.push_back("off " + std::to_string(ch) + " " + std::to_string(n)); }
};
int main() {
// ---- parser
std::vector<std::vector<int>> msgs;
std::vector<int> rt;
MidiByteParser p([&](int s, int a, int b) { msgs.push_back({s, a, b}); }, [&](int s) { rt.push_back(s); });
const uint8_t a[] = {0x90, 60, 100, 62, 90}; // running status
p.feed(a, sizeof a);
CHECK(msgs.size() == 2 && msgs[1] == (std::vector<int>{0x90, 62, 90}));
const uint8_t b1[] = {0x80, 60}, b2[] = {0xF8, 0}; // split + realtime inside
p.feed(b1, 2); p.feed(b2, 2);
CHECK(msgs.size() == 3 && msgs[2] == (std::vector<int>{0x80, 60, 0}) && rt == std::vector<int>{0xF8});
const uint8_t c[] = {0xC3, 5, 0xF0, 1, 2, 3, 0xF7, 7}; // program change, SysEx skipped, stray byte
p.feed(c, sizeof c);
CHECK(msgs.size() == 4 && msgs[3] == (std::vector<int>{0xC3, 5, 0}));
const uint8_t d[] = {0xF2, 1, 2, 64, 0xB0, 123, 0}; // system common cancels running status
msgs.clear(); p.feed(d, sizeof d);
CHECK(msgs.size() == 1 && msgs[0] == (std::vector<int>{0xB0, 123, 0}));
// ---- sound module
Rec r;
MidiSoundModule m(r);
std::vector<std::string> mirror;
m.listener = [&](bool on, int ch, int n, int) { mirror.push_back((on ? "+" : "-") + std::to_string(ch) + ":" + std::to_string(n)); };
m.sourceConnected(1); m.sourceConnected(2);
CHECK(m.onChannelMessage(1, 0x90, 60, 100));
CHECK(m.onChannelMessage(2, 0x91, 64, 80));
CHECK(m.onChannelMessage(1, 0x90, 60, 0)); // velocity 0 = off
CHECK(m.heldNotes(1).empty() && m.heldNotes(2).size() == 1);
CHECK(!m.onChannelMessage(1, 0xB0, 7, 100)); // other CCs are the caller's
m.onChannelMessage(1, 0x92, 70, 90);
CHECK(m.onChannelMessage(2, 0xB2, 123, 0)); // channel 3 off from any source
CHECK(m.heldNotes(1).empty());
r.log.clear();
m.sourceDisconnected(2); // releases its held note
CHECK(r.log == std::vector<std::string>{"off 2 64"} && m.sourceCount() == 1);
CHECK(mirror.front() == "+1:60" && mirror.back() == "-2:64");
// ---- clock follow: 24 pulses at 125 BPM = 20 ms each
ClockFollower f;
float bpm = 0; int starts = 0, stops = 0;
f.onTempo = [&](float b) { bpm = b; };
f.onTransport = [&](bool s) { s ? ++starts : ++stops; };
f.realtime(0xFA, 0);
for (int i = 0; i <= 24; ++i) f.realtime(0xF8, 1'000'000'000LL + i * 20'000'000LL);
f.realtime(0xFC, 0);
CHECK(starts == 1 && stops == 1 && bpm > 124.99f && bpm < 125.01f);
std::printf(failures ? "midi_test: %d failure(s)\n" : "midi_test: ok\n", failures);
return failures ? 1 : 0;
}