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,48 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#pragma once
|
||||
|
||||
// Port of model/SynthDefs.kt: the option lists the subtractive synth's slot
|
||||
// values are written with, and its shape constants.
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace sizzle::synth::defs {
|
||||
|
||||
/** Oscillator waveforms. */
|
||||
constexpr const char *WAVES[] = {"Tri", "Saw", "Square", "Pulse25", "Pulse12"};
|
||||
constexpr int WAVES_COUNT = 5;
|
||||
/** LFO waveforms. */
|
||||
constexpr const char *LFO_WAVES[] = {"Tri", "Saw", "Square", "Sine", "S&H"};
|
||||
constexpr int LFO_WAVES_COUNT = 5;
|
||||
/** LFO start-phase offsets, eight 45-degree steps. */
|
||||
constexpr const char *LFO_PHASES[] = {"0°", "45°", "90°", "135°", "180°", "225°", "270°", "315°"};
|
||||
constexpr int LFO_PHASES_COUNT = 8;
|
||||
/** Modulation-matrix sources; index 0 ("Off") disables the slot. */
|
||||
constexpr const char *MOD_SRC[] = {"Off", "LFO", "FiltEnv", "AmpEnv", "Vel", "KeyTrk"};
|
||||
constexpr int MOD_SRC_COUNT = 6;
|
||||
/** Modulation-matrix destinations. */
|
||||
constexpr const char *MOD_DST[] = {"Pitch", "Osc2", "Osc3", "Cutoff", "PWM", "Amp"};
|
||||
constexpr int MOD_DST_COUNT = 6;
|
||||
|
||||
constexpr int OSC_COUNT = 3;
|
||||
constexpr int MOD_SLOTS = 4;
|
||||
|
||||
/** Init-patch oscillator waveforms (per oscillator). */
|
||||
constexpr const char *DEF_OSC_WAVE[OSC_COUNT] = {"Saw", "Square", "Tri"};
|
||||
/** Init-patch oscillator mixer levels (only oscillator 1 audible by default). */
|
||||
constexpr float DEF_OSC_LEVEL[OSC_COUNT] = {0.9f, 0.f, 0.f};
|
||||
|
||||
/** List.indexOf: -1 when absent. */
|
||||
inline int indexOf(const char *const *list, int n, const char *v) {
|
||||
for (int i = 0; i < n; ++i) if (std::strcmp(list[i], v) == 0) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** A LFO_PHASES label as a fraction of one LFO cycle (0..1). */
|
||||
inline float lfoPhaseFraction(const char *label) {
|
||||
int i = indexOf(LFO_PHASES, LFO_PHASES_COUNT, label);
|
||||
return i < 0 ? 0.f : (float)i / (float)LFO_PHASES_COUNT;
|
||||
}
|
||||
|
||||
} // namespace sizzle::synth::defs
|
||||
Reference in New Issue
Block a user