iOS 0.1.0: the eight audio effects as AUv3 plugins on a C++ core
C++ ports of the Kotlin effects, checked against audio the Kotlin code renders (25 scenarios, IosGoldenExport); an Objective-C++ AUv3 wrapper checked on the Mac against the core (parameters, presets, saved state); a container app that checks each plugin on the device. Built as a TrollStore .ipa. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c9ad186de1
commit
dcf85ba915
@@ -0,0 +1,364 @@
|
||||
// GENERATED by IosGoldenExport (make -C ios golden). Do not edit.
|
||||
// Every Sizzle device's parameters, from ToolboxType in the Android app.
|
||||
#pragma once
|
||||
#include "sizzle/Specs.hpp"
|
||||
|
||||
namespace sizzle::gen {
|
||||
|
||||
inline const char *const NES_SYNTH_c0[] = {"Tri", "Saw", "Square", "Pulse25", "Pulse12", nullptr};
|
||||
inline const char *const NES_SYNTH_c5[] = {"Tri", "Saw", "Square", "Pulse25", "Pulse12", nullptr};
|
||||
inline const char *const NES_SYNTH_c10[] = {"Tri", "Saw", "Square", "Pulse25", "Pulse12", nullptr};
|
||||
inline const char *const NES_SYNTH_c28[] = {"Tri", "Saw", "Square", "Sine", "S&H", nullptr};
|
||||
inline const char *const NES_SYNTH_c30[] = {"0°", "45°", "90°", "135°", "180°", "225°", "270°", "315°", nullptr};
|
||||
inline const char *const NES_SYNTH_c31[] = {"Off", "LFO", "FiltEnv", "AmpEnv", "Vel", "KeyTrk", nullptr};
|
||||
inline const char *const NES_SYNTH_c32[] = {"Pitch", "Osc2", "Osc3", "Cutoff", "PWM", "Amp", nullptr};
|
||||
inline const char *const NES_SYNTH_c34[] = {"Off", "LFO", "FiltEnv", "AmpEnv", "Vel", "KeyTrk", nullptr};
|
||||
inline const char *const NES_SYNTH_c35[] = {"Pitch", "Osc2", "Osc3", "Cutoff", "PWM", "Amp", nullptr};
|
||||
inline const char *const NES_SYNTH_c37[] = {"Off", "LFO", "FiltEnv", "AmpEnv", "Vel", "KeyTrk", nullptr};
|
||||
inline const char *const NES_SYNTH_c38[] = {"Pitch", "Osc2", "Osc3", "Cutoff", "PWM", "Amp", nullptr};
|
||||
inline const char *const NES_SYNTH_c40[] = {"Off", "LFO", "FiltEnv", "AmpEnv", "Vel", "KeyTrk", nullptr};
|
||||
inline const char *const NES_SYNTH_c41[] = {"Pitch", "Osc2", "Osc3", "Cutoff", "PWM", "Amp", nullptr};
|
||||
inline const ParamSpec NES_SYNTH_params[] = {
|
||||
{"osc0wave", "Osc1 Wave", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c0},
|
||||
{"osc0oct", "Osc1 Oct", 0.0f, -2.0f, 2.0f, true, nullptr},
|
||||
{"osc0semi", "Osc1 Semi", 0.0f, -12.0f, 12.0f, true, nullptr},
|
||||
{"osc0fine", "Osc1 Fine", 0.0f, -50.0f, 50.0f, false, nullptr},
|
||||
{"osc0level", "Osc1 Level", 0.9f, 0.0f, 1.0f, false, nullptr},
|
||||
{"osc1wave", "Osc2 Wave", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c5},
|
||||
{"osc1oct", "Osc2 Oct", 0.0f, -2.0f, 2.0f, true, nullptr},
|
||||
{"osc1semi", "Osc2 Semi", 0.0f, -12.0f, 12.0f, true, nullptr},
|
||||
{"osc1fine", "Osc2 Fine", 0.0f, -50.0f, 50.0f, false, nullptr},
|
||||
{"osc1level", "Osc2 Level", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"osc2wave", "Osc3 Wave", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c10},
|
||||
{"osc2oct", "Osc3 Oct", 0.0f, -2.0f, 2.0f, true, nullptr},
|
||||
{"osc2semi", "Osc3 Semi", 0.0f, -12.0f, 12.0f, true, nullptr},
|
||||
{"osc2fine", "Osc3 Fine", 0.0f, -50.0f, 50.0f, false, nullptr},
|
||||
{"osc2level", "Osc3 Level", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"noise", "Noise", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"cutoff", "Cutoff", 0.55f, 0.0f, 1.0f, false, nullptr},
|
||||
{"reso", "Resonance", 0.15f, 0.0f, 1.0f, false, nullptr},
|
||||
{"keytrack", "Key Track", 0.3f, 0.0f, 1.0f, false, nullptr},
|
||||
{"fenvamt", "Filter Env", 0.4f, -1.0f, 1.0f, false, nullptr},
|
||||
{"fatk", "F.Attack", 0.005f, 0.0f, 2.0f, false, nullptr},
|
||||
{"fdec", "F.Decay", 0.25f, 0.0f, 2.0f, false, nullptr},
|
||||
{"fsus", "F.Sustain", 0.4f, 0.0f, 1.0f, false, nullptr},
|
||||
{"frel", "F.Release", 0.2f, 0.0f, 3.0f, false, nullptr},
|
||||
{"attack", "Attack", 0.005f, 0.0f, 2.0f, false, nullptr},
|
||||
{"decay", "Decay", 0.2f, 0.0f, 2.0f, false, nullptr},
|
||||
{"sustain", "Sustain", 0.7f, 0.0f, 1.0f, false, nullptr},
|
||||
{"release", "Release", 0.2f, 0.0f, 3.0f, false, nullptr},
|
||||
{"lfowave", "LFO Wave", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c28},
|
||||
{"lfodiv", "LFO Rate", 3.0f, 0.0f, 6.0f, true, nullptr},
|
||||
{"lfophase", "LFO Phase", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c30},
|
||||
{"m0src", "Mod1 Src", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c31},
|
||||
{"m0dst", "Mod1 Dst", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c32},
|
||||
{"m0amt", "Mod1 Amt", 0.0f, -1.0f, 1.0f, false, nullptr},
|
||||
{"m1src", "Mod2 Src", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c34},
|
||||
{"m1dst", "Mod2 Dst", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c35},
|
||||
{"m1amt", "Mod2 Amt", 0.0f, -1.0f, 1.0f, false, nullptr},
|
||||
{"m2src", "Mod3 Src", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c37},
|
||||
{"m2dst", "Mod3 Dst", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c38},
|
||||
{"m2amt", "Mod3 Amt", 0.0f, -1.0f, 1.0f, false, nullptr},
|
||||
{"m3src", "Mod4 Src", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c40},
|
||||
{"m3dst", "Mod4 Dst", 0.0f, 0.0f, 1.0f, false, NES_SYNTH_c41},
|
||||
{"m3amt", "Mod4 Amt", 0.0f, -1.0f, 1.0f, false, nullptr},
|
||||
};
|
||||
|
||||
inline const ParamSpec SAMPLER_params[] = {
|
||||
{"volume", "Volume", 0.8f, 0.0f, 1.0f, false, nullptr},
|
||||
};
|
||||
|
||||
inline const char *const SOUNDFONT_c6[] = {"Off", "On", nullptr};
|
||||
inline const ParamSpec SOUNDFONT_params[] = {
|
||||
{"program", "Program", 0.0f, 0.0f, 127.0f, true, nullptr},
|
||||
{"volume", "Volume", 0.8f, 0.0f, 1.0f, false, nullptr},
|
||||
{"attack", "Attack", 0.005f, 0.0f, 2.0f, false, nullptr},
|
||||
{"decay", "Decay", 0.1f, 0.0f, 2.0f, false, nullptr},
|
||||
{"sustain", "Sustain", 1.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"release", "Release", 0.2f, 0.0f, 3.0f, false, nullptr},
|
||||
{"loop", "Loop", 0.0f, 0.0f, 1.0f, false, SOUNDFONT_c6},
|
||||
{"loopXfade", "Loop XFade", 0.0f, 0.0f, 500.0f, false, nullptr},
|
||||
};
|
||||
|
||||
inline const char *const MORPH_PAD_c0[] = {"Off", "Mist", "Cathedral", "Glacier", "Abyss", "Aurora", "Ember", "Tide", "Dust", "Wind", "Organ", "Hollow", "Vowel", "Shimmer", "Chanter", "Ensemble", "Bells", "Nocturne", "Haze", "Pulse", "Rime", "Deep", "Spectral", "Rust", "Still", "Velvet", "Chrome", "Swarm", "Foghorn", "Solar", "Cave", "Glass Harp", "Monk", "Static", "Lullaby", "Storm", "Prism", nullptr};
|
||||
inline const char *const MORPH_PAD_c19[] = {"Unison", "-12", "+7", "+12", nullptr};
|
||||
inline const char *const MORPH_PAD_c21[] = {"Low", "Band", "High", nullptr};
|
||||
inline const char *const MORPH_PAD_c33[] = {"-12", "Unison", "+12", "+19", "+24", nullptr};
|
||||
inline const ParamSpec MORPH_PAD_params[] = {
|
||||
{"morphTo", "Morph To", 0.0f, 0.0f, 1.0f, false, MORPH_PAD_c0},
|
||||
{"morph", "Morph", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"mtime", "Morph Time s", 0.0f, 0.0f, 120.0f, false, nullptr},
|
||||
{"choir", "Choir", 0.5984252f, 0.0f, 1.0f, false, nullptr},
|
||||
{"partials", "Partials", 0.7007874f, 0.0f, 1.0f, false, nullptr},
|
||||
{"breath", "Breath", 0.2519685f, 0.0f, 1.0f, false, nullptr},
|
||||
{"timbre", "Timbre", 0.503937f, 0.0f, 1.0f, false, nullptr},
|
||||
{"warmth", "Warmth", 0.1496063f, 0.0f, 1.0f, false, nullptr},
|
||||
{"body", "Body", 1.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"attack", "Attack", 0.7007874f, 0.0f, 1.0f, false, nullptr},
|
||||
{"release", "Release", 0.6535433f, 0.0f, 1.0f, false, nullptr},
|
||||
{"velsens", "Velocity", 0.2992126f, 0.0f, 1.0f, false, nullptr},
|
||||
{"motion", "Motion", 0.3464567f, 0.0f, 1.0f, false, nullptr},
|
||||
{"mrate", "Motion Rate", 0.4015748f, 0.0f, 1.0f, false, nullptr},
|
||||
{"tide", "Tide", 0.19685039f, 0.0f, 1.0f, false, nullptr},
|
||||
{"tperiod", "Tide Speed", 0.2992126f, 0.0f, 1.0f, false, nullptr},
|
||||
{"detune", "Detune", 0.4015748f, 0.0f, 1.0f, false, nullptr},
|
||||
{"cfilter", "Filter", 0.3464567f, 0.0f, 1.0f, false, nullptr},
|
||||
{"shape", "Shape", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"interval", "Interval", 0.0f, 0.0f, 1.0f, false, MORPH_PAD_c19},
|
||||
{"creso", "Resonance", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"ctype", "Filter Type", 0.0f, 0.0f, 1.0f, false, MORPH_PAD_c21},
|
||||
{"soft", "Soft", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"tilt", "Tilt", 0.4488189f, 0.0f, 1.0f, false, nullptr},
|
||||
{"odd", "Odd", 0.19685039f, 0.0f, 1.0f, false, nullptr},
|
||||
{"stretch", "Stretch", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"evolve", "Evolve", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"beat", "Beat", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"formant", "Formant", 0.6692913f, 0.0f, 1.0f, false, nullptr},
|
||||
{"peak", "Peak", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"bres", "Glass", 0.5511811f, 0.0f, 1.0f, false, nullptr},
|
||||
{"color", "Color", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"grain", "Grain", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"bpitch", "Pitch", 0.0f, 0.0f, 1.0f, false, MORPH_PAD_c33},
|
||||
{"btone", "Tone", 0.503937f, 0.0f, 1.0f, false, nullptr},
|
||||
{"air", "Air", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
};
|
||||
|
||||
inline const char *const GRAIN_CLOUD_c0[] = {"Felt Piano", "Bowed Glass", "Music Box", "Warm Pad", "Strings", "Low Drone", "Rain Field", "Kalimba", "Breath Choir", "Glass Tines", "Custom", nullptr};
|
||||
inline const char *const GRAIN_CLOUD_c1[] = {"Cloud", "Dust", "Tape", "Bloom", "Pulse", "Drift", nullptr};
|
||||
inline const char *const GRAIN_CLOUD_c15[] = {"Auto", "Hann", "Tukey", "Perc", "Swell", "Gauss", nullptr};
|
||||
inline const char *const GRAIN_CLOUD_c22[] = {"Off", "On", nullptr};
|
||||
inline const ParamSpec GRAIN_CLOUD_params[] = {
|
||||
{"source", "Source", 0.0f, 0.0f, 1.0f, false, GRAIN_CLOUD_c0},
|
||||
{"mode", "Mode", 0.0f, 0.0f, 1.0f, false, GRAIN_CLOUD_c1},
|
||||
{"position", "Position", 0.35f, 0.0f, 1.0f, false, nullptr},
|
||||
{"texture", "Texture", 0.72f, 0.0f, 1.0f, false, nullptr},
|
||||
{"scatter", "Scatter", 0.45f, 0.0f, 1.0f, false, nullptr},
|
||||
{"drift", "Drift", 0.35f, 0.0f, 1.0f, false, nullptr},
|
||||
{"motion", "Evolve", 0.35f, 0.0f, 1.0f, false, nullptr},
|
||||
{"pitch", "Pitch", 0.0f, -24.0f, 24.0f, true, nullptr},
|
||||
{"harmony", "Harmony", 0.3f, 0.0f, 1.0f, false, nullptr},
|
||||
{"size_mul", "Size", 0.0f, -2.0f, 2.0f, false, nullptr},
|
||||
{"dens_mul", "Density", 0.0f, -2.0f, 2.0f, false, nullptr},
|
||||
{"scan", "Scan", 0.0f, -1.0f, 1.0f, false, nullptr},
|
||||
{"reverse", "Reverse", 0.1f, 0.0f, 1.0f, false, nullptr},
|
||||
{"pitch_rand", "Pitch Rnd", 0.0f, 0.0f, 12.0f, false, nullptr},
|
||||
{"size_rand", "Size Rnd", 0.3f, 0.0f, 1.0f, false, nullptr},
|
||||
{"window", "Envelope", 0.0f, 0.0f, 1.0f, false, GRAIN_CLOUD_c15},
|
||||
{"grain_tone", "Tone", -0.1f, -1.0f, 1.0f, false, nullptr},
|
||||
{"attack", "Attack", 0.15f, 0.0f, 1.0f, false, nullptr},
|
||||
{"release", "Release", 0.45f, 0.0f, 1.0f, false, nullptr},
|
||||
{"velo", "Velocity", 0.5f, 0.0f, 1.0f, false, nullptr},
|
||||
{"start", "Start", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"end", "End", 1.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"freeze", "Freeze", 0.0f, 0.0f, 1.0f, false, GRAIN_CLOUD_c22},
|
||||
{"level", "Level", 0.75f, 0.0f, 1.0f, false, nullptr},
|
||||
};
|
||||
|
||||
inline const char *const WAVETABLE_c0[] = {"Classic", "PWM", "Vowels", "Harmonic Sweep", "Sync", "FM", "Organ", "Fold", "Digital", "Glass", "Odd Even", "Comb", "Custom", nullptr};
|
||||
inline const char *const WAVETABLE_c7[] = {"Classic", "PWM", "Vowels", "Harmonic Sweep", "Sync", "FM", "Organ", "Fold", "Digital", "Glass", "Odd Even", "Comb", "Custom", nullptr};
|
||||
inline const char *const WAVETABLE_c19[] = {"Auto", "256", "512", "1024", "2048", nullptr};
|
||||
inline const char *const WAVETABLE_c20[] = {"Low", "Band", "High", nullptr};
|
||||
inline const char *const WAVETABLE_c35[] = {"Sine", "Tri", "Saw", "Square", "S&H", nullptr};
|
||||
inline const ParamSpec WAVETABLE_params[] = {
|
||||
{"o1table", "Osc1 Table", 0.0f, 0.0f, 1.0f, false, WAVETABLE_c0},
|
||||
{"o1pos", "Osc1 Position", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"o1oct", "Osc1 Oct", 0.0f, -2.0f, 2.0f, true, nullptr},
|
||||
{"o1semi", "Osc1 Semi", 0.0f, -12.0f, 12.0f, true, nullptr},
|
||||
{"o1fine", "Osc1 Fine", 0.0f, -50.0f, 50.0f, false, nullptr},
|
||||
{"o1level", "Osc1 Level", 0.8f, 0.0f, 1.0f, false, nullptr},
|
||||
{"o1bend", "Osc1 Bend", 0.0f, -1.0f, 1.0f, false, nullptr},
|
||||
{"o2table", "Osc2 Table", 0.0f, 0.0f, 1.0f, false, WAVETABLE_c7},
|
||||
{"o2pos", "Osc2 Position", 0.3f, 0.0f, 1.0f, false, nullptr},
|
||||
{"o2oct", "Osc2 Oct", 0.0f, -2.0f, 2.0f, true, nullptr},
|
||||
{"o2semi", "Osc2 Semi", 0.0f, -12.0f, 12.0f, true, nullptr},
|
||||
{"o2fine", "Osc2 Fine", 7.0f, -50.0f, 50.0f, false, nullptr},
|
||||
{"o2level", "Osc2 Level", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"o2bend", "Osc2 Bend", 0.0f, -1.0f, 1.0f, false, nullptr},
|
||||
{"unison", "Unison", 1.0f, 1.0f, 4.0f, true, nullptr},
|
||||
{"spread", "Spread", 0.3f, 0.0f, 1.0f, false, nullptr},
|
||||
{"sub", "Sub", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"noise", "Noise", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"velsens", "Velocity", 0.5f, 0.0f, 1.0f, false, nullptr},
|
||||
{"wtframe", "Frame Size", 0.0f, 0.0f, 1.0f, false, WAVETABLE_c19},
|
||||
{"ftype", "Filter", 0.0f, 0.0f, 1.0f, false, WAVETABLE_c20},
|
||||
{"cutoff", "Cutoff", 0.75f, 0.0f, 1.0f, false, nullptr},
|
||||
{"reso", "Resonance", 0.15f, 0.0f, 1.0f, false, nullptr},
|
||||
{"keytrack", "Key Track", 0.4f, 0.0f, 1.0f, false, nullptr},
|
||||
{"fenv", "Env Amount", 0.2f, -1.0f, 1.0f, false, nullptr},
|
||||
{"drive", "Drive", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"attack", "Attack", 0.01f, 0.0f, 5.0f, false, nullptr},
|
||||
{"decay", "Decay", 0.3f, 0.0f, 5.0f, false, nullptr},
|
||||
{"sustain", "Sustain", 0.8f, 0.0f, 1.0f, false, nullptr},
|
||||
{"release", "Release", 0.4f, 0.0f, 8.0f, false, nullptr},
|
||||
{"mattack", "Mod Attack", 0.5f, 0.0f, 10.0f, false, nullptr},
|
||||
{"mdecay", "Mod Decay", 2.0f, 0.0f, 10.0f, false, nullptr},
|
||||
{"msustain", "Mod Sustain", 0.5f, 0.0f, 1.0f, false, nullptr},
|
||||
{"mrelease", "Mod Release", 1.0f, 0.0f, 10.0f, false, nullptr},
|
||||
{"menvpos", "Env > Position", 0.3f, -1.0f, 1.0f, false, nullptr},
|
||||
{"lfowave", "LFO Wave", 0.0f, 0.0f, 1.0f, false, WAVETABLE_c35},
|
||||
{"lfodiv", "LFO Sync", 1.0f, 0.0f, 6.0f, true, nullptr},
|
||||
{"lfopos", "LFO > Position", 0.15f, 0.0f, 1.0f, false, nullptr},
|
||||
{"lfopitch", "LFO > Pitch", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"lfocut", "LFO > Cutoff", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
};
|
||||
|
||||
inline const char *const ARPEGGIATOR_c0[] = {"Up", "Down", "UpDown", "Random", nullptr};
|
||||
inline const char *const ARPEGGIATOR_c3[] = {"Off", "On", nullptr};
|
||||
inline const ParamSpec ARPEGGIATOR_params[] = {
|
||||
{"mode", "Mode", 0.0f, 0.0f, 1.0f, false, ARPEGGIATOR_c0},
|
||||
{"octaves", "Octaves", 1.0f, 1.0f, 4.0f, true, nullptr},
|
||||
{"division", "Division", 3.0f, 0.0f, 6.0f, true, nullptr},
|
||||
{"resetbar", "Reset/Bar", 0.0f, 0.0f, 1.0f, false, ARPEGGIATOR_c3},
|
||||
};
|
||||
|
||||
inline const ParamSpec TRANSPOSER_params[] = {
|
||||
{"octaves", "Octaves", 0.0f, -4.0f, 4.0f, true, nullptr},
|
||||
{"semitones", "Semitones", 0.0f, -24.0f, 24.0f, true, nullptr},
|
||||
};
|
||||
|
||||
inline const char *const LFO_c0[] = {"Sine", "Triangle", "Saw", "Square", "SampleHold", nullptr};
|
||||
inline const ParamSpec LFO_params[] = {
|
||||
{"wave", "Wave", 0.0f, 0.0f, 1.0f, false, LFO_c0},
|
||||
{"phase", "Phase", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"depth", "Depth", 0.5f, 0.0f, 1.0f, false, nullptr},
|
||||
{"division", "Division", 3.0f, 0.0f, 6.0f, true, nullptr},
|
||||
};
|
||||
|
||||
inline const ParamSpec DELAY_params[] = {
|
||||
{"feedback", "Feedback", 0.4f, 0.0f, 0.9f, false, nullptr},
|
||||
{"drywet", "Dry/Wet", 0.35f, 0.0f, 1.0f, false, nullptr},
|
||||
{"tape", "Tape Strength", 0.3f, 0.0f, 1.0f, false, nullptr},
|
||||
{"head0On", "Head 1 On", 1.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"head0Div", "Head 1 Div", 5.0f, 0.0f, 12.0f, false, nullptr},
|
||||
{"head1On", "Head 2 On", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"head1Div", "Head 2 Div", 8.0f, 0.0f, 12.0f, false, nullptr},
|
||||
{"head2On", "Head 3 On", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"head2Div", "Head 3 Div", 3.0f, 0.0f, 12.0f, false, nullptr},
|
||||
{"head3On", "Head 4 On", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"head3Div", "Head 4 Div", 2.0f, 0.0f, 12.0f, false, nullptr},
|
||||
};
|
||||
|
||||
inline const char *const FILTER_c0[] = {"LPF", "HPF", "BPF", nullptr};
|
||||
inline const ParamSpec FILTER_params[] = {
|
||||
{"type", "Type", 0.0f, 0.0f, 1.0f, false, FILTER_c0},
|
||||
{"cutoff", "Cutoff", 0.7f, 0.0f, 1.0f, false, nullptr},
|
||||
{"resonance", "Resonance", 0.2f, 0.0f, 1.0f, false, nullptr},
|
||||
{"warmth", "Warmth", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"envamt", "Env Amount", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"attack", "Attack", 0.005f, 0.0f, 2.0f, false, nullptr},
|
||||
{"decay", "Decay", 0.1f, 0.0f, 2.0f, false, nullptr},
|
||||
{"sustain", "Sustain", 1.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"release", "Release", 0.2f, 0.0f, 3.0f, false, nullptr},
|
||||
};
|
||||
|
||||
inline const ParamSpec EQ10_params[] = {
|
||||
{"band0", "Band 1", 0.0f, -1.0f, 1.0f, false, nullptr},
|
||||
{"band1", "Band 2", 0.0f, -1.0f, 1.0f, false, nullptr},
|
||||
{"band2", "Band 3", 0.0f, -1.0f, 1.0f, false, nullptr},
|
||||
{"band3", "Band 4", 0.0f, -1.0f, 1.0f, false, nullptr},
|
||||
{"band4", "Band 5", 0.0f, -1.0f, 1.0f, false, nullptr},
|
||||
{"band5", "Band 6", 0.0f, -1.0f, 1.0f, false, nullptr},
|
||||
{"band6", "Band 7", 0.0f, -1.0f, 1.0f, false, nullptr},
|
||||
{"band7", "Band 8", 0.0f, -1.0f, 1.0f, false, nullptr},
|
||||
{"band8", "Band 9", 0.0f, -1.0f, 1.0f, false, nullptr},
|
||||
{"band9", "Band 10", 0.0f, -1.0f, 1.0f, false, nullptr},
|
||||
};
|
||||
|
||||
inline const ParamSpec BITCRUSHER_params[] = {
|
||||
{"bits", "Bits", 8.0f, 1.0f, 16.0f, true, nullptr},
|
||||
{"downsample", "Downsample", 1.0f, 1.0f, 32.0f, true, nullptr},
|
||||
{"drive", "Drive", 0.2f, 0.0f, 1.0f, false, nullptr},
|
||||
};
|
||||
|
||||
inline const char *const AMBIENCE_c0[] = {"Room 1", "Room 2", "Hall 1", "Hall 2", "Plate", "Spring", "Goldfoil", nullptr};
|
||||
inline const ParamSpec AMBIENCE_params[] = {
|
||||
{"algo", "Algorithm", 0.0f, 0.0f, 6.0f, false, AMBIENCE_c0},
|
||||
{"predelay", "Pre-Delay", 10.0f, 0.0f, 500.0f, false, nullptr},
|
||||
{"roomsize", "Room Size", 1.0f, 0.3f, 2.0f, false, nullptr},
|
||||
{"decay", "Decay", 1.5f, 0.1f, 20.0f, false, nullptr},
|
||||
{"hfdamp", "HF Damp", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"lfabsorb", "LF Absorb", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"diffusion", "Diffusion", 0.7f, 0.0f, 1.0f, false, nullptr},
|
||||
{"modamt", "Mod Amount", 0.25f, 0.0f, 1.0f, false, nullptr},
|
||||
{"modrate", "Mod Rate", 0.5f, 0.05f, 2.0f, false, nullptr},
|
||||
{"erlevel", "ER Level", 0.6f, 0.0f, 1.0f, false, nullptr},
|
||||
{"saturation", "Saturation", 0.0f, 0.0f, 1.0f, false, nullptr},
|
||||
{"wet", "Wet (dB)", -4.0f, -60.0f, 0.0f, false, nullptr},
|
||||
{"dry", "Dry (dB)", 0.0f, -60.0f, 0.0f, false, nullptr},
|
||||
{"duckamt", "Ducking (dB)", 0.0f, 0.0f, 20.0f, false, nullptr},
|
||||
{"duckthresh", "Duck Thresh (dB)", -20.0f, -60.0f, 0.0f, false, nullptr},
|
||||
{"duckattack", "Duck Attack (ms)", 10.0f, 0.5f, 100.0f, false, nullptr},
|
||||
{"duckrelease", "Duck Release (ms)", 200.0f, 10.0f, 2000.0f, false, nullptr},
|
||||
};
|
||||
|
||||
inline const ParamSpec MIX_TIGHTENER_params[] = {
|
||||
{"strength", "Strength", 1.0f, 0.0f, 1.0f, false, nullptr},
|
||||
};
|
||||
|
||||
inline const ParamSpec TAPE_ENGINE_params[] = {
|
||||
{"speed", "Speed", 1.0f, 0.25f, 1.0f, false, nullptr},
|
||||
{"wow", "Wow", 0.15f, 0.0f, 1.0f, false, nullptr},
|
||||
{"flutter", "Flutter", 0.15f, 0.0f, 1.0f, false, nullptr},
|
||||
{"hiss", "Hiss", 0.1f, 0.0f, 1.0f, false, nullptr},
|
||||
{"division", "Wow Sync", 2.0f, 0.0f, 6.0f, true, nullptr},
|
||||
};
|
||||
|
||||
inline const ParamSpec GRANULAR_params[] = {
|
||||
{"intensity", "Intensity", 0.3f, 0.0f, 1.0f, false, nullptr},
|
||||
};
|
||||
|
||||
inline const DeviceSpec devices[] = {
|
||||
{"NES_SYNTH", "Synth", Kind::Instrument, NES_SYNTH_params, 43},
|
||||
{"SAMPLER", "Sampler", Kind::Instrument, SAMPLER_params, 1},
|
||||
{"SOUNDFONT", "SF2 / XI Loader", Kind::Instrument, SOUNDFONT_params, 8},
|
||||
{"MORPH_PAD", "Morph Pad", Kind::Instrument, MORPH_PAD_params, 36},
|
||||
{"GRAIN_CLOUD", "Grain Cloud", Kind::Instrument, GRAIN_CLOUD_params, 24},
|
||||
{"WAVETABLE", "Wavetable", Kind::Instrument, WAVETABLE_params, 40},
|
||||
{"ARPEGGIATOR", "MIDI Arpeggiator", Kind::Effect, ARPEGGIATOR_params, 4},
|
||||
{"TRANSPOSER", "MIDI Transposer", Kind::Effect, TRANSPOSER_params, 2},
|
||||
{"LFO", "MIDI LFO", Kind::Effect, LFO_params, 4},
|
||||
{"DELAY", "Tape Delay", Kind::Effect, DELAY_params, 11},
|
||||
{"FILTER", "Filter (LP/HP/BP)", Kind::Effect, FILTER_params, 9},
|
||||
{"EQ10", "10-Band EQ", Kind::Effect, EQ10_params, 10},
|
||||
{"BITCRUSHER", "Bitcrusher", Kind::Effect, BITCRUSHER_params, 3},
|
||||
{"AMBIENCE", "Ambience Reverb", Kind::Effect, AMBIENCE_params, 17},
|
||||
{"MIX_TIGHTENER", "Mix Tightener", Kind::Effect, MIX_TIGHTENER_params, 1},
|
||||
{"TAPE_ENGINE", "Tape Engine", Kind::Effect, TAPE_ENGINE_params, 5},
|
||||
{"GRANULAR", "Granular Glitch", Kind::Effect, GRANULAR_params, 1},
|
||||
};
|
||||
inline constexpr int deviceCount = 17;
|
||||
|
||||
// Mix Tightener factory presets: name, then key/value pairs, nullptr-terminated.
|
||||
inline const char *const mixTightener0[] = {"808 Crisp", "cHiAtk", "3", "cHiMk", "2", "cHiRatio", "3", "cHiRel", "80", "cHiThr", "-24", "cLoAtk", "8", "cLoMk", "3", "cLoRatio", "4", "cLoRel", "140", "cLoThr", "-22", "cMidMk", "1", "cMidRatio", "2.5", "cMidThr", "-20", "eqHiFreq", "9000", "eqHiGain", "4", "eqLoFreq", "70", "eqLoGain", "4", "eqMidFreq", "450", "eqMidGain", "-2", "limCeil", "-0.3", "limRel", "80", "outGain", "2", "xHi", "3000", "xLo", "120", nullptr};
|
||||
inline const char *const mixTightener1[] = {"Boom-Bap Kit", "cLoAtk", "12", "cLoMk", "2", "cLoRatio", "3", "cLoRel", "160", "cLoThr", "-20", "cMidMk", "1", "cMidRatio", "2.5", "cMidThr", "-18", "eqHiFreq", "10000", "eqHiGain", "1.5", "eqLoFreq", "90", "eqLoGain", "2", "limCeil", "-0.5", "outGain", "1.5", "xHi", "2500", "xLo", "160", nullptr};
|
||||
inline const char *const mixTightener2[] = {"Trap Hats", "cHiAtk", "2", "cHiMk", "2", "cHiRatio", "4", "cHiRel", "60", "cHiThr", "-26", "cLoRatio", "1.5", "cMidRatio", "2", "eqHiFreq", "11000", "eqHiGain", "5", "eqMidFreq", "4000", "eqMidGain", "1", "limCeil", "-0.3", "outGain", "2", "xHi", "4000", nullptr};
|
||||
inline const char *const mixTightener3[] = {"Industrial Drums", "cHiMk", "2", "cHiRatio", "3", "cHiThr", "-20", "cLoAtk", "6", "cLoMk", "3", "cLoRatio", "5", "cLoRel", "120", "cLoThr", "-18", "cMidAtk", "8", "cMidMk", "3", "cMidRatio", "4", "cMidRel", "120", "cMidThr", "-16", "eqHiFreq", "8000", "eqHiGain", "2", "eqLoFreq", "80", "eqLoGain", "3", "eqMidFreq", "2200", "eqMidGain", "3", "eqMidQ", "1.2", "limCeil", "-0.2", "limRel", "60", "outGain", "3", "xHi", "2000", "xLo", "150", nullptr};
|
||||
inline const char *const mixTightener4[] = {"Techno Kick", "cHiRatio", "1.5", "cLoAtk", "4", "cLoMk", "3", "cLoRatio", "6", "cLoRel", "100", "cLoThr", "-16", "cMidRatio", "2", "eqLoFreq", "60", "eqLoGain", "3", "eqMidFreq", "700", "eqMidGain", "-2", "limCeil", "-0.2", "outGain", "2.5", "xHi", "3000", "xLo", "120", nullptr};
|
||||
inline const char *const mixTightener5[] = {"House Groove", "cHiMk", "1", "cHiRatio", "2", "cHiThr", "-22", "cLoMk", "1.5", "cLoRatio", "2.5", "cLoThr", "-22", "cMidMk", "1", "cMidRatio", "2", "cMidThr", "-20", "eqHiFreq", "9000", "eqHiGain", "1.5", "eqLoFreq", "90", "eqLoGain", "1.5", "limCeil", "-0.5", "outGain", "1.5", "strength", "0.85", "xHi", "2600", "xLo", "180", nullptr};
|
||||
inline const char *const mixTightener6[] = {"DnB Breaks", "cHiAtk", "2", "cHiMk", "2", "cHiRatio", "3", "cHiRel", "60", "cHiThr", "-22", "cLoAtk", "3", "cLoMk", "2", "cLoRatio", "4", "cLoRel", "90", "cLoThr", "-18", "cMidAtk", "4", "cMidMk", "2", "cMidRatio", "3", "cMidRel", "90", "cMidThr", "-18", "eqHiFreq", "9000", "eqHiGain", "2", "eqLoFreq", "80", "eqLoGain", "2", "eqMidFreq", "2500", "eqMidGain", "1.5", "limCeil", "-0.3", "limRel", "50", "outGain", "2", "xHi", "2500", "xLo", "150", nullptr};
|
||||
inline const char *const mixTightener7[] = {"Lo-Fi Kit", "cHiRatio", "1.5", "cLoMk", "1", "cLoRatio", "2.5", "cLoThr", "-22", "cMidRatio", "2", "eqHiFreq", "6000", "eqHiGain", "-4", "eqLoFreq", "100", "eqLoGain", "2", "eqMidFreq", "500", "eqMidGain", "1", "limCeil", "-1", "outGain", "1", "strength", "0.8", "xHi", "2200", "xLo", "200", nullptr};
|
||||
inline const char *const mixTightener8[] = {"Snare Crack", "cHiAtk", "2", "cHiMk", "2", "cHiRatio", "3", "cHiRel", "70", "cHiThr", "-22", "cLoRatio", "1.5", "cMidAtk", "3", "cMidMk", "2", "cMidRatio", "4", "cMidRel", "100", "cMidThr", "-18", "eqHiFreq", "8000", "eqHiGain", "3", "eqLoFreq", "200", "eqLoGain", "-2", "eqMidFreq", "2000", "eqMidGain", "3", "eqMidQ", "1.5", "limCeil", "-0.3", "outGain", "2", "xHi", "1800", "xLo", "250", nullptr};
|
||||
inline const char *const mixTightener9[] = {"Clap Snap", "cHiAtk", "2", "cHiMk", "2", "cHiRatio", "3", "cLoRatio", "1.5", "cMidAtk", "3", "cMidMk", "1", "cMidRatio", "3", "eqHiFreq", "9000", "eqHiGain", "4", "eqMidFreq", "1500", "eqMidGain", "2", "outGain", "2", "xHi", "3000", nullptr};
|
||||
inline const char *const mixTightener10[] = {"Cymbal Sheen", "cHiAtk", "5", "cHiMk", "1", "cHiRatio", "2.5", "cHiRel", "120", "cHiThr", "-26", "eqHiFreq", "12000", "eqHiGain", "4", "eqMidFreq", "3000", "eqMidGain", "-1", "limCeil", "-0.5", "outGain", "1.5", "strength", "0.75", "xHi", "5000", nullptr};
|
||||
inline const char *const mixTightener11[] = {"Percussion Tight", "cHiMk", "1", "cHiRatio", "2.5", "cLoMk", "1", "cLoRatio", "2", "cMidAtk", "4", "cMidMk", "1.5", "cMidRatio", "3", "eqHiFreq", "8000", "eqHiGain", "2", "eqMidFreq", "2500", "eqMidGain", "1.5", "outGain", "1.5", "xHi", "2500", "xLo", "200", nullptr};
|
||||
inline const char *const mixTightener12[] = {"EBM Bass", "cHiRatio", "1.5", "cLoAtk", "10", "cLoMk", "3", "cLoRatio", "4", "cLoRel", "130", "cLoThr", "-18", "cMidAtk", "12", "cMidMk", "2", "cMidRatio", "3", "cMidRel", "130", "cMidThr", "-18", "eqHiFreq", "9000", "eqHiGain", "-2", "eqLoFreq", "80", "eqLoGain", "3", "eqMidFreq", "800", "eqMidGain", "2", "eqMidQ", "1.2", "limCeil", "-0.3", "outGain", "2.5", "xHi", "1500", "xLo", "150", nullptr};
|
||||
inline const char *const mixTightener13[] = {"Reese Bass", "cHiRatio", "1.5", "cLoAtk", "8", "cLoMk", "3", "cLoRatio", "5", "cLoRel", "120", "cLoThr", "-16", "cMidMk", "2", "cMidRatio", "3", "cMidThr", "-18", "eqLoFreq", "70", "eqLoGain", "2", "eqMidFreq", "500", "eqMidGain", "2", "limCeil", "-0.3", "outGain", "2", "xHi", "1200", "xLo", "140", nullptr};
|
||||
inline const char *const mixTightener14[] = {"Acid 303", "cHiRatio", "2", "cLoMk", "2", "cLoRatio", "3", "cMidAtk", "6", "cMidMk", "2", "cMidRatio", "4", "cMidRel", "110", "cMidThr", "-18", "eqLoFreq", "90", "eqLoGain", "1", "eqMidFreq", "1200", "eqMidGain", "3", "eqMidQ", "1.5", "limCeil", "-0.4", "outGain", "2", "xHi", "1800", "xLo", "160", nullptr};
|
||||
inline const char *const mixTightener15[] = {"Sub Bass Tame", "cHiRatio", "1.2", "cLoAtk", "12", "cLoMk", "3", "cLoRatio", "6", "cLoRel", "150", "cLoThr", "-14", "cMidRatio", "2", "eqLoFreq", "55", "eqLoGain", "2", "eqMidFreq", "900", "eqMidGain", "-2", "limCeil", "-0.5", "outGain", "2", "strength", "0.9", "xHi", "2000", "xLo", "120", nullptr};
|
||||
inline const char *const mixTightener16[] = {"FM Bass Punch", "cHiRatio", "2", "cLoAtk", "6", "cLoMk", "2", "cLoRatio", "4", "cLoRel", "110", "cLoThr", "-18", "cMidMk", "1.5", "cMidRatio", "3", "cMidThr", "-18", "eqLoFreq", "90", "eqLoGain", "2", "eqMidFreq", "1000", "eqMidGain", "1.5", "limCeil", "-0.3", "outGain", "2", "xHi", "2200", "xLo", "160", nullptr};
|
||||
inline const char *const mixTightener17[] = {"Goth Bass", "cHiRatio", "1.5", "cLoAtk", "10", "cLoMk", "3", "cLoRatio", "4", "cLoRel", "140", "cLoThr", "-18", "cMidMk", "1", "cMidRatio", "2.5", "eqHiFreq", "8000", "eqHiGain", "-2", "eqLoFreq", "75", "eqLoGain", "3", "eqMidFreq", "600", "eqMidGain", "-1", "limCeil", "-0.5", "outGain", "2", "strength", "0.9", "xHi", "1600", "xLo", "140", nullptr};
|
||||
inline const char *const mixTightener18[] = {"Synthwave Bass", "cHiRatio", "2", "cLoAtk", "10", "cLoMk", "2", "cLoRatio", "3", "cLoRel", "130", "cLoThr", "-20", "cMidMk", "1", "cMidRatio", "2.5", "eqHiFreq", "7000", "eqHiGain", "1", "eqLoFreq", "80", "eqLoGain", "2.5", "eqMidFreq", "900", "eqMidGain", "1", "limCeil", "-0.5", "outGain", "1.8", "xHi", "2000", "xLo", "150", nullptr};
|
||||
inline const char *const mixTightener19[] = {"Synthwave Lead", "cHiMk", "1.5", "cHiRatio", "2", "cHiThr", "-22", "cLoRatio", "1.5", "cMidAtk", "12", "cMidMk", "1.5", "cMidRatio", "2.5", "cMidRel", "150", "cMidThr", "-20", "eqHiFreq", "9000", "eqHiGain", "4", "eqLoFreq", "200", "eqLoGain", "-1", "eqMidFreq", "2000", "eqMidGain", "1.5", "limCeil", "-0.5", "outGain", "2", "strength", "0.85", "xHi", "3000", "xLo", "300", nullptr};
|
||||
inline const char *const mixTightener20[] = {"Cutting Lead", "cHiMk", "1", "cHiRatio", "2", "cLoRatio", "1.5", "cMidAtk", "8", "cMidMk", "2", "cMidRatio", "3", "cMidRel", "130", "cMidThr", "-18", "eqHiFreq", "8000", "eqHiGain", "2", "eqLoFreq", "200", "eqLoGain", "-2", "eqMidFreq", "3000", "eqMidGain", "3", "eqMidQ", "1.2", "limCeil", "-0.4", "outGain", "2", "xHi", "3500", "xLo", "300", nullptr};
|
||||
inline const char *const mixTightener21[] = {"Darkwave Pad", "cHiRatio", "2", "cLoMk", "1", "cLoRatio", "2", "cMidAtk", "20", "cMidMk", "1", "cMidRatio", "2", "cMidRel", "200", "cMidThr", "-24", "eqHiFreq", "8000", "eqHiGain", "-2", "eqLoFreq", "150", "eqLoGain", "1", "eqMidFreq", "1000", "eqMidGain", "0.5", "limCeil", "-1", "outGain", "1", "strength", "0.7", "xHi", "2500", "xLo", "250", nullptr};
|
||||
inline const char *const mixTightener22[] = {"Ambient Wash", "cMidAtk", "30", "cMidMk", "0.5", "cMidRatio", "1.8", "cMidRel", "250", "cMidThr", "-26", "eqHiFreq", "10000", "eqHiGain", "1", "eqLoFreq", "120", "eqLoGain", "1", "limCeil", "-1.5", "outGain", "0.5", "strength", "0.6", "xHi", "3000", "xLo", "300", nullptr};
|
||||
inline const char *const mixTightener23[] = {"Pluck Tight", "cHiAtk", "2", "cHiMk", "1.5", "cHiRatio", "2.5", "cHiRel", "70", "cHiThr", "-22", "cLoRatio", "1.5", "cMidAtk", "3", "cMidMk", "1.5", "cMidRatio", "3", "cMidRel", "100", "cMidThr", "-18", "eqHiFreq", "9000", "eqHiGain", "3", "eqMidFreq", "2500", "eqMidGain", "2", "outGain", "1.5", "xHi", "3000", "xLo", "300", nullptr};
|
||||
inline const char *const mixTightener24[] = {"Arp Sparkle", "cHiAtk", "4", "cHiMk", "1.5", "cHiRatio", "2.5", "cHiThr", "-24", "cMidMk", "1", "cMidRatio", "2", "eqHiFreq", "11000", "eqHiGain", "4", "eqMidFreq", "3000", "eqMidGain", "1", "limCeil", "-0.5", "outGain", "1.5", "strength", "0.8", "xHi", "4000", nullptr};
|
||||
inline const char *const mixTightener25[] = {"Chip Lead", "cHiMk", "1", "cHiRatio", "2", "cLoRatio", "1.2", "cMidMk", "2", "cMidRatio", "3", "cMidThr", "-18", "eqHiFreq", "8000", "eqHiGain", "2", "eqLoFreq", "150", "eqLoGain", "-3", "eqMidFreq", "2500", "eqMidGain", "2.5", "eqMidQ", "1.2", "limCeil", "-0.4", "outGain", "2", "xHi", "3000", "xLo", "350", nullptr};
|
||||
inline const char *const mixTightener26[] = {"Bell Clarity", "cHiAtk", "4", "cHiMk", "1", "cHiRatio", "2", "cMidAtk", "6", "cMidMk", "1", "cMidRatio", "2", "eqHiFreq", "10000", "eqHiGain", "3", "eqMidFreq", "1800", "eqMidGain", "1.5", "limCeil", "-0.5", "outGain", "1", "strength", "0.75", "xHi", "4000", nullptr};
|
||||
inline const char *const mixTightener27[] = {"Keys Clarity", "cHiMk", "1", "cHiRatio", "2", "cLoRatio", "1.8", "cMidAtk", "10", "cMidMk", "1", "cMidRatio", "2.5", "cMidRel", "150", "cMidThr", "-22", "eqHiFreq", "9000", "eqHiGain", "2", "eqLoFreq", "200", "eqLoGain", "-1", "eqMidFreq", "2500", "eqMidGain", "1.5", "limCeil", "-0.5", "outGain", "1.5", "strength", "0.8", "xHi", "3000", "xLo", "250", nullptr};
|
||||
inline const char *const mixTightener28[] = {"Mix Glue", "cHiAtk", "15", "cHiMk", "1", "cHiRatio", "2", "cHiRel", "180", "cHiThr", "-22", "cLoAtk", "20", "cLoMk", "1", "cLoRatio", "2", "cLoRel", "200", "cLoThr", "-22", "cMidAtk", "25", "cMidMk", "1", "cMidRatio", "2", "cMidRel", "200", "cMidThr", "-22", "eqHiFreq", "10000", "eqHiGain", "1", "eqLoFreq", "100", "eqLoGain", "0.5", "limCeil", "-0.8", "outGain", "1", "strength", "0.7", "xHi", "2500", "xLo", "200", nullptr};
|
||||
inline const char *const mixTightener29[] = {"Loudness Max", "cHiMk", "2", "cHiRatio", "3", "cHiThr", "-20", "cLoMk", "2", "cLoRatio", "3", "cLoThr", "-20", "cMidMk", "2", "cMidRatio", "3", "cMidThr", "-18", "eqHiFreq", "9000", "eqHiGain", "2", "eqLoFreq", "90", "eqLoGain", "1", "limCeil", "-0.1", "limRel", "40", "outGain", "4", "xHi", "2800", "xLo", "180", nullptr};
|
||||
inline const char *const *const mixTightenerPresets[] = {mixTightener0, mixTightener1, mixTightener2, mixTightener3, mixTightener4, mixTightener5, mixTightener6, mixTightener7, mixTightener8, mixTightener9, mixTightener10, mixTightener11, mixTightener12, mixTightener13, mixTightener14, mixTightener15, mixTightener16, mixTightener17, mixTightener18, mixTightener19, mixTightener20, mixTightener21, mixTightener22, mixTightener23, mixTightener24, mixTightener25, mixTightener26, mixTightener27, mixTightener28, mixTightener29, nullptr};
|
||||
|
||||
} // namespace sizzle::gen
|
||||
@@ -0,0 +1,27 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "sizzle/Params.hpp"
|
||||
|
||||
namespace sizzle {
|
||||
|
||||
/**
|
||||
* An insert effect: the C++ twin of AudioEffect in Effects.kt. `update` refreshes
|
||||
* cached settings (call it when the params change, and once before processing);
|
||||
* `process` runs per mono sample and must never allocate or lock. Construct on a
|
||||
* normal thread: constructors allocate delay lines for [sampleRate].
|
||||
*/
|
||||
class Effect {
|
||||
public:
|
||||
virtual ~Effect() = default;
|
||||
virtual void update(const Params &p, float tempoBpm) = 0;
|
||||
virtual float process(float x) = 0;
|
||||
|
||||
/** The effect for ToolboxType name [type] ("DELAY", "FILTER", …), or nullptr
|
||||
* for types without an audio processor (the MIDI effects) or not ported yet. */
|
||||
static std::unique_ptr<Effect> create(const char *type, int sampleRate);
|
||||
};
|
||||
|
||||
} // namespace sizzle
|
||||
@@ -0,0 +1,45 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#pragma once
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include "sizzle/Specs.hpp"
|
||||
|
||||
namespace sizzle {
|
||||
|
||||
/**
|
||||
* A device's settings, the C++ twin of ToolboxSlot's string map: every value is
|
||||
* kept as text so `f()` / `s()` read exactly what the Kotlin `slot.float()` /
|
||||
* `slot.string()` would. Fixed capacity, no allocation: safe to read from
|
||||
* `Effect::update` on the audio thread. Keys are stored by copy, so values can
|
||||
* come from a file (tests), a preset, or AU parameters.
|
||||
*/
|
||||
class Params {
|
||||
public:
|
||||
static constexpr int kMax = 96;
|
||||
static constexpr int kKeyLen = 24;
|
||||
static constexpr int kValLen = 32;
|
||||
|
||||
/** All of [spec]'s defaults, like ToolboxSlot.fill(). */
|
||||
void fill(const DeviceSpec &spec);
|
||||
void set(const char *key, const char *value);
|
||||
void set(const char *key, float value);
|
||||
/** Number as Kotlin's String.toFloat would parse it, else [fallback]. */
|
||||
float f(const char *key, float fallback = 0.f) const;
|
||||
/** The stored text (enum choice name), else [fallback]. */
|
||||
const char *s(const char *key, const char *fallback = "") const;
|
||||
bool has(const char *key) const { return find(key) >= 0; }
|
||||
/** Stored entries in insertion order (for saving state). */
|
||||
int size() const { return n_; }
|
||||
const char *keyAt(int i) const { return keys_[i]; }
|
||||
const char *valueAt(int i) const { return vals_[i]; }
|
||||
|
||||
private:
|
||||
int find(const char *key) const;
|
||||
char keys_[kMax][kKeyLen] = {};
|
||||
char vals_[kMax][kValLen] = {};
|
||||
int n_ = 0;
|
||||
};
|
||||
|
||||
} // namespace sizzle
|
||||
@@ -0,0 +1,35 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#pragma once
|
||||
|
||||
// Plain descriptions of Sizzle's devices and their parameters. The tables
|
||||
// themselves are generated from the Android app (DeviceSpecs.gen.hpp).
|
||||
|
||||
namespace sizzle {
|
||||
|
||||
enum class Kind { Instrument, Effect };
|
||||
|
||||
/** One parameter, as ToolboxType's ParamSpec: choices != nullptr marks an enum
|
||||
* (nullptr-terminated list of names; the default is an index into it). */
|
||||
struct ParamSpec {
|
||||
const char *key;
|
||||
const char *label;
|
||||
float def, min, max;
|
||||
bool isInt;
|
||||
const char *const *choices;
|
||||
bool isEnum() const { return choices != nullptr; }
|
||||
int choiceCount() const { int n = 0; if (choices) while (choices[n]) ++n; return n; }
|
||||
};
|
||||
|
||||
struct DeviceSpec {
|
||||
const char *type; // ToolboxType name, e.g. "BITCRUSHER"
|
||||
const char *displayName;
|
||||
Kind kind;
|
||||
const ParamSpec *params;
|
||||
int paramCount;
|
||||
};
|
||||
|
||||
/** The device with ToolboxType name [type], or nullptr. */
|
||||
const DeviceSpec *findDevice(const char *type);
|
||||
|
||||
} // namespace sizzle
|
||||
@@ -0,0 +1,65 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "sizzle/Params.hpp"
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
|
||||
namespace sizzle {
|
||||
|
||||
void Params::fill(const DeviceSpec &spec) {
|
||||
n_ = 0;
|
||||
for (int i = 0; i < spec.paramCount; ++i) {
|
||||
const ParamSpec &p = spec.params[i];
|
||||
if (p.isEnum()) {
|
||||
int idx = (int)p.def;
|
||||
int n = p.choiceCount();
|
||||
if (idx < 0) idx = 0;
|
||||
if (idx > n - 1) idx = n - 1;
|
||||
set(p.key, p.choices[idx]);
|
||||
} else {
|
||||
set(p.key, p.def);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int Params::find(const char *key) const {
|
||||
for (int i = 0; i < n_; ++i) if (std::strcmp(keys_[i], key) == 0) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void Params::set(const char *key, const char *value) {
|
||||
int i = find(key);
|
||||
if (i < 0) {
|
||||
if (n_ >= kMax) return;
|
||||
i = n_++;
|
||||
std::snprintf(keys_[i], kKeyLen, "%s", key);
|
||||
}
|
||||
std::snprintf(vals_[i], kValLen, "%s", value);
|
||||
}
|
||||
|
||||
void Params::set(const char *key, float value) {
|
||||
// Shortest text that reads back as the same float (Kotlin stores toString()).
|
||||
char buf[kValLen];
|
||||
std::snprintf(buf, sizeof buf, "%.9g", (double)value);
|
||||
set(key, buf);
|
||||
}
|
||||
|
||||
float Params::f(const char *key, float fallback) const {
|
||||
int i = find(key);
|
||||
if (i < 0) return fallback;
|
||||
const char *s = vals_[i];
|
||||
while (std::isspace((unsigned char)*s)) ++s;
|
||||
if (!*s) return fallback;
|
||||
char *end = nullptr;
|
||||
float v = std::strtof(s, &end);
|
||||
while (end && std::isspace((unsigned char)*end)) ++end;
|
||||
return (end && *end == '\0') ? v : fallback;
|
||||
}
|
||||
|
||||
const char *Params::s(const char *key, const char *fallback) const {
|
||||
int i = find(key);
|
||||
return i < 0 ? fallback : vals_[i];
|
||||
}
|
||||
|
||||
} // namespace sizzle
|
||||
@@ -0,0 +1,14 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include <cstring>
|
||||
#include "sizzle/DeviceSpecs.gen.hpp"
|
||||
|
||||
namespace sizzle {
|
||||
|
||||
const DeviceSpec *findDevice(const char *type) {
|
||||
for (const auto &d : gen::devices) if (std::strcmp(d.type, type) == 0) return &d;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace sizzle
|
||||
@@ -0,0 +1,401 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// Port of AmbienceReverb.kt: mono 8-line FDN reverb (OTODESK "Ambience" style) with
|
||||
// predelay, early reflections, input diffusers, nested allpasses, xorshift-noise
|
||||
// LFOs, ducking and wet saturation. Line-for-line; Float stays float.
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
#include "sizzle/Effect.hpp"
|
||||
#include "KotlinMath.hpp"
|
||||
|
||||
// The JVM never fuses a*b+c; keep the compiler from contracting into FMA.
|
||||
#if defined(__clang__)
|
||||
#pragma clang fp contract(off)
|
||||
#endif
|
||||
|
||||
namespace sizzle {
|
||||
namespace {
|
||||
|
||||
constexpr int N = 8;
|
||||
const float FWHT_NORM = 1.f / kt::sqrtf_((float)N);
|
||||
constexpr float LATE_SCALE = 2.f / N;
|
||||
constexpr int MAX_ER = 12;
|
||||
constexpr int MAX_ER_ACTIVE = 6;
|
||||
constexpr float PHI = 1.6180339887f;
|
||||
constexpr float TWO_PI = 6.28318530718f;
|
||||
|
||||
const float ALGO_HF[] = {0.00f, 0.26f, 0.26f, 0.22f, 0.36f, 0.14f, 0.30f};
|
||||
const float ALGO_OFFSET_DB[] = {0.8f, 0.9f, 0.5f, 0.5f, 1.5f, 0.6f, 0.6f};
|
||||
const float ALGO_SAT_MUL[] = {0.90f, 0.90f, 0.93f, 0.93f, 1.00f, 1.05f, 1.02f};
|
||||
const float SIGN_FLIP[N] = {1.f, -1.f, 1.f, -1.f, -1.f, 1.f, -1.f, 1.f};
|
||||
|
||||
const char *const ALGORITHMS[] = {"Room 1", "Room 2", "Hall 1", "Hall 2", "Plate", "Spring", "Goldfoil"};
|
||||
|
||||
const float ER_ROOM1[] = {
|
||||
5.2f, 0.65f, 8.7f, 0.58f, 12.4f, 0.52f, 15.8f, 0.46f, 19.3f, 0.42f, 24.1f, 0.36f,
|
||||
28.6f, 0.32f, 33.5f, 0.28f, 38.9f, 0.24f, 45.2f, 0.20f, 52.8f, 0.16f, 62.4f, 0.13f,
|
||||
};
|
||||
const float ER_ROOM2[] = {
|
||||
7.5f, 0.62f, 12.3f, 0.55f, 17.1f, 0.49f, 22.8f, 0.43f, 28.5f, 0.38f, 34.2f, 0.33f,
|
||||
41.6f, 0.28f, 49.3f, 0.24f, 57.8f, 0.20f, 67.5f, 0.17f, 78.2f, 0.14f, 90.6f, 0.11f,
|
||||
};
|
||||
const float ER_HALL1[] = {
|
||||
12.0f, 0.58f, 18.5f, 0.52f, 25.7f, 0.47f, 33.4f, 0.42f, 42.1f, 0.38f, 51.6f, 0.33f,
|
||||
62.3f, 0.29f, 73.9f, 0.25f, 86.5f, 0.21f, 99.8f, 0.18f, 113.4f, 0.15f, 128.7f, 0.12f,
|
||||
};
|
||||
const float ER_HALL2[] = {
|
||||
16.5f, 0.55f, 24.8f, 0.50f, 33.7f, 0.45f, 43.5f, 0.40f, 54.2f, 0.36f, 65.8f, 0.32f,
|
||||
78.4f, 0.28f, 92.1f, 0.24f, 107.3f, 0.21f, 123.6f, 0.18f, 141.2f, 0.15f, 160.5f, 0.12f,
|
||||
};
|
||||
const float *const ER_PATTERNS[] = {ER_ROOM1, ER_ROOM2, ER_HALL1, ER_HALL2, nullptr, nullptr, nullptr};
|
||||
const int ER_PATTERN_SIZE[] = {24, 24, 24, 24, 0, 0, 0};
|
||||
|
||||
inline float lnf_(float x) { return (float)std::log((double)x); }
|
||||
inline float floorf_(float x) { return (float)std::floor((double)x); }
|
||||
|
||||
inline float pow10(float x) { return kt::expf_(x * 2.302585093f); }
|
||||
inline float db2lin(float db) { return pow10(db / 20.f); }
|
||||
|
||||
/** In-place size-N Fast Walsh-Hadamard transform, normalised (÷√N) → orthonormal. */
|
||||
void fwht(float *v) {
|
||||
int h = 1;
|
||||
while (h < N) {
|
||||
int i = 0;
|
||||
while (i < N) {
|
||||
int j = i;
|
||||
while (j < i + h) {
|
||||
float a = v[j]; float b = v[j + h];
|
||||
v[j] = a + b; v[j + h] = a - b;
|
||||
j++;
|
||||
}
|
||||
i += h * 2;
|
||||
}
|
||||
h *= 2;
|
||||
}
|
||||
for (int k = 0; k < N; ++k) v[k] *= FWHT_NORM;
|
||||
}
|
||||
|
||||
bool isPrime(int n) {
|
||||
if (n < 2) return false;
|
||||
if (n == 2) return true;
|
||||
if (n % 2 == 0) return false;
|
||||
int i = 3;
|
||||
while (i * i <= n) { if (n % i == 0) return false; i += 2; }
|
||||
return true;
|
||||
}
|
||||
|
||||
bool usedNone(const int *used, int count, int v) {
|
||||
for (int k = 0; k < count; ++k) if (used[k] == v) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
int nearestUniquePrime(int target, const int *used, int count) {
|
||||
int t = std::max(target, 2);
|
||||
int offset = 0;
|
||||
while (offset < 100000) {
|
||||
int hi = t + offset;
|
||||
if (isPrime(hi) && usedNone(used, count, hi)) return hi;
|
||||
int lo = t - offset;
|
||||
if (offset > 0 && lo >= 2 && isPrime(lo) && usedNone(used, count, lo)) return lo;
|
||||
offset++;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
float softClip(float x) {
|
||||
if (x > 1.f) return 1.f - 1.f / (x + 1.f);
|
||||
if (x < -1.f) return -1.f + 1.f / (-x + 1.f);
|
||||
return x;
|
||||
}
|
||||
|
||||
/** A power-of-two circular buffer with fractional (linear-interpolated) reads. */
|
||||
class DelayLine {
|
||||
std::vector<float> buf;
|
||||
int mask;
|
||||
int w = 0;
|
||||
|
||||
public:
|
||||
explicit DelayLine(int size) {
|
||||
int p = 1;
|
||||
while (p < size) p *= 2;
|
||||
buf.assign((size_t)p, 0.f);
|
||||
mask = p - 1;
|
||||
}
|
||||
float maxDelay() const { return (float)(mask - 2); }
|
||||
void write(float x) { buf[(size_t)w] = x; w = (w + 1) & mask; }
|
||||
float read(float delay) const {
|
||||
float d = kt::coerceIn(delay, 1.f, (float)mask - 1.f);
|
||||
float rp = (float)w - d;
|
||||
float i0f = floorf_(rp);
|
||||
float frac = rp - i0f;
|
||||
int i0 = kt::toInt(i0f) & mask;
|
||||
int i1 = (i0 + 1) & mask;
|
||||
return buf[(size_t)i0] * (1.f - frac) + buf[(size_t)i1] * frac;
|
||||
}
|
||||
};
|
||||
|
||||
class AmbienceReverb final : public Effect {
|
||||
float fs;
|
||||
|
||||
DelayLine preDelay;
|
||||
DelayLine erLine;
|
||||
std::vector<DelayLine> diffusers;
|
||||
std::vector<DelayLine> fdn;
|
||||
std::vector<DelayLine> apf;
|
||||
|
||||
float fbVec[N] = {};
|
||||
float fbScratch[N] = {};
|
||||
float nextFb[N] = {};
|
||||
float baseDelay[N] = {};
|
||||
float decayGain[N] = {};
|
||||
float hfState[N] = {};
|
||||
float lfState[N] = {};
|
||||
float freqMod[N];
|
||||
float apfBase[N];
|
||||
float diffuserSmp[4];
|
||||
|
||||
int32_t lfoState[N];
|
||||
float lfoSmooth[N] = {};
|
||||
float lfoCoeff[N] = {};
|
||||
float lfoRateMul[N];
|
||||
|
||||
float hfCoeff = 1.f;
|
||||
float lfCoeff = 0.f;
|
||||
float lfAmt = 0.f;
|
||||
float apfGain = 0.5f;
|
||||
float diffusionSens = 1.f;
|
||||
bool bypassER = false;
|
||||
float makeup = 1.f;
|
||||
float satMul = 1.f;
|
||||
float modDepthScale = 1.f;
|
||||
int erCount = 0;
|
||||
float erDelaySmp[MAX_ER] = {};
|
||||
float erGain[MAX_ER] = {};
|
||||
|
||||
float wetLin = 0.63f;
|
||||
float dryLin = 1.f;
|
||||
float preDelaySmp = 480.f;
|
||||
float modDepth = 0.f;
|
||||
float diffGain = 0.63f;
|
||||
float effApfGain = 0.4f;
|
||||
float satAmt = 0.f;
|
||||
float erLevel = 0.6f;
|
||||
float duckAmtDb = 0.f;
|
||||
float duckThreshDb = -20.f;
|
||||
float duckThreshLin = 0.1f;
|
||||
float duckAtt = 0.01f;
|
||||
float duckRel = 0.001f;
|
||||
float duckEnv = 0.f;
|
||||
|
||||
float dc1 = 0.f;
|
||||
float dcY = 0.f;
|
||||
|
||||
int lastAlgo = -1;
|
||||
float lastSize = NAN;
|
||||
float lastDecay = NAN;
|
||||
float lastHf = NAN;
|
||||
float lastLf = NAN;
|
||||
float lastDiffusion = NAN;
|
||||
|
||||
void recompute(int algo, float size, float decay, float hf, float lf, float diffusion) {
|
||||
(void)diffusion;
|
||||
switch (algo) {
|
||||
case 0: case 1: apfGain = 0.3f; diffusionSens = 1.f; bypassER = false; break;
|
||||
case 2: case 3: apfGain = 0.618f; diffusionSens = 1.f; bypassER = false; break;
|
||||
case 4: apfGain = 0.7f; diffusionSens = 0.7f; bypassER = true; break;
|
||||
case 5: apfGain = 0.5f; diffusionSens = 0.5f; bypassER = true; break;
|
||||
default: apfGain = 0.75f; diffusionSens = 0.8f; bypassER = true; break;
|
||||
}
|
||||
|
||||
float sizeCoeff = kt::coerceIn(size + 0.5f, 0.5f, 2.f);
|
||||
float minMs = 15.f + sizeCoeff * 7.5f;
|
||||
float maxMs = 50.f + sizeCoeff * 75.f;
|
||||
int minS = std::max(11, kt::toInt(minMs * 0.001f * fs));
|
||||
int maxS = kt::coerceAtLeast(kt::toInt(maxMs * 0.001f * fs), minS + 1);
|
||||
float logMin = lnf_((float)minS);
|
||||
float logMax = lnf_((float)maxS);
|
||||
int used[N] = {};
|
||||
for (int i = 0; i < N; ++i) {
|
||||
float t = (float)i / ((float)N - 1.f);
|
||||
int target = kt::toInt(kt::expf_(logMin + t * (logMax - logMin)));
|
||||
int p = nearestUniquePrime(target, used, i);
|
||||
used[i] = p;
|
||||
baseDelay[i] = kt::coerceAtMost((float)p, fdn[(size_t)i].maxDelay());
|
||||
}
|
||||
|
||||
for (int i = 0; i < N; ++i) {
|
||||
float tSec = baseDelay[i] / fs;
|
||||
decayGain[i] = kt::coerceIn(pow10(-3.f * tSec / decay), 0.f, 0.9995f);
|
||||
}
|
||||
|
||||
float totalHf = kt::coerceIn(hf + ALGO_HF[algo], 0.f, 0.95f);
|
||||
float hfCut = 16000.f * (1.f - totalHf) + 700.f * totalHf;
|
||||
hfCoeff = kt::coerceIn(1.f - kt::expf_(-TWO_PI * hfCut / fs), 0.02f, 1.f);
|
||||
lfCoeff = kt::coerceIn(1.f - kt::expf_(-TWO_PI * 200.f / fs), 0.f, 1.f);
|
||||
lfAmt = lf * 0.9f;
|
||||
|
||||
modDepthScale = 1.f + kt::coerceIn((decay - 1.f) * 0.5f, 0.f, 2.f);
|
||||
|
||||
float decayCompDb = 7.f * kt::log10f_(kt::coerceAtLeast(decay, 0.1f));
|
||||
makeup = db2lin(16.f + decayCompDb + ALGO_OFFSET_DB[algo]);
|
||||
satMul = ALGO_SAT_MUL[algo];
|
||||
|
||||
const float *pattern = ER_PATTERNS[algo];
|
||||
erCount = bypassER ? 0 : std::min(ER_PATTERN_SIZE[algo] / 2, MAX_ER_ACTIVE);
|
||||
float erSizeScale = 0.5f + size;
|
||||
for (int t = 0; t < erCount; ++t) {
|
||||
erDelaySmp[t] = kt::coerceIn(pattern[t * 2] * 0.001f * fs * erSizeScale, 1.f, erLine.maxDelay());
|
||||
erGain[t] = pattern[t * 2 + 1];
|
||||
}
|
||||
}
|
||||
|
||||
float nextLfo(int i) {
|
||||
uint32_t s = (uint32_t)lfoState[i];
|
||||
s = s ^ (s << 13); s = s ^ (s >> 17); s = s ^ (s << 5);
|
||||
lfoState[i] = (int32_t)s;
|
||||
float n = (float)s * 2.3283064e-10f * 2.f - 1.f;
|
||||
lfoSmooth[i] += (n - lfoSmooth[i]) * lfoCoeff[i];
|
||||
return lfoSmooth[i];
|
||||
}
|
||||
|
||||
public:
|
||||
explicit AmbienceReverb(int sampleRate)
|
||||
: fs((float)sampleRate),
|
||||
preDelay(kt::toInt(fs * 0.55f)),
|
||||
erLine(kt::toInt(fs * 0.6f)) {
|
||||
diffusers.reserve(4);
|
||||
for (int i = 0; i < 4; ++i) diffusers.emplace_back(kt::toInt(fs * 0.03f));
|
||||
fdn.reserve(N);
|
||||
apf.reserve(N);
|
||||
for (int i = 0; i < N; ++i) fdn.emplace_back(kt::toInt(fs * 0.3f));
|
||||
for (int i = 0; i < N; ++i) apf.emplace_back(kt::toInt(fs * 0.03f));
|
||||
for (int it = 0; it < N; ++it) {
|
||||
freqMod[it] = 0.5f + (1.f - (float)it / ((float)N - 1.f));
|
||||
apfBase[it] = (2.3f + (float)it * 0.37f) * 0.001f * fs;
|
||||
lfoState[it] = 12345 + it * 9876;
|
||||
float a = (float)it * PHI;
|
||||
lfoRateMul[it] = 0.8f + (a - floorf_(a)) * 0.4f;
|
||||
}
|
||||
for (int it = 0; it < 4; ++it) diffuserSmp[it] = (3.f + (float)it * 2.f) * 0.001f * fs;
|
||||
}
|
||||
|
||||
void update(const Params &p, float) override {
|
||||
const char *algoName = p.s("algo", "Room 1");
|
||||
int algo = -1;
|
||||
for (int k = 0; k < 7; ++k) if (std::strcmp(ALGORITHMS[k], algoName) == 0) { algo = k; break; }
|
||||
algo = kt::coerceIn(algo, 0, 6);
|
||||
float size = kt::coerceIn(p.f("roomsize", 1.f), 0.3f, 2.f);
|
||||
float decay = kt::coerceIn(p.f("decay", 1.5f), 0.1f, 20.f);
|
||||
float hf = kt::coerceIn(p.f("hfdamp", 0.f), 0.f, 1.f);
|
||||
float lf = kt::coerceIn(p.f("lfabsorb", 0.f), 0.f, 1.f);
|
||||
float diffusion = kt::coerceIn(p.f("diffusion", 0.7f), 0.f, 1.f);
|
||||
|
||||
wetLin = db2lin(p.f("wet", -4.f));
|
||||
dryLin = db2lin(p.f("dry", 0.f));
|
||||
preDelaySmp = kt::coerceIn(p.f("predelay", 10.f), 0.f, 500.f) * 0.001f * fs;
|
||||
erLevel = kt::coerceIn(p.f("erlevel", 0.6f), 0.f, 1.f);
|
||||
satAmt = kt::coerceIn(p.f("saturation", 0.f), 0.f, 1.f);
|
||||
float modAmt = kt::coerceIn(p.f("modamt", 0.25f), 0.f, 1.f);
|
||||
float modRate = kt::coerceIn(p.f("modrate", 0.5f), 0.05f, 2.f);
|
||||
// Uses the modDepthScale from the previous recompute (as the Kotlin does).
|
||||
modDepth = modAmt * modAmt * 0.001f * fs * modDepthScale;
|
||||
for (int i = 0; i < N; ++i) {
|
||||
lfoCoeff[i] = kt::coerceIn(1.f - kt::expf_(-TWO_PI * modRate * lfoRateMul[i] / fs), 0.0001f, 0.9999f);
|
||||
}
|
||||
duckAmtDb = kt::coerceIn(p.f("duckamt", 0.f), 0.f, 20.f);
|
||||
duckThreshDb = p.f("duckthresh", -20.f);
|
||||
duckThreshLin = db2lin(duckThreshDb);
|
||||
duckAtt = 1.f - kt::expf_(-1.f / (fs * kt::coerceAtLeast(p.f("duckattack", 10.f), 0.1f) * 0.001f));
|
||||
duckRel = 1.f - kt::expf_(-1.f / (fs * kt::coerceAtLeast(p.f("duckrelease", 200.f), 0.1f) * 0.001f));
|
||||
float effDiff = diffusion * diffusionSens;
|
||||
diffGain = 0.25f + effDiff * 0.55f;
|
||||
effApfGain = apfGain * (0.6f + effDiff * 0.4f) * 0.78f;
|
||||
|
||||
if (algo != lastAlgo || size != lastSize || decay != lastDecay ||
|
||||
hf != lastHf || lf != lastLf || diffusion != lastDiffusion) {
|
||||
lastAlgo = algo; lastSize = size; lastDecay = decay;
|
||||
lastHf = hf; lastLf = lf; lastDiffusion = diffusion;
|
||||
recompute(algo, size, decay, hf, lf, diffusion);
|
||||
float d2 = diffusion * diffusionSens;
|
||||
diffGain = 0.25f + d2 * 0.55f;
|
||||
effApfGain = apfGain * (0.6f + d2 * 0.4f) * 0.78f;
|
||||
}
|
||||
}
|
||||
|
||||
float process(float x) override {
|
||||
preDelay.write(x);
|
||||
float din = preDelaySmp > 0.5f ? preDelay.read(preDelaySmp) : x;
|
||||
|
||||
float peak = std::fabs(x);
|
||||
duckEnv += (peak - duckEnv) * (peak > duckEnv ? duckAtt : duckRel);
|
||||
float duckGain = 1.f;
|
||||
if (duckAmtDb > 0.001f && duckEnv > duckThreshLin) {
|
||||
float overDb = 20.f * kt::log10f_(std::max(duckEnv, 1e-6f)) - duckThreshDb;
|
||||
duckGain = db2lin(-std::min(overDb, duckAmtDb));
|
||||
}
|
||||
|
||||
float fdnIn = din;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
float d = diffusers[(size_t)i].read(diffuserSmp[i]);
|
||||
float w = fdnIn + diffGain * d;
|
||||
diffusers[(size_t)i].write(w);
|
||||
fdnIn = d - diffGain * w;
|
||||
}
|
||||
|
||||
float er = 0.f;
|
||||
if (!bypassER) {
|
||||
erLine.write(din);
|
||||
for (int t = 0; t < erCount; ++t) er += erLine.read(erDelaySmp[t]) * erGain[t] * 0.5f;
|
||||
fdnIn += er * 0.15f;
|
||||
}
|
||||
|
||||
std::memcpy(fbScratch, fbVec, sizeof(fbScratch));
|
||||
fwht(fbScratch);
|
||||
for (int i = 0; i < N; ++i) fbScratch[i] *= SIGN_FLIP[i];
|
||||
|
||||
float inPerCh = fdnIn * 0.25f;
|
||||
float out = 0.f;
|
||||
for (int i = 0; i < N; ++i) {
|
||||
float lfo = nextLfo(i);
|
||||
DelayLine &line = fdn[(size_t)i];
|
||||
float d = line.read(baseDelay[i] + lfo * modDepth * freqMod[i]);
|
||||
d *= decayGain[i];
|
||||
hfState[i] += hfCoeff * (d - hfState[i]); d = hfState[i];
|
||||
lfState[i] += lfCoeff * (d - lfState[i]); d -= lfAmt * lfState[i];
|
||||
DelayLine &ap = apf[(size_t)i];
|
||||
float ad = ap.read(apfBase[i] + lfo * modDepth * 0.1f * freqMod[i]);
|
||||
float aw = d + effApfGain * ad;
|
||||
ap.write(aw);
|
||||
float apfOut = ad - effApfGain * aw;
|
||||
|
||||
nextFb[i] = apfOut;
|
||||
line.write(inPerCh + fbScratch[i]);
|
||||
out += apfOut;
|
||||
}
|
||||
std::memcpy(fbVec, nextFb, sizeof(fbVec));
|
||||
|
||||
float late = out * LATE_SCALE * makeup;
|
||||
float amt = kt::coerceIn(satAmt * satMul, 0.f, 1.f);
|
||||
if (amt > 0.0001f) late += amt * (kt::tanhf_(late * 2.f) * 0.5f - late);
|
||||
|
||||
float wetRaw = (bypassER ? 0.f : er * erLevel) + late;
|
||||
float dcOut = wetRaw - dc1 + 0.999f * dcY;
|
||||
dc1 = wetRaw; dcY = dcOut;
|
||||
|
||||
float wet = softClip(dcOut * wetLin * duckGain);
|
||||
return x * dryLin + wet;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
std::unique_ptr<Effect> makeAmbienceReverb(int sampleRate) {
|
||||
return std::make_unique<AmbienceReverb>(sampleRate);
|
||||
}
|
||||
|
||||
} // namespace sizzle
|
||||
@@ -0,0 +1,42 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// Port of Bitcrusher (Effects.kt): bit-depth reduction + sample-rate reduction + drive.
|
||||
|
||||
#include "sizzle/Effect.hpp"
|
||||
#include "KotlinMath.hpp"
|
||||
|
||||
namespace sizzle {
|
||||
namespace {
|
||||
|
||||
class Bitcrusher final : public Effect {
|
||||
float levels = 256.f;
|
||||
int downsample = 1;
|
||||
float drive = 1.f;
|
||||
int counter = 0;
|
||||
float held = 0.f;
|
||||
|
||||
public:
|
||||
void update(const Params &p, float) override {
|
||||
float bits = kt::coerceIn(p.f("bits", 8.f), 1.f, 16.f);
|
||||
levels = kt::powf_(2.f, bits);
|
||||
downsample = kt::coerceAtLeast(kt::toInt(p.f("downsample", 1.f)), 1);
|
||||
drive = 1.f + p.f("drive", 0.2f) * 4.f;
|
||||
}
|
||||
|
||||
float process(float x) override {
|
||||
if (counter <= 0) {
|
||||
counter = downsample;
|
||||
float driven = kt::tanhf_(x * drive);
|
||||
held = (float)kt::roundToInt(driven * levels) / levels;
|
||||
}
|
||||
counter--;
|
||||
return held;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
std::unique_ptr<Effect> makeBitcrusher(int) { return std::make_unique<Bitcrusher>(); }
|
||||
|
||||
} // namespace sizzle
|
||||
@@ -0,0 +1,111 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// Port of BiquadFilterEffect (Effects.kt): RBJ LP/HP/BP biquad whose cutoff an
|
||||
// input-level-gated ADSR opens, plus soft-saturation "warmth".
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include "sizzle/Effect.hpp"
|
||||
#include "KotlinMath.hpp"
|
||||
|
||||
namespace sizzle {
|
||||
namespace {
|
||||
|
||||
constexpr int CTRL_INTERVAL = 32;
|
||||
constexpr float GATE_HI = 0.010f;
|
||||
constexpr float GATE_LO = 0.004f;
|
||||
|
||||
class Filter final : public Effect {
|
||||
double b0 = 1, b1 = 0, b2 = 0, a1 = 0, a2 = 0, z1 = 0, z2 = 0;
|
||||
int sampleRate;
|
||||
float sr;
|
||||
enum Type { LPF, HPF, BPF } type = LPF;
|
||||
float baseCutoff = 0.7f;
|
||||
double q = 1.0;
|
||||
float warmth = 0.f, envAmount = 0.f;
|
||||
enum Phase { IDLE, ATTACK, DECAY, SUSTAIN, RELEASE } phase = IDLE;
|
||||
float env = 0.f, attackInc = 1.f, decayInc = 1.f, sustainLevel = 1.f;
|
||||
float releaseSeconds = 0.2f, releaseInc = 1.f, levelEnv = 0.f, levelCoeff = 0.f;
|
||||
bool gateOpen = false;
|
||||
int ctrl = 0;
|
||||
|
||||
void computeCoefficients(Type t, double freq, double qq) {
|
||||
double w0 = 2.0 * M_PI * freq / sampleRate;
|
||||
double cosW = std::cos(w0);
|
||||
double alpha = std::sin(w0) / (2.0 * qq);
|
||||
double a0;
|
||||
switch (t) {
|
||||
case HPF:
|
||||
b0 = (1 + cosW) / 2; b1 = -(1 + cosW); b2 = (1 + cosW) / 2;
|
||||
a0 = 1 + alpha; a1 = -2 * cosW; a2 = 1 - alpha; break;
|
||||
case BPF:
|
||||
b0 = alpha; b1 = 0.0; b2 = -alpha;
|
||||
a0 = 1 + alpha; a1 = -2 * cosW; a2 = 1 - alpha; break;
|
||||
default:
|
||||
b0 = (1 - cosW) / 2; b1 = 1 - cosW; b2 = (1 - cosW) / 2;
|
||||
a0 = 1 + alpha; a1 = -2 * cosW; a2 = 1 - alpha; break;
|
||||
}
|
||||
b0 /= a0; b1 /= a0; b2 /= a0; a1 /= a0; a2 /= a0;
|
||||
}
|
||||
|
||||
public:
|
||||
explicit Filter(int rate) : sampleRate(rate), sr((float)rate) {}
|
||||
|
||||
void update(const Params &p, float) override {
|
||||
const char *t = p.s("type", "LPF");
|
||||
type = std::strcmp(t, "HPF") == 0 ? HPF : std::strcmp(t, "BPF") == 0 ? BPF : LPF;
|
||||
baseCutoff = kt::coerceIn(p.f("cutoff", 0.7f), 0.f, 1.f);
|
||||
q = (double)(0.5 + p.f("resonance", 0.2f) * 8.f);
|
||||
warmth = kt::coerceIn(p.f("warmth", 0.f), 0.f, 1.f);
|
||||
envAmount = kt::coerceIn(p.f("envamt", 0.f), 0.f, 1.f);
|
||||
sustainLevel = kt::coerceIn(p.f("sustain", 1.f), 0.f, 1.f);
|
||||
attackInc = 1.f / (std::max(p.f("attack", 0.005f), 0.0005f) * sr);
|
||||
float decay = p.f("decay", 0.10f);
|
||||
decayInc = decay <= 0.f ? 1.f : (1.f - sustainLevel) / (decay * sr);
|
||||
releaseSeconds = p.f("release", 0.20f);
|
||||
levelCoeff = 1.f - kt::expf_(-1.f / (sr * 0.005f));
|
||||
ctrl = 0;
|
||||
}
|
||||
|
||||
float process(float x) override {
|
||||
levelEnv += (std::fabs(x) - levelEnv) * levelCoeff;
|
||||
if (!gateOpen && levelEnv > GATE_HI) {
|
||||
gateOpen = true; phase = ATTACK;
|
||||
} else if (gateOpen && levelEnv < GATE_LO) {
|
||||
gateOpen = false;
|
||||
releaseInc = releaseSeconds <= 0.f ? 1.f : env / (releaseSeconds * sr);
|
||||
if (releaseInc <= 0.f) releaseInc = 1.f;
|
||||
phase = RELEASE;
|
||||
}
|
||||
switch (phase) {
|
||||
case ATTACK: env += attackInc; if (env >= 1.f) { env = 1.f; phase = DECAY; } break;
|
||||
case DECAY: env -= decayInc; if (env <= sustainLevel) { env = sustainLevel; phase = SUSTAIN; } break;
|
||||
case RELEASE: env -= releaseInc; if (env <= 0.f) { env = 0.f; phase = IDLE; } break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (ctrl <= 0) {
|
||||
ctrl = CTRL_INTERVAL;
|
||||
float eff = kt::coerceIn(baseCutoff + envAmount * env * (1.f - baseCutoff), 0.f, 1.f);
|
||||
double freq = 20.0 * std::pow(900.0, (double)eff);
|
||||
computeCoefficients(type, kt::coerceIn(freq, 20.0, sampleRate * 0.45), q);
|
||||
}
|
||||
ctrl--;
|
||||
|
||||
double input = (double)x;
|
||||
double out = b0 * input + z1;
|
||||
z1 = b1 * input - a1 * out + z2;
|
||||
z2 = b2 * input - a2 * out;
|
||||
float y = (float)out;
|
||||
if (warmth > 0.0001f) y += warmth * (kt::tanhf_(y * 1.8f) / 1.8f - y);
|
||||
return y;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
std::unique_ptr<Effect> makeFilter(int sr) { return std::make_unique<Filter>(sr); }
|
||||
|
||||
} // namespace sizzle
|
||||
@@ -0,0 +1,91 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// Port of GranularGlitch (Effects.kt), audio path only: a rolling 1 s buffer whose
|
||||
// read head randomly jumps back to replay short (sometimes octave-shifted) grains,
|
||||
// dry in between. The VizEffect scope/playhead is not ported (output-independent).
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include "sizzle/Effect.hpp"
|
||||
#include "KotlinMath.hpp"
|
||||
|
||||
namespace sizzle {
|
||||
namespace {
|
||||
|
||||
constexpr float MAX_TRIGGER = 0.0009f;
|
||||
constexpr float MIN_JUMP_S = 0.03f;
|
||||
constexpr float MAX_JUMP_S = 0.5f;
|
||||
constexpr float GRAIN_MIN_S = 0.02f;
|
||||
constexpr float GRAIN_MAX_S = 0.15f;
|
||||
|
||||
class GranularGlitch final : public Effect {
|
||||
int sampleRate;
|
||||
std::vector<float> buf;
|
||||
int size;
|
||||
int writePos = 0;
|
||||
double readPos = 0.0;
|
||||
int grainLeft = 0;
|
||||
double grainRate = 1.0;
|
||||
float intensity = 0.f;
|
||||
uint32_t rng = 0x2F6E1DB7u;
|
||||
|
||||
float nextUnit() {
|
||||
uint32_t s = rng; s ^= s << 13; s ^= s >> 17; s ^= s << 5; rng = s;
|
||||
return (float)s * 2.3283064e-10f; // 0 … 1
|
||||
}
|
||||
|
||||
bool maybeStartGrain(int wp) {
|
||||
if (nextUnit() > intensity * intensity * MAX_TRIGGER) return false;
|
||||
float minJ = MIN_JUMP_S * (float)sampleRate;
|
||||
float maxJ = (MIN_JUMP_S + intensity * (MAX_JUMP_S - MIN_JUMP_S)) * (float)sampleRate;
|
||||
float jump = minJ + nextUnit() * (maxJ - minJ);
|
||||
double rp = (double)wp - (double)jump;
|
||||
while (rp < 0) rp += size;
|
||||
readPos = rp;
|
||||
float lenSec = GRAIN_MAX_S - intensity * (GRAIN_MAX_S - GRAIN_MIN_S);
|
||||
grainLeft = kt::coerceAtLeast(kt::toInt(lenSec * (float)sampleRate * (0.5f + nextUnit())), 64);
|
||||
if (nextUnit() < intensity * 0.3f) grainRate = 2.0;
|
||||
else if (nextUnit() < intensity * 0.2f) grainRate = 0.5;
|
||||
else grainRate = 1.0;
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
explicit GranularGlitch(int rate) : sampleRate(rate), buf((size_t)rate, 0.f), size(rate) {}
|
||||
|
||||
void update(const Params &p, float) override {
|
||||
intensity = kt::coerceIn(p.f("intensity", 0.3f), 0.f, 1.f);
|
||||
}
|
||||
|
||||
float process(float x) override {
|
||||
int wp = writePos;
|
||||
buf[wp] = x;
|
||||
writePos++; if (writePos >= size) writePos = 0;
|
||||
|
||||
float out;
|
||||
if (grainLeft <= 0 && (intensity < 0.001f || !maybeStartGrain(wp))) {
|
||||
readPos = (double)wp;
|
||||
out = x;
|
||||
} else {
|
||||
int i0 = (int)readPos % size;
|
||||
int i1 = (i0 + 1) % size;
|
||||
float frac = (float)(readPos - (int)readPos);
|
||||
out = buf[i0] + (buf[i1] - buf[i0]) * frac;
|
||||
double rp = readPos + grainRate;
|
||||
if (rp >= size) rp -= size;
|
||||
if (rp < 0) rp += size;
|
||||
double gap = wp - rp; if (gap < 0) gap += size;
|
||||
if (gap < 2.0) { rp = wp - 2.0; if (rp < 0) rp += size; }
|
||||
readPos = rp;
|
||||
grainLeft--;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
std::unique_ptr<Effect> makeGranularGlitch(int sr) { return std::make_unique<GranularGlitch>(sr); }
|
||||
|
||||
} // namespace sizzle
|
||||
@@ -0,0 +1,67 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// Port of GraphicEq (Effects.kt): ten peaking biquads at octave-spaced centres.
|
||||
|
||||
#include <cmath>
|
||||
#include "sizzle/Effect.hpp"
|
||||
#include "KotlinMath.hpp"
|
||||
|
||||
namespace sizzle {
|
||||
namespace {
|
||||
|
||||
struct PeakBiquad {
|
||||
double b0 = 1, b1 = 0, b2 = 0, a1 = 0, a2 = 0, z1 = 0, z2 = 0;
|
||||
|
||||
void set(int sampleRate, float freq, float gainDb) {
|
||||
if (freq >= sampleRate * 0.45f) return;
|
||||
double a = std::pow(10.0, gainDb / 40.0);
|
||||
double w0 = 2.0 * M_PI * freq / sampleRate;
|
||||
double cosW = std::cos(w0);
|
||||
double alpha = std::sin(w0) / (2.0 * 1.0);
|
||||
double a0 = 1 + alpha / a;
|
||||
b0 = (1 + alpha * a) / a0;
|
||||
b1 = (-2 * cosW) / a0;
|
||||
b2 = (1 - alpha * a) / a0;
|
||||
a1 = (-2 * cosW) / a0;
|
||||
a2 = (1 - alpha / a) / a0;
|
||||
}
|
||||
|
||||
float process(float x) {
|
||||
double input = (double)x;
|
||||
double out = b0 * input + z1;
|
||||
z1 = b1 * input - a1 * out + z2;
|
||||
z2 = b2 * input - a2 * out;
|
||||
return (float)out;
|
||||
}
|
||||
};
|
||||
|
||||
class GraphicEq final : public Effect {
|
||||
static constexpr float centers[10] = {31.f, 63.f, 125.f, 250.f, 500.f, 1000.f, 2000.f, 4000.f, 8000.f, 16000.f};
|
||||
static constexpr const char *keys[10] = {"band0", "band1", "band2", "band3", "band4",
|
||||
"band5", "band6", "band7", "band8", "band9"};
|
||||
PeakBiquad bands[10];
|
||||
int sampleRate;
|
||||
|
||||
public:
|
||||
explicit GraphicEq(int sr) : sampleRate(sr) {}
|
||||
|
||||
void update(const Params &p, float) override {
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
float gainDb = kt::coerceIn(p.f(keys[i], 0.f), -1.f, 1.f) * 12.f;
|
||||
bands[i].set(sampleRate, centers[i], gainDb);
|
||||
}
|
||||
}
|
||||
|
||||
float process(float x) override {
|
||||
float y = x;
|
||||
for (auto &b : bands) y = b.process(y);
|
||||
return y;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
std::unique_ptr<Effect> makeGraphicEq(int sr) { return std::make_unique<GraphicEq>(sr); }
|
||||
|
||||
} // namespace sizzle
|
||||
@@ -0,0 +1,34 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#pragma once
|
||||
|
||||
// Kotlin/JVM math semantics, so ports read like the Kotlin and match its output.
|
||||
// kotlin.math on Float goes through Java's double Math and rounds back to float.
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace sizzle::kt {
|
||||
|
||||
inline float tanhf_(float x) { return (float)std::tanh((double)x); }
|
||||
inline float expf_(float x) { return (float)std::exp((double)x); }
|
||||
inline float sinf_(float x) { return (float)std::sin((double)x); }
|
||||
inline float cosf_(float x) { return (float)std::cos((double)x); }
|
||||
inline float powf_(float a, float b) { return (float)std::pow((double)a, (double)b); }
|
||||
inline float sqrtf_(float x) { return (float)std::sqrt((double)x); }
|
||||
inline float log10f_(float x) { return (float)std::log10((double)x); }
|
||||
|
||||
/** Float.roundToInt(): Math.round, i.e. floor(x + 0.5). */
|
||||
inline int roundToInt(float x) { return (int)std::floor((double)x + 0.5); }
|
||||
inline int roundToInt(double x) { return (int)std::floor(x + 0.5); }
|
||||
/** Float.toInt(): truncation toward zero, NaN → 0, saturating. */
|
||||
inline int toInt(float x) {
|
||||
if (std::isnan(x)) return 0;
|
||||
if (x >= 2147483647.f) return 2147483647;
|
||||
if (x <= -2147483648.f) return (-2147483647 - 1);
|
||||
return (int)x;
|
||||
}
|
||||
template <class T> inline T coerceIn(T v, T lo, T hi) { return v < lo ? lo : (v > hi ? hi : v); }
|
||||
template <class T> inline T coerceAtLeast(T v, T lo) { return v < lo ? lo : v; }
|
||||
template <class T> inline T coerceAtMost(T v, T hi) { return v > hi ? hi : v; }
|
||||
|
||||
} // namespace sizzle::kt
|
||||
@@ -0,0 +1,190 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// Port of MixTightener (Effects.kt): parametric EQ -> 3-band multiband compressor ->
|
||||
// peak limiter, morphed by one Strength control; per-band values are hidden params
|
||||
// set by presets. Includes the private Bq biquad (TDF-II, double state).
|
||||
|
||||
#include <cmath>
|
||||
#include "sizzle/Effect.hpp"
|
||||
#include "KotlinMath.hpp"
|
||||
|
||||
namespace sizzle {
|
||||
namespace {
|
||||
|
||||
class Bq {
|
||||
double b0 = 1.0, b1 = 0.0, b2 = 0.0;
|
||||
double a1 = 0.0, a2 = 0.0;
|
||||
double z1 = 0.0, z2 = 0.0;
|
||||
|
||||
void setRaw(double nb0, double nb1, double nb2, double a0, double na1, double na2) {
|
||||
b0 = nb0 / a0; b1 = nb1 / a0; b2 = nb2 / a0; a1 = na1 / a0; a2 = na2 / a0;
|
||||
}
|
||||
|
||||
public:
|
||||
void identity() { b0 = 1.0; b1 = 0.0; b2 = 0.0; a1 = 0.0; a2 = 0.0; }
|
||||
|
||||
void peak(int sr, float freq, float gainDb, float q) {
|
||||
float f = kt::coerceIn(freq, 20.f, sr * 0.45f);
|
||||
double a = std::pow(10.0, gainDb / 40.0);
|
||||
double w0 = 2.0 * M_PI * f / sr; double cw = std::cos(w0);
|
||||
double alpha = std::sin(w0) / (2.0 * kt::coerceAtLeast(q, 0.1f));
|
||||
setRaw(1 + alpha * a, -2 * cw, 1 - alpha * a, 1 + alpha / a, -2 * cw, 1 - alpha / a);
|
||||
}
|
||||
|
||||
void lowShelf(int sr, float freq, float gainDb) {
|
||||
float f = kt::coerceIn(freq, 20.f, sr * 0.45f);
|
||||
double a = std::pow(10.0, gainDb / 40.0); double w0 = 2.0 * M_PI * f / sr; double cw = std::cos(w0);
|
||||
double alpha = std::sin(w0) / 2.0 * std::sqrt(2.0); double ta = 2.0 * std::sqrt(a) * alpha;
|
||||
setRaw(
|
||||
a * ((a + 1) - (a - 1) * cw + ta), 2 * a * ((a - 1) - (a + 1) * cw),
|
||||
a * ((a + 1) - (a - 1) * cw - ta), (a + 1) + (a - 1) * cw + ta,
|
||||
-2 * ((a - 1) + (a + 1) * cw), (a + 1) + (a - 1) * cw - ta);
|
||||
}
|
||||
|
||||
void highShelf(int sr, float freq, float gainDb) {
|
||||
float f = kt::coerceIn(freq, 20.f, sr * 0.45f);
|
||||
double a = std::pow(10.0, gainDb / 40.0); double w0 = 2.0 * M_PI * f / sr; double cw = std::cos(w0);
|
||||
double alpha = std::sin(w0) / 2.0 * std::sqrt(2.0); double ta = 2.0 * std::sqrt(a) * alpha;
|
||||
setRaw(
|
||||
a * ((a + 1) + (a - 1) * cw + ta), -2 * a * ((a - 1) + (a + 1) * cw),
|
||||
a * ((a + 1) + (a - 1) * cw - ta), (a + 1) - (a - 1) * cw + ta,
|
||||
2 * ((a - 1) - (a + 1) * cw), (a + 1) - (a - 1) * cw - ta);
|
||||
}
|
||||
|
||||
void lowPass(int sr, float freq, float q) {
|
||||
float f = kt::coerceIn(freq, 20.f, sr * 0.45f);
|
||||
double w0 = 2.0 * M_PI * f / sr; double cw = std::cos(w0); double alpha = std::sin(w0) / (2.0 * q);
|
||||
setRaw((1 - cw) / 2, 1 - cw, (1 - cw) / 2, 1 + alpha, -2 * cw, 1 - alpha);
|
||||
}
|
||||
|
||||
void highPass(int sr, float freq, float q) {
|
||||
float f = kt::coerceIn(freq, 20.f, sr * 0.45f);
|
||||
double w0 = 2.0 * M_PI * f / sr; double cw = std::cos(w0); double alpha = std::sin(w0) / (2.0 * q);
|
||||
setRaw((1 + cw) / 2, -(1 + cw), (1 + cw) / 2, 1 + alpha, -2 * cw, 1 - alpha);
|
||||
}
|
||||
|
||||
void reset() { z1 = 0.0; z2 = 0.0; }
|
||||
|
||||
float process(float x) {
|
||||
double inp = (double)x;
|
||||
double out = b0 * inp + z1;
|
||||
z1 = b1 * inp - a1 * out + z2;
|
||||
z2 = b2 * inp - a2 * out;
|
||||
if (!std::isfinite(out)) { z1 = 0.0; z2 = 0.0; out = 0.0; }
|
||||
return (float)out;
|
||||
}
|
||||
};
|
||||
|
||||
constexpr int CTRL = 16; // samples between (expensive) gain recomputes
|
||||
constexpr float GAIN_SMOOTH = 0.05f; // per-sample gain ramp toward the control-rate target
|
||||
|
||||
class MixTightener final : public Effect {
|
||||
int sampleRate;
|
||||
Bq eqLo, eqMid, eqHi;
|
||||
bool eqActive = false;
|
||||
Bq xLoLP, xLoHP, xHiLP, xHiHP;
|
||||
bool compActive = false;
|
||||
float env[3] = {0.f, 0.f, 0.f};
|
||||
float gain[3] = {1.f, 1.f, 1.f};
|
||||
float target[3] = {1.f, 1.f, 1.f};
|
||||
float atkCoef[3] = {}, relCoef[3] = {};
|
||||
float thrDb[3] = {}, ratio[3] = {}, makeDb[3] = {};
|
||||
int ctrl = 0;
|
||||
float limCeil = 1.f, limRelCoef = 0.f, limEnv = 0.f;
|
||||
float outGain = 1.f;
|
||||
float strength = 1.f;
|
||||
float compScale = 1.f;
|
||||
|
||||
static float dbToLin(float db) { return (float)std::pow(10.0, db / 20.0); }
|
||||
float coefFromMs(float ms) const {
|
||||
float t = kt::coerceAtLeast(ms, 0.1f) * 0.001f * sampleRate;
|
||||
return (float)(1.0 - std::exp(-1.0 / t));
|
||||
}
|
||||
|
||||
float compBand(int i, float band) {
|
||||
float r = std::fabs(band);
|
||||
float e = env[i];
|
||||
env[i] = r > e ? e + atkCoef[i] * (r - e) : e + relCoef[i] * (r - e);
|
||||
gain[i] += GAIN_SMOOTH * (target[i] - gain[i]);
|
||||
return band * gain[i];
|
||||
}
|
||||
|
||||
public:
|
||||
explicit MixTightener(int rate) : sampleRate(rate) {}
|
||||
|
||||
void update(const Params &p, float) override {
|
||||
strength = kt::coerceIn(p.f("strength", 1.f), 0.f, 1.f);
|
||||
float eqS = strength * kt::coerceIn(p.f("eqAmt", 1.f), 0.f, 1.f);
|
||||
float compAmt = kt::coerceIn(p.f("compAmt", 1.f), 0.f, 1.f);
|
||||
compScale = strength * compAmt;
|
||||
float limS = strength * kt::coerceIn(p.f("limAmt", 1.f), 0.f, 1.f);
|
||||
|
||||
float loG = kt::coerceIn(p.f("eqLoGain", 0.f), -18.f, 18.f) * eqS;
|
||||
float midG = kt::coerceIn(p.f("eqMidGain", 0.f), -18.f, 18.f) * eqS;
|
||||
float hiG = kt::coerceIn(p.f("eqHiGain", 0.f), -18.f, 18.f) * eqS;
|
||||
if (std::fabs(loG) > 0.1f) eqLo.lowShelf(sampleRate, p.f("eqLoFreq", 120.f), loG); else eqLo.identity();
|
||||
if (std::fabs(midG) > 0.1f) eqMid.peak(sampleRate, p.f("eqMidFreq", 1000.f), midG,
|
||||
kt::coerceIn(p.f("eqMidQ", 1.0f), 0.2f, 8.f)); else eqMid.identity();
|
||||
if (std::fabs(hiG) > 0.1f) eqHi.highShelf(sampleRate, p.f("eqHiFreq", 8000.f), hiG); else eqHi.identity();
|
||||
eqActive = std::fabs(loG) > 0.1f || std::fabs(midG) > 0.1f || std::fabs(hiG) > 0.1f;
|
||||
|
||||
float xl = kt::coerceIn(p.f("xLo", 200.f), 40.f, sampleRate * 0.4f);
|
||||
float xh = kt::coerceIn(p.f("xHi", 2500.f), xl + 50.f, sampleRate * 0.45f);
|
||||
xLoLP.lowPass(sampleRate, xl, 0.5f); xLoHP.highPass(sampleRate, xl, 0.5f);
|
||||
xHiLP.lowPass(sampleRate, xh, 0.5f); xHiHP.highPass(sampleRate, xh, 0.5f);
|
||||
|
||||
thrDb[0] = p.f("cLoThr", -24.f); ratio[0] = kt::coerceIn(p.f("cLoRatio", 2.f), 1.f, 20.f);
|
||||
makeDb[0] = p.f("cLoMk", 0.f); atkCoef[0] = coefFromMs(p.f("cLoAtk", 10.f)); relCoef[0] = coefFromMs(p.f("cLoRel", 120.f));
|
||||
thrDb[1] = p.f("cMidThr", -22.f); ratio[1] = kt::coerceIn(p.f("cMidRatio", 2.f), 1.f, 20.f);
|
||||
makeDb[1] = p.f("cMidMk", 0.f); atkCoef[1] = coefFromMs(p.f("cMidAtk", 15.f)); relCoef[1] = coefFromMs(p.f("cMidRel", 140.f));
|
||||
thrDb[2] = p.f("cHiThr", -24.f); ratio[2] = kt::coerceIn(p.f("cHiRatio", 2.f), 1.f, 20.f);
|
||||
makeDb[2] = p.f("cHiMk", 0.f); atkCoef[2] = coefFromMs(p.f("cHiAtk", 5.f)); relCoef[2] = coefFromMs(p.f("cHiRel", 90.f));
|
||||
bool anyRatio = false, anyMake = false;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (ratio[i] > 1.01f) anyRatio = true;
|
||||
if (std::fabs(makeDb[i]) > 0.1f) anyMake = true;
|
||||
}
|
||||
compActive = compAmt > 0.001f && (anyRatio || anyMake);
|
||||
|
||||
limCeil = 1.f + (dbToLin(kt::coerceIn(p.f("limCeil", -0.5f), -24.f, 0.f)) - 1.f) * limS;
|
||||
limRelCoef = coefFromMs(p.f("limRel", 100.f));
|
||||
outGain = 1.f + (dbToLin(kt::coerceIn(p.f("outGain", 0.f), -12.f, 18.f)) - 1.f) * limS;
|
||||
}
|
||||
|
||||
float process(float x) override {
|
||||
if (strength < 0.001f) return x;
|
||||
float s = x;
|
||||
if (eqActive) { s = eqLo.process(s); s = eqMid.process(s); s = eqHi.process(s); }
|
||||
|
||||
if (compActive) {
|
||||
float low = xLoLP.process(s);
|
||||
float hp = xLoHP.process(s);
|
||||
float mid = xHiLP.process(hp);
|
||||
float high = xHiHP.process(hp);
|
||||
if (ctrl <= 0) {
|
||||
ctrl = CTRL;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
float envDb = 20.f * kt::log10f_(env[i] + 1e-9f);
|
||||
float over = envDb - thrDb[i];
|
||||
float grDb = over > 0.f ? -over * (1.f - 1.f / ratio[i]) : 0.f;
|
||||
target[i] = dbToLin(kt::coerceIn((grDb + makeDb[i]) * compScale, -40.f, 24.f));
|
||||
}
|
||||
}
|
||||
ctrl--;
|
||||
s = compBand(0, low) + compBand(1, mid) + compBand(2, high);
|
||||
}
|
||||
|
||||
float r = std::fabs(s);
|
||||
limEnv = r > limEnv ? r : limEnv + limRelCoef * (r - limEnv);
|
||||
if (limEnv > limCeil && limEnv > 1e-6f) s *= limCeil / limEnv;
|
||||
s *= outGain;
|
||||
return s > 1.f ? 1.f : s < -1.f ? -1.f : !std::isfinite(s) ? 0.f : s;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
std::unique_ptr<Effect> makeMixTightener(int sampleRate) { return std::make_unique<MixTightener>(sampleRate); }
|
||||
|
||||
} // namespace sizzle
|
||||
@@ -0,0 +1,39 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// Effect::create. Each effect lives in src/fx/<Name>.cpp and defines its maker
|
||||
// below. The defaults here are weak definitions returning nullptr; a port's own
|
||||
// (strong) definition replaces its default at link time, so a build without some
|
||||
// of those files still links (lets ports land one by one).
|
||||
|
||||
#include <cstring>
|
||||
#include "sizzle/Effect.hpp"
|
||||
|
||||
#define SIZZLE_MAKER(fn) \
|
||||
__attribute__((weak)) std::unique_ptr<Effect> fn(int) { return nullptr; }
|
||||
|
||||
namespace sizzle {
|
||||
|
||||
SIZZLE_MAKER(makeBitcrusher);
|
||||
SIZZLE_MAKER(makeFilter);
|
||||
SIZZLE_MAKER(makeGraphicEq);
|
||||
SIZZLE_MAKER(makeTapeDelay);
|
||||
SIZZLE_MAKER(makeMixTightener);
|
||||
SIZZLE_MAKER(makeTapeEngine);
|
||||
SIZZLE_MAKER(makeGranularGlitch);
|
||||
SIZZLE_MAKER(makeAmbienceReverb);
|
||||
|
||||
std::unique_ptr<Effect> Effect::create(const char *type, int sr) {
|
||||
struct Entry { const char *type; std::unique_ptr<Effect> (*make)(int); };
|
||||
const Entry table[] = {
|
||||
{"BITCRUSHER", makeBitcrusher}, {"FILTER", makeFilter},
|
||||
{"EQ10", makeGraphicEq}, {"DELAY", makeTapeDelay},
|
||||
{"MIX_TIGHTENER", makeMixTightener}, {"TAPE_ENGINE", makeTapeEngine},
|
||||
{"GRANULAR", makeGranularGlitch}, {"AMBIENCE", makeAmbienceReverb},
|
||||
};
|
||||
for (const auto &e : table)
|
||||
if (std::strcmp(type, e.type) == 0) return e.make(sr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace sizzle
|
||||
@@ -0,0 +1,122 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// Port of TapeDelay (Effects.kt): one shared delay line read by up to four
|
||||
// tempo-synced tape heads (averaged), with saturation, a darkening one-pole LP
|
||||
// in the feedback path and sine wow/flutter, all scaled by "tape".
|
||||
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
#include "sizzle/Effect.hpp"
|
||||
#include "KotlinMath.hpp"
|
||||
|
||||
// The JVM never fuses a*b+c; keep clang from contracting into FMAs.
|
||||
#if defined(__clang__)
|
||||
#pragma STDC FP_CONTRACT OFF
|
||||
#endif
|
||||
|
||||
namespace sizzle {
|
||||
namespace {
|
||||
|
||||
// DelayDivisions (model/Toolbox.kt).
|
||||
constexpr int HEADS = 4;
|
||||
constexpr float MAX_FEEDBACK = 0.9f;
|
||||
constexpr double BEAT_FRACTIONS[] = {
|
||||
4.0, // 1/1
|
||||
3.0, // 1/2.
|
||||
2.0, // 1/2
|
||||
1.5, // 1/4.
|
||||
4.0 / 3.0, // 1/2T
|
||||
1.0, // 1/4
|
||||
0.75, // 1/8.
|
||||
2.0 / 3.0, // 1/4T
|
||||
0.5, // 1/8
|
||||
0.375, // 1/16.
|
||||
1.0 / 3.0, // 1/8T
|
||||
0.25, // 1/16
|
||||
1.0 / 6.0, // 1/16T
|
||||
};
|
||||
constexpr int DIV_COUNT = (int)(sizeof(BEAT_FRACTIONS) / sizeof(BEAT_FRACTIONS[0]));
|
||||
constexpr int DIV_DEFAULT = 5; // indexOf("1/4")
|
||||
inline double beatFraction(int i) { return BEAT_FRACTIONS[kt::coerceIn(i, 0, DIV_COUNT - 1)]; }
|
||||
|
||||
constexpr double FLUTTER_HZ = 5.0;
|
||||
const char *const HEAD_ON_KEYS[HEADS] = {"head0On", "head1On", "head2On", "head3On"};
|
||||
const char *const HEAD_DIV_KEYS[HEADS] = {"head0Div", "head1Div", "head2Div", "head3Div"};
|
||||
|
||||
class TapeDelay final : public Effect {
|
||||
int sampleRate;
|
||||
std::vector<float> buffer; // up to 4 s of delay line
|
||||
int bufferSize;
|
||||
int writeIndex = 0;
|
||||
int delaySamples[HEADS];
|
||||
bool headOn[HEADS] = {};
|
||||
float feedback = 0.4f;
|
||||
float dryWet = 0.35f;
|
||||
float satBlend = 0.f;
|
||||
float lpAlpha = 1.f;
|
||||
float lpState = 0.f;
|
||||
double flutterInc = 0.0;
|
||||
float flutterDepth = 0.f;
|
||||
double flutterPhase = 0.0;
|
||||
|
||||
public:
|
||||
explicit TapeDelay(int rate)
|
||||
: sampleRate(rate), buffer((size_t)rate * 4, 0.f), bufferSize(rate * 4) {
|
||||
for (int h = 0; h < HEADS; h++) delaySamples[h] = rate / 2;
|
||||
}
|
||||
|
||||
void update(const Params &p, float tempoBpm) override {
|
||||
double samplesPerBeat = (60.0 / (double)tempoBpm) * sampleRate;
|
||||
for (int h = 0; h < HEADS; h++) {
|
||||
headOn[h] = p.f(HEAD_ON_KEYS[h], h == 0 ? 1.f : 0.f) >= 0.5f;
|
||||
int idx = kt::toInt(p.f(HEAD_DIV_KEYS[h], (float)DIV_DEFAULT));
|
||||
// Double.toInt(): truncation (values here are small and positive).
|
||||
double d = beatFraction(idx) * samplesPerBeat;
|
||||
int ds = std::isnan(d) ? 0 : d >= 2147483647.0 ? 2147483647 : (int)d;
|
||||
delaySamples[h] = kt::coerceIn(ds, 1, bufferSize - 2);
|
||||
}
|
||||
feedback = kt::coerceIn(p.f("feedback", 0.4f), 0.f, MAX_FEEDBACK);
|
||||
dryWet = kt::coerceIn(p.f("drywet", 0.35f), 0.f, 1.f);
|
||||
float tape = kt::coerceIn(p.f("tape", 0.3f), 0.f, 1.f);
|
||||
satBlend = tape;
|
||||
lpAlpha = 1.f - tape * 0.85f;
|
||||
flutterInc = 2.0 * M_PI * FLUTTER_HZ / sampleRate;
|
||||
flutterDepth = tape * (float)sampleRate * 0.0015f;
|
||||
}
|
||||
|
||||
float process(float x) override {
|
||||
flutterPhase += flutterInc;
|
||||
if (flutterPhase > 2 * M_PI) flutterPhase -= 2 * M_PI;
|
||||
float flutter = (float)std::sin(flutterPhase) * flutterDepth;
|
||||
|
||||
float wet = 0.f;
|
||||
int active = 0;
|
||||
for (int h = 0; h < HEADS; h++) {
|
||||
if (!headOn[h]) continue;
|
||||
active++;
|
||||
float pos = (float)(writeIndex - delaySamples[h]) - flutter;
|
||||
while (pos < 0.f) pos += (float)bufferSize;
|
||||
int i0 = kt::toInt(pos) % bufferSize;
|
||||
int i1 = (i0 + 1) % bufferSize;
|
||||
float frac = pos - (float)kt::toInt(pos);
|
||||
wet += buffer[i0] + (buffer[i1] - buffer[i0]) * frac;
|
||||
}
|
||||
if (active > 0) wet /= (float)active;
|
||||
|
||||
float fb = wet * feedback;
|
||||
fb += satBlend * (kt::tanhf_(fb) - fb);
|
||||
lpState += lpAlpha * (fb - lpState);
|
||||
fb = lpState;
|
||||
|
||||
buffer[writeIndex] = x + fb;
|
||||
writeIndex = (writeIndex + 1) % bufferSize;
|
||||
return x * (1.f - dryWet) + wet * dryWet;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
std::unique_ptr<Effect> makeTapeDelay(int sampleRate) { return std::make_unique<TapeDelay>(sampleRate); }
|
||||
|
||||
} // namespace sizzle
|
||||
@@ -0,0 +1,102 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// Port of TapeEngine (Effects.kt): a varispeed reel-to-reel. Input is written into
|
||||
// a ring at rate 1 and read back at a gliding `speed`, with wow/flutter wobble and
|
||||
// xorshift hiss.
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include "sizzle/Effect.hpp"
|
||||
#include "KotlinMath.hpp"
|
||||
|
||||
namespace sizzle {
|
||||
namespace {
|
||||
|
||||
constexpr int NOMINAL_DELAY = 128;
|
||||
constexpr float MIN_SPEED = 0.25f;
|
||||
constexpr float MAX_WOW = 0.03f;
|
||||
constexpr float MAX_FLUT = 0.008f;
|
||||
constexpr float MAX_HISS = 0.02f;
|
||||
constexpr double FLUTTER_HZ = 11.0;
|
||||
constexpr float SPEED_GLIDE = 0.00012f;
|
||||
constexpr double MIN_GAP = 2.0;
|
||||
|
||||
/** TimeDivision.beatFraction by index, with fromIndex's clamping. */
|
||||
double beatFraction(int i) {
|
||||
static constexpr double kFrac[] = {4.0, 2.0, 1.0, 0.5, 0.25, 0.125, 0.75};
|
||||
return kFrac[kt::coerceIn(i, 0, 6)];
|
||||
}
|
||||
|
||||
class TapeEngine final : public Effect {
|
||||
int sampleRate;
|
||||
std::vector<float> buf;
|
||||
int size;
|
||||
int writePos = NOMINAL_DELAY;
|
||||
double readPos = 0.0;
|
||||
double targetSpeed = 1.0;
|
||||
double curSpeed = 1.0;
|
||||
double wowInc = 0.0, wowPhase = 0.0; float wowDepth = 0.f;
|
||||
double flutInc, flutPhase = 0.0; float flutDepth = 0.f;
|
||||
float hiss = 0.f;
|
||||
uint32_t rng = 0x51ED2A19u;
|
||||
|
||||
float nextRand() {
|
||||
uint32_t s = rng; s ^= s << 13; s ^= s >> 17; s ^= s << 5; rng = s;
|
||||
return (float)(int32_t)s * 4.656613e-10f; // -1 … 1
|
||||
}
|
||||
|
||||
public:
|
||||
explicit TapeEngine(int rate)
|
||||
: sampleRate(rate), buf((size_t)rate * 2, 0.f), size(rate * 2),
|
||||
flutInc(FLUTTER_HZ / rate) {}
|
||||
|
||||
void update(const Params &p, float tempoBpm) override {
|
||||
targetSpeed = (double)kt::coerceIn(p.f("speed", 1.f), MIN_SPEED, 1.f);
|
||||
wowDepth = kt::coerceIn(p.f("wow", 0.15f), 0.f, 1.f) * MAX_WOW;
|
||||
flutDepth = kt::coerceIn(p.f("flutter", 0.15f), 0.f, 1.f) * MAX_FLUT;
|
||||
hiss = kt::coerceIn(p.f("hiss", 0.10f), 0.f, 1.f) * MAX_HISS;
|
||||
double secPerBeat = 60.0 / (double)tempoBpm;
|
||||
double frac = beatFraction(kt::toInt(p.f("division", 2.f)));
|
||||
double wowHz = 1.0 / kt::coerceAtLeast(frac * secPerBeat, 1e-4);
|
||||
wowInc = wowHz / sampleRate;
|
||||
flutInc = FLUTTER_HZ / sampleRate;
|
||||
}
|
||||
|
||||
float process(float x) override {
|
||||
buf[writePos] = x;
|
||||
writePos++; if (writePos >= size) writePos = 0;
|
||||
|
||||
curSpeed += (targetSpeed - curSpeed) * (double)SPEED_GLIDE; // tape inertia
|
||||
|
||||
wowPhase += wowInc; if (wowPhase >= 1.0) wowPhase -= 1.0;
|
||||
flutPhase += flutInc; if (flutPhase >= 1.0) flutPhase -= 1.0;
|
||||
double wow = std::sin(2.0 * M_PI * wowPhase) * (double)wowDepth;
|
||||
double flut = std::sin(2.0 * M_PI * flutPhase) * (double)flutDepth;
|
||||
double rate = curSpeed * (1.0 + wow + flut);
|
||||
if (rate < 0.01) rate = 0.01;
|
||||
|
||||
int i0 = (int)readPos % size;
|
||||
int i1 = (i0 + 1) % size;
|
||||
float frac = (float)(readPos - (int)readPos);
|
||||
float out = buf[i0] + (buf[i1] - buf[i0]) * frac;
|
||||
|
||||
double rp = readPos + rate;
|
||||
if (rp >= size) rp -= size;
|
||||
double gap = writePos - rp; if (gap < 0) gap += size;
|
||||
double maxGap = size - 2.0;
|
||||
if (gap < MIN_GAP) { rp = writePos - MIN_GAP; if (rp < 0) rp += size; }
|
||||
else if (gap > maxGap) { rp = writePos - maxGap; if (rp < 0) rp += size; }
|
||||
readPos = rp;
|
||||
|
||||
if (hiss > 0.f) out += nextRand() * hiss;
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
std::unique_ptr<Effect> makeTapeEngine(int sr) { return std::make_unique<TapeEngine>(sr); }
|
||||
|
||||
} // namespace sizzle
|
||||
@@ -0,0 +1,87 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// Renders every reference scenario exported by IosGoldenExport (Kotlin) through the
|
||||
// C++ core and compares sample by sample.
|
||||
//
|
||||
// golden_test <golden dir> [TYPE ...]
|
||||
//
|
||||
// A scenario passes when the largest difference is below 1e-4 (float rounding and
|
||||
// libm vs Java Math differ by an ulp here and there). Types with no C++ port yet are
|
||||
// listed as SKIP. Exit status is non-zero if any scenario fails.
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <dirent.h>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "sizzle/Effect.hpp"
|
||||
|
||||
using namespace sizzle;
|
||||
|
||||
static std::vector<float> readF32(const std::string &path) {
|
||||
std::ifstream f(path, std::ios::binary);
|
||||
std::vector<char> bytes((std::istreambuf_iterator<char>(f)), {});
|
||||
std::vector<float> out(bytes.size() / 4);
|
||||
std::memcpy(out.data(), bytes.data(), out.size() * 4);
|
||||
return out;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if (argc < 2) { std::fprintf(stderr, "usage: %s <golden dir> [TYPE ...]\n", argv[0]); return 2; }
|
||||
std::string dir = argv[1];
|
||||
std::vector<std::string> only(argv + 2, argv + argc);
|
||||
std::vector<float> input = readF32(dir + "/input.f32");
|
||||
if (input.empty()) { std::fprintf(stderr, "no input.f32 in %s (run make -C ios golden)\n", dir.c_str()); return 2; }
|
||||
|
||||
std::vector<std::string> scns;
|
||||
if (DIR *d = opendir(dir.c_str())) {
|
||||
while (dirent *e = readdir(d)) {
|
||||
std::string n = e->d_name;
|
||||
if (n.size() > 4 && n.compare(n.size() - 4, 4, ".scn") == 0) scns.push_back(n.substr(0, n.size() - 4));
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
std::sort(scns.begin(), scns.end());
|
||||
|
||||
int pass = 0, fail = 0, skip = 0;
|
||||
for (const auto &base : scns) {
|
||||
std::ifstream f(dir + "/" + base + ".scn");
|
||||
std::string line, type;
|
||||
int sr = 48000;
|
||||
float tempo = 120.f;
|
||||
Params p;
|
||||
while (std::getline(f, line)) {
|
||||
std::istringstream ls(line);
|
||||
std::string tag; ls >> tag;
|
||||
if (tag == "type") ls >> type;
|
||||
else if (tag == "sr") ls >> sr;
|
||||
else if (tag == "tempo") ls >> tempo;
|
||||
else if (tag == "p") {
|
||||
std::string key, val; ls >> key; std::getline(ls, val);
|
||||
if (!val.empty() && val[0] == ' ') val.erase(0, 1);
|
||||
p.set(key.c_str(), val.c_str());
|
||||
}
|
||||
}
|
||||
if (!only.empty() && std::find(only.begin(), only.end(), type) == only.end()) continue;
|
||||
auto fx = Effect::create(type.c_str(), sr);
|
||||
if (!fx) { std::printf("SKIP %-36s (not ported)\n", base.c_str()); ++skip; continue; }
|
||||
std::vector<float> want = readF32(dir + "/" + base + ".f32");
|
||||
fx->update(p, tempo);
|
||||
double maxErr = 0; size_t at = 0;
|
||||
for (size_t i = 0; i < input.size() && i < want.size(); ++i) {
|
||||
float y = fx->process(input[i]);
|
||||
double e = std::fabs((double)y - (double)want[i]);
|
||||
if (!(e <= maxErr)) { maxErr = e; at = i; } // NaN counts as worst
|
||||
}
|
||||
bool ok = maxErr < 1e-4 && want.size() == input.size();
|
||||
std::printf("%s %-36s max diff %.3g at sample %zu\n", ok ? "PASS" : "FAIL", base.c_str(), maxErr, at);
|
||||
ok ? ++pass : ++fail;
|
||||
}
|
||||
std::printf("\n%d passed, %d failed, %d not ported\n", pass, fail, skip);
|
||||
return fail ? 1 : 0;
|
||||
}
|
||||
Reference in New Issue
Block a user