// 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 #include "frasil/FrasilVoice.hpp" #include "sizzle/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 makeSynthTestVoice(const TestVoiceSetup &setup) { wavetable::WaveTables::prewarmBlocking(); return std::make_unique(setup); } } // namespace sizzle