0.41.2 (78): cleanup and optimisation round (Android and iOS)

Nothing user-visible changes, except that the Android app is half the size and
both are lighter on the battery.

R8 is on for release builds (21.5 MB -> 10.1 MB); only the two JNI classes are
pinned by name, since the app reflects over nothing of its own, and `make dist`
keeps the mapping beside the APK. The Kotlin DSP that core/ replaced in 0.37.0
was still compiled into every APK with nothing calling it — it moves to the test
source set, where it belongs as the reference the C++ is checked against — and
the golden tests' TestVoice wrappers leave core/src for core/tests/voices, so
neither app compiles them either.

Speed: channel gain, mute/solo and the FX chain are read once per audio block
instead of once per frame in Engine::fillBlock (both platforms, bit-identical —
all 61 reference scenarios still match); the transport pollers idle at 100 ms
(Android) and 10 Hz (iOS) instead of polling flat out while a song is stopped,
woken by any transport call; ProjectIo.save builds into one pre-sized buffer and
a burst of edits is coalesced into one engine sync; the Kotlin grain sources and
factory wavetables are built when their editor opens rather than at launch, where
they duplicated ~6 MB the engine already renders in core/; and Xcode builds the
DSP core at -O2, the level the golden tests measure, not -Os.

Fix: `make lint` failed on a manifest asking for ACCESS_FINE_LOCATION without
ACCESS_COARSE_LOCATION (the BLE MIDI scan on Android 8-11), so `make check`
passes again.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Reactorcoremeltdown
2026-11-18 21:01:29 +01:00
co-authored by Claude Opus 5
parent 634dd05486
commit ba98ec56f4
46 changed files with 508 additions and 192 deletions
+1 -1
View File
@@ -21,7 +21,7 @@
#include <string>
#include <vector>
#include "sizzle/Effect.hpp"
#include "sizzle/TestVoice.hpp"
#include "voices/TestVoice.hpp"
#include "wavetable/WaveTables.hpp"
using namespace sizzle;
+54
View File
@@ -0,0 +1,54 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// The reference tests' FRASIL maker (see TestVoice.hpp, IosGoldenInstruments.kt).
#include <cmath>
#include "frasil/FrasilVoice.hpp"
#include "TestVoice.hpp"
namespace sizzle {
namespace {
using frasil::FrasilClock;
using frasil::FrasilPatch;
using frasil::FrasilSeeds;
using frasil::FrasilVoice;
/**
* The seed the Kotlin export's FrasilVoice got: the export records Kotlin's global
* seed counter right before the scenario built its voices ("seeds" line). The
* SynthVoice built first takes the next seed for its own Morph Pad voice; the
* FrasilVoice takes the one after.
*/
int32_t exportSeed(const TestVoiceSetup &s) {
FrasilSeeds seeds;
seeds.seeds = s.frasilSeeds;
seeds.next(); // the SynthVoice's Morph Pad voice
return seeds.next();
}
class FrasilTestVoice final : public TestVoice {
FrasilClock clock;
FrasilPatch patch;
FrasilVoice voice;
int sampleRate;
public:
explicit FrasilTestVoice(const TestVoiceSetup &s)
: clock{s.clock0}, patch(FrasilPatch::from(s.params)), voice(s.sampleRate, clock, exportSeed(s)),
sampleRate(s.sampleRate) {}
void blockStart(int frames) override { clock.advance(frames, sampleRate); }
void noteOn(int midi, int velocity) override { voice.noteOn(midi, (float)velocity / 127.f, patch); }
void noteOff(int) override { voice.noteOff(); }
float render() override { return voice.render(); }
};
} // namespace
std::unique_ptr<TestVoice> makeFrasilTestVoice(const TestVoiceSetup &setup) {
return std::make_unique<FrasilTestVoice>(setup);
}
} // namespace sizzle
+42
View File
@@ -0,0 +1,42 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// The reference-test maker for kind "GRAIN" (see TestVoice.hpp and
// IosGoldenInstruments.kt): a GrainCloud with the slot's patch, notes from live input.
#include <cmath>
#include <memory>
#include "echofield/GrainCloud.hpp"
#include "echofield/GrainSources.hpp"
#include "TestVoice.hpp"
namespace sizzle {
namespace {
/** The seed the Kotlin export's GrainCloud got: the next one after the global
* counter the export recorded right before the scenario built its voices. */
uint32_t exportSeed(const TestVoiceSetup &s) {
echofield::GrainSeeds seeds;
seeds.seeds = s.grainSeeds;
return seeds.next();
}
class GrainTestVoice final : public TestVoice {
echofield::GrainCloud cloud;
public:
GrainTestVoice(const TestVoiceSetup &s, uint32_t seed) : cloud(s.sampleRate, seed) {
cloud.setPatch(echofield::GrainPatch::from(s.params, s.tempoBpm));
}
void noteOn(int midi, int velocity) override { cloud.noteOn(midi, velocity, echofield::GrainCloud::OWNER_LIVE); }
void noteOff(int midi) override { cloud.noteOff(midi); }
float render() override { return cloud.render(); }
};
} // namespace
std::unique_ptr<TestVoice> makeGrainTestVoice(const TestVoiceSetup &setup) {
echofield::GrainSources::prewarmBlocking();
return std::make_unique<GrainTestVoice>(setup, exportSeed(setup));
}
} // namespace sizzle
+48
View File
@@ -0,0 +1,48 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// The reference-test maker for kind "SAMPLE" (see TestVoice.hpp and
// IosGoldenInstruments.kt): one SampleVoice playing the script with the engine's
// voiceSample() settings; the test sample is put in a store under every id the
// slot names (Sampler pads, SoundFont sfSample).
#include <memory>
#include <vector>
#include "sampler/SampleStore.hpp"
#include "sampler/SampleVoice.hpp"
#include "TestVoice.hpp"
namespace sizzle {
namespace {
class SampleTestVoice final : public TestVoice {
sampler::SampleStore store;
sampler::SampleVoice voice;
const char *type;
const Params *params;
public:
explicit SampleTestVoice(const TestVoiceSetup &s) : voice(s.sampleRate), type(s.type), params(s.params) {
if (s.sample && s.sampleLength > 0) {
Sample smp(std::vector<float>(s.sample, s.sample + s.sampleLength), s.sampleRate2, s.loopStart, s.loopEnd);
auto putId = [&](const char *id) { if (id && id[0]) store.put(id, smp); };
for (int pad = 0; pad < sampler::SamplerPads::COUNT; ++pad)
putId(params->s(sampler::SamplerPads::key(pad).s));
putId(params->s("sfSample"));
}
}
void blockStart(int) override { store.quiescent(); }
void noteOn(int midi, int velocity) override {
sampler::VoiceSample vs;
if (sampler::voiceSample(type, *params, store, midi, vs)) voice.noteOn(vs, midi, velocity);
}
void noteOff(int) override { voice.noteOff(); }
float render() override { return voice.render(); }
};
} // namespace
std::unique_ptr<TestVoice> makeSampleTestVoice(const TestVoiceSetup &setup) {
return std::make_unique<SampleTestVoice>(setup);
}
} // namespace sizzle
+60
View File
@@ -0,0 +1,60 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// The reference tests' SYNTH maker (see TestVoice.hpp, IosGoldenInstruments.kt):
// a SynthVoice with the patch the engine builds for the slot's type.
#include <cstring>
#include "frasil/FrasilVoice.hpp"
#include "TestVoice.hpp"
#include "synth/SynthVoice.hpp"
#include "wavetable/WaveTables.hpp"
namespace sizzle {
namespace {
using frasil::FrasilClock;
using frasil::FrasilSeeds;
using synth::SynthPatch;
using synth::SynthVoice;
SynthPatch enginePatch(const TestVoiceSetup &s) {
if (std::strcmp(s.type, "NES_SYNTH") == 0) return SynthPatch::from(s.params, s.tempoBpm);
if (std::strcmp(s.type, "MORPH_PAD") == 0) return SynthPatch::forPad(frasil::FrasilPatch::from(s.params));
if (std::strcmp(s.type, "WAVETABLE") == 0)
return SynthPatch::forWave(wavetable::WavePatch::from(s.params, s.tempoBpm));
return SynthPatch::defaults();
}
FrasilSeeds seedsAt(uint32_t counter) {
FrasilSeeds seeds;
seeds.seeds = counter;
return seeds;
}
class SynthTestVoice final : public TestVoice {
FrasilClock clock;
FrasilSeeds seeds;
SynthPatch patch;
SynthVoice voice;
int sampleRate;
public:
explicit SynthTestVoice(const TestVoiceSetup &s)
: clock{s.clock0}, seeds(seedsAt(s.frasilSeeds)), patch(enginePatch(s)),
voice(s.sampleRate, clock, seeds.next()), sampleRate(s.sampleRate) {}
void blockStart(int frames) override { clock.advance(frames, sampleRate); }
void noteOn(int midi, int velocity) override { voice.noteOn(midi, velocity, patch); }
void noteOff(int) override { voice.noteOff(); }
float render() override { return voice.render(); }
};
} // namespace
std::unique_ptr<TestVoice> makeSynthTestVoice(const TestVoiceSetup &setup) {
wavetable::WaveTables::prewarmBlocking();
return std::make_unique<SynthTestVoice>(setup);
}
} // namespace sizzle
+57
View File
@@ -0,0 +1,57 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
// The hook the reference tests use to play a note script through one instrument
// voice (see IosGoldenInstruments.kt and tests/golden_test.cpp). Each instrument
// port provides its maker (strong definition) in its own source file; the weak
// placeholders in src/TestVoices.cpp return nullptr for kinds not ported yet.
#include <memory>
#include "sizzle/Params.hpp"
namespace sizzle {
class TestVoice {
public:
virtual ~TestVoice() = default;
/** Called before each block of [frames] (AudioEngine advances shared clocks
* such as the Morph Pad's FrasilClock here). */
virtual void blockStart(int frames) { (void)frames; }
virtual void noteOn(int midi, int velocity) = 0;
virtual void noteOff(int midi) = 0;
virtual float render() = 0;
};
struct TestVoiceSetup {
const char *type; // ToolboxType name, e.g. "MORPH_PAD"
const Params *params; // the slot's values
int sampleRate;
float tempoBpm;
double clock0; // FrasilClock.seconds when the scenario started
// kind "SAMPLE": the test sample (mono), its rate and loop points (-1 = none)
const float *sample = nullptr;
int sampleLength = 0;
int sampleRate2 = 0;
int loopStart = -1, loopEnd = -1;
// Kotlin's global seed counters right before the scenario built its voices
// (FrasilVoice, GrainCloud): a SynthVoice's Morph Pad voice takes the next
// Frasil seed, then the FRASIL kind's voice, then the GrainCloud the next grain one.
uint32_t frasilSeeds = 0, grainSeeds = 0;
};
/** kind "SYNTH": SynthVoice with the engine's patch for [setup.type]. */
std::unique_ptr<TestVoice> makeSynthTestVoice(const TestVoiceSetup &setup);
/** kind "FRASIL": FrasilVoice alone (Morph Pad). */
std::unique_ptr<TestVoice> makeFrasilTestVoice(const TestVoiceSetup &setup);
/** kind "WAVE": WaveVoice alone (Wavetable). */
std::unique_ptr<TestVoice> makeWaveTestVoice(const TestVoiceSetup &setup);
/** kind "GRAIN": GrainCloud (Grain Cloud), notes owned by live input. */
std::unique_ptr<TestVoice> makeGrainTestVoice(const TestVoiceSetup &setup);
/** kind "SAMPLE": SampleVoice with the engine's voiceSample() settings for
* [setup.type] (SAMPLER: pads by note; SOUNDFONT: sfRoot, envelope, loop). */
std::unique_ptr<TestVoice> makeSampleTestVoice(const TestVoiceSetup &setup);
std::unique_ptr<TestVoice> makeTestVoice(const char *kind, const TestVoiceSetup &setup);
} // namespace sizzle
+30
View File
@@ -0,0 +1,30 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// Weak placeholders for the TestVoice makers (see TestVoice.hpp): a port's strong
// definition replaces its placeholder at link time.
#include <cstring>
#include "TestVoice.hpp"
#define SIZZLE_TEST_MAKER(fn) \
__attribute__((weak)) std::unique_ptr<TestVoice> fn(const TestVoiceSetup &) { return nullptr; }
namespace sizzle {
SIZZLE_TEST_MAKER(makeSynthTestVoice)
SIZZLE_TEST_MAKER(makeFrasilTestVoice)
SIZZLE_TEST_MAKER(makeWaveTestVoice)
SIZZLE_TEST_MAKER(makeGrainTestVoice)
SIZZLE_TEST_MAKER(makeSampleTestVoice)
std::unique_ptr<TestVoice> makeTestVoice(const char *kind, const TestVoiceSetup &s) {
if (!std::strcmp(kind, "SYNTH")) return makeSynthTestVoice(s);
if (!std::strcmp(kind, "FRASIL")) return makeFrasilTestVoice(s);
if (!std::strcmp(kind, "WAVE")) return makeWaveTestVoice(s);
if (!std::strcmp(kind, "GRAIN")) return makeGrainTestVoice(s);
if (!std::strcmp(kind, "SAMPLE")) return makeSampleTestVoice(s);
return nullptr;
}
} // namespace sizzle
+35
View File
@@ -0,0 +1,35 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// The reference-test maker for kind "WAVE" (see TestVoice.hpp, IosGoldenInstruments.kt):
// WaveVoice alone, patch from the slot, factory tables built up front.
#include <memory>
#include "TestVoice.hpp"
#include "wavetable/WaveTables.hpp"
#include "wavetable/WaveVoice.hpp"
namespace sizzle {
namespace {
class WaveTestVoice final : public TestVoice {
public:
explicit WaveTestVoice(const TestVoiceSetup &s)
: voice_(s.sampleRate), patch_(wavetable::WavePatch::from(s.params, s.tempoBpm)) {}
void noteOn(int midi, int velocity) override { voice_.noteOn(midi, (float)velocity / 127.f, patch_); }
void noteOff(int) override { voice_.noteOff(); }
float render() override { return voice_.render(); }
private:
wavetable::WaveVoice voice_;
wavetable::WavePatch patch_;
};
} // namespace
std::unique_ptr<TestVoice> makeWaveTestVoice(const TestVoiceSetup &setup) {
wavetable::WaveTables::prewarmBlocking();
return std::make_unique<WaveTestVoice>(setup);
}
} // namespace sizzle