iOS core: Synth voice, Sampler, sample store and SF2/XI loader ported, bit-exact with Kotlin
All six instruments now run in C++ (61 reference scenarios, 16 sampler tests). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
8d85b14a67
commit
a5b2f4c873
@@ -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 "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<TestVoice> makeSynthTestVoice(const TestVoiceSetup &setup) {
|
||||
wavetable::WaveTables::prewarmBlocking();
|
||||
return std::make_unique<SynthTestVoice>(setup);
|
||||
}
|
||||
|
||||
} // namespace sizzle
|
||||
Reference in New Issue
Block a user