// 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 #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 makeSynthTestVoice(const TestVoiceSetup &setup); /** kind "FRASIL": FrasilVoice alone (Morph Pad). */ std::unique_ptr makeFrasilTestVoice(const TestVoiceSetup &setup); /** kind "WAVE": WaveVoice alone (Wavetable). */ std::unique_ptr makeWaveTestVoice(const TestVoiceSetup &setup); /** kind "GRAIN": GrainCloud (Grain Cloud), notes owned by live input. */ std::unique_ptr 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 makeSampleTestVoice(const TestVoiceSetup &setup); std::unique_ptr makeTestVoice(const char *kind, const TestVoiceSetup &setup); } // namespace sizzle