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:
co-authored by
Claude Opus 5.5
parent
64e21e0bcc
commit
2bc5cb1cbb
@@ -0,0 +1,95 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// host::EngineHost: renders a song exactly as the bare engine does, and a synced
|
||||
// project text ends up as the engine's song without stopping playback.
|
||||
// argv[1]: the reference songs folder (core/golden/songs).
|
||||
|
||||
#include "host/EngineHost.hpp"
|
||||
#include "echofield/GrainSources.hpp"
|
||||
#include "io/ProjectIo.hpp"
|
||||
#include "wavetable/WaveTables.hpp"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
using namespace sizzle;
|
||||
|
||||
static int failures = 0;
|
||||
#define CHECK(c) do { if (!(c)) { std::printf("FAIL %s:%d %s\n", __FILE__, __LINE__, #c); ++failures; } } while (0)
|
||||
|
||||
static std::string readFile(const std::string &path) {
|
||||
std::ifstream f(path, std::ios::binary);
|
||||
std::stringstream ss;
|
||||
ss << f.rdbuf();
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if (argc < 2) { std::printf("usage: host_test <songs dir>\n"); return 2; }
|
||||
// midifx: arp, transposer and the MIDI LFO (which writes its target slot as it plays).
|
||||
const std::string text = readFile(std::string(argv[1]) + "/midifx.szg");
|
||||
const std::string plain = readFile(std::string(argv[1]) + "/mix.szg");
|
||||
CHECK(!text.empty() && !plain.empty());
|
||||
wavetable::WaveTables::prewarmBlocking(); // the host builds them in the background
|
||||
echofield::GrainSources::prewarmBlocking();
|
||||
constexpr int SR = 48000, FRAMES = 48000;
|
||||
|
||||
// 1. The host renders what the engine renders (odd buffer sizes, 192-frame blocks inside).
|
||||
{
|
||||
host::EngineHost h(SR);
|
||||
h.loadProjectText(text);
|
||||
h.rebuildArrangement();
|
||||
h.rebuildFxChains();
|
||||
h.play();
|
||||
std::vector<float> a(FRAMES * 2);
|
||||
for (int done = 0; done < FRAMES;) {
|
||||
const int n = std::min(384, FRAMES - done); // whole blocks: the LFO steps per block
|
||||
h.render(a.data() + 2 * done, n);
|
||||
done += n;
|
||||
}
|
||||
model::Project p;
|
||||
io::ProjectIo::loadInto(p, text);
|
||||
engine::Engine e(SR);
|
||||
e.setProject(&p);
|
||||
e.rebuildArrangement();
|
||||
e.rebuildFxChains();
|
||||
e.play();
|
||||
std::vector<float> b(FRAMES * 2);
|
||||
for (int done = 0; done < FRAMES; done += 192) e.fillBlock(b.data() + 2 * done, std::min(192, FRAMES - done));
|
||||
double peak = 0, diff = 0;
|
||||
for (size_t i = 0; i < a.size(); ++i) { peak = std::max(peak, (double)std::fabs(a[i])); diff = std::max(diff, (double)std::fabs(a[i] - b[i])); }
|
||||
CHECK(peak > 0.01);
|
||||
CHECK(diff == 0);
|
||||
}
|
||||
|
||||
// 2. Syncing an edited song changes the engine's song, playing on.
|
||||
{
|
||||
const std::string &text = plain; // no LFO rewriting a slot meanwhile
|
||||
host::EngineHost h(SR);
|
||||
h.loadProjectText(text);
|
||||
h.play();
|
||||
std::vector<float> buf(2 * 4800);
|
||||
h.render(buf.data(), 4800);
|
||||
model::Project p;
|
||||
io::ProjectIo::loadInto(p, text);
|
||||
p.tempoBpm = 97.f;
|
||||
p.patterns[0].tracks[1][3] = model::Cell{64, 90, 2};
|
||||
p.mixer.channels[2].volume = 0.5f;
|
||||
p.toolbox[0].set("cutoff", 0.25f);
|
||||
p.arrangement.set(3, 5, 2);
|
||||
const std::string edited = io::ProjectIo::save(p);
|
||||
h.syncProjectText(edited);
|
||||
CHECK(h.isPlaying());
|
||||
h.render(buf.data(), 4800);
|
||||
CHECK(h.projectText() == edited);
|
||||
h.syncProjectText(text); // and back
|
||||
CHECK(h.projectText() == io::ProjectIo::save([&] { model::Project q; io::ProjectIo::loadInto(q, text); return q; }()));
|
||||
}
|
||||
|
||||
std::printf(failures ? "host_test: %d failure(s)\n" : "host_test: ok\n", failures);
|
||||
return failures ? 1 : 0;
|
||||
}
|
||||
Reference in New Issue
Block a user