// 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 #include #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 makeGrainTestVoice(const TestVoiceSetup &setup) { echofield::GrainSources::prewarmBlocking(); return std::make_unique(setup, exportSeed(setup)); } } // namespace sizzle