Files
sizzletracker-android/core/tests/voices/SynthTestVoice.cpp
T
ReactorcoremeltdownandClaude Opus 5 dd04a61e22 0.41.1 (77): 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>
2026-11-18 10:21:09 +01:00

61 lines
1.9 KiB
C++

// 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