mirror of
https://codeberg.org/armin/rmx-19.git
synced 2026-10-11 16:51:55 +02:00
add generative evolution, cross-mod and reverb FX; expand preset bank
- 4 new params (xmod/xmix/evolve/warp) with free-running brownian evolution - evolution: tune drift, osc2 detune sway, osc-mix crossfade, filter cutoff wander, resonance growl, warp drive/bias, cross-mod bloom - per-voice unison detune spread for fat stacks - FX engine: 3-tap ensemble chorus, filtered-feedback ping-pong delay, Schroeder hall reverb; new FX types 4-7 (REV HALL/ENS+REV/DLY+REV/CATHEDRAL) - 195 presets: 40-field realignment, genre-tuned FX identities, showcase eval - calibrate banks vs attack-inclusive peak (median 0.263); fix square-LFO on filter sustain collapse
This commit is contained in:
parent
bc417e1cc1
commit
35d6cd014a
8 changed files with 2016 additions and 601 deletions
|
|
@ -8,7 +8,7 @@ void SynthEngine::setSampleRate (double s)
|
|||
sr = s;
|
||||
}
|
||||
|
||||
float SynthEngine::osc (int wave, double ph)
|
||||
float SynthEngine::osc (int wave, double ph, double phRaw)
|
||||
{
|
||||
switch (wave)
|
||||
{
|
||||
|
|
@ -17,6 +17,90 @@ float SynthEngine::osc (int wave, double ph)
|
|||
case 2: return (float) (1.0 - 2.0 * ph);
|
||||
case 3: return (float) (ph < 0.5 ? -1.0 : 1.0);
|
||||
case 4: return rng.nextFloat() * 2.0f - 1.0f;
|
||||
|
||||
// 5 FM: 2-op sine FM (1:2 ratio), index slowly evolves over the note
|
||||
case 5:
|
||||
{
|
||||
const double idx = 2.2 + 1.6 * (0.5 + 0.5 * std::sin (phRaw * 0.03));
|
||||
return (float) std::sin (ph * 2.0 * juce::MathConstants<double>::pi
|
||||
+ idx * std::sin (ph * 4.0 * juce::MathConstants<double>::pi));
|
||||
}
|
||||
// 6 PWM: pulse whose width animates with the running phase
|
||||
case 6:
|
||||
{
|
||||
const double w = 0.05 + 0.60 * (0.5 + 0.5 * std::sin (phRaw * 0.05));
|
||||
return (float) (ph < w ? 1.0 : -1.0);
|
||||
}
|
||||
// 7 SUPRSW: 5 stacked saws with a slowly moving spread (detuned-stack feel)
|
||||
case 7:
|
||||
{
|
||||
const double df = 0.006 * std::sin (phRaw * 0.02);
|
||||
double s = 0.0;
|
||||
for (int k = -2; k <= 2; ++k)
|
||||
{
|
||||
double sp = ph + df + k * 0.13;
|
||||
sp -= std::floor (sp);
|
||||
s += 1.0 - 2.0 * sp;
|
||||
}
|
||||
return (float) (s * 0.40);
|
||||
}
|
||||
// 8 DBLSAW: saw plus a sub-octave saw (big, weighted low end)
|
||||
case 8:
|
||||
{
|
||||
double sub = ph * 0.5;
|
||||
sub -= std::floor (sub);
|
||||
return (float) (0.62 * (1.0 - 2.0 * ph) + 0.48 * (1.0 - 2.0 * sub));
|
||||
}
|
||||
// 9 WARP: saw pushed twice through a wavefolder -> bright, buzzy, raw
|
||||
case 9:
|
||||
{
|
||||
double x = 1.0 - 2.0 * ph;
|
||||
x = 1.0 - 2.0 * std::fabs (1.0 - std::fabs (x));
|
||||
x = 1.0 - 2.0 * std::fabs (1.0 - std::fabs (x));
|
||||
return (float) x;
|
||||
}
|
||||
// 10 HSYNC: saw hard-synced to a 2.5x master -> bright, cutting lead
|
||||
case 10:
|
||||
{
|
||||
double sp = ph * 2.5;
|
||||
sp -= std::floor (sp);
|
||||
return (float) (1.0 - 2.0 * sp);
|
||||
}
|
||||
// 11 TINE: electric-tine partial stack (1x,2x,4x,8x) -> bell/marimba/EP
|
||||
case 11:
|
||||
{
|
||||
const double a = ph * 2.0 * juce::MathConstants<double>::pi;
|
||||
return (float) (0.85 * std::sin (a)
|
||||
+ 0.55 * std::sin (2.0 * a)
|
||||
+ 0.35 * std::sin (4.0 * a)
|
||||
+ 0.18 * std::sin (8.0 * a));
|
||||
}
|
||||
// 12 SEQ: 8 pseudo-random levels per cycle -> digital, step-sequencer
|
||||
case 12:
|
||||
{
|
||||
static const float L[8] = { 0.90f, -0.45f, 0.30f, -0.85f,
|
||||
0.55f, -0.20f, 0.75f, -0.60f };
|
||||
const int k = (int) std::floor (ph * 8.0);
|
||||
return L[k & 7];
|
||||
}
|
||||
// 13 CHORD: built-in minor triad (root, m3, 5th) -> one-osc chord
|
||||
case 13:
|
||||
{
|
||||
const double a = ph * 2.0 * juce::MathConstants<double>::pi;
|
||||
return (float) (0.62 * std::sin (a)
|
||||
+ 0.42 * std::sin (a * (6.0 / 5.0))
|
||||
+ 0.38 * std::sin (a * 1.5));
|
||||
}
|
||||
// 14 SUPRPL: 3 stacked phase-offset pulse waves -> fat chorus-box square
|
||||
case 14:
|
||||
{
|
||||
const double o1 = ph < 0.5 ? 1.0 : -1.0;
|
||||
double p2 = ph + 0.10; p2 -= std::floor (p2);
|
||||
const double o2 = p2 < 0.5 ? 1.0 : -1.0;
|
||||
double p3 = ph + 0.25; p3 -= std::floor (p3);
|
||||
const double o3 = p3 < 0.5 ? 1.0 : -1.0;
|
||||
return (float) ((o1 + o2 + o3) * (1.0 / 3.0));
|
||||
}
|
||||
default: return 0.0f;
|
||||
}
|
||||
}
|
||||
|
|
@ -80,12 +164,19 @@ void SynthEngine::noteOn (int midiNote, float velocity)
|
|||
v->targetFreq = noteFreq;
|
||||
v->ph1 = rng.nextDouble() * 0.5;
|
||||
v->ph2 = rng.nextDouble() * 0.5;
|
||||
v->ph1r = rng.nextDouble() * 8.0;
|
||||
v->ph2r = rng.nextDouble() * 8.0;
|
||||
v->lfoPh = rng.nextDouble();
|
||||
v->lfoIdx = 0;
|
||||
v->lfoSH = rng.nextFloat() * 2.0f - 1.0f;
|
||||
v->lp = v->bp = 0.0f;
|
||||
v->fcSm = 0.0f;
|
||||
v->outSmooth = 0.0f;
|
||||
v->drift = 0.0f;
|
||||
v->driftT = rng.nextFloat() * 2.0f - 1.0f;
|
||||
// Micro Q-style unison: every voice gets its own small detune offset, the
|
||||
// spread widening with the DETUNE 1 setting, for fat stacks on chords
|
||||
v->dtSp = (rng.nextFloat() * 2.0f - 1.0f) * (1.5f + 0.30f * std::abs (curDetune1));
|
||||
|
||||
const float p = juce::jlimit (-1.0f, 1.0f, lastPan + (rng.nextFloat() - 0.5f) * 0.1f);
|
||||
const float ang = (p + 1.0f) * juce::MathConstants<float>::pi * 0.25f;
|
||||
|
|
@ -114,6 +205,7 @@ void SynthEngine::noteOff (int midiNote)
|
|||
|
||||
void SynthEngine::render (const VParams& p, float* left, float* right, int num)
|
||||
{
|
||||
curDetune1 = p.detune1;
|
||||
for (auto& v : voices)
|
||||
{
|
||||
v.amp.setRates (p.ampA, p.ampD, p.ampS, p.ampR, sr);
|
||||
|
|
@ -131,8 +223,33 @@ void SynthEngine::render (const VParams& p, float* left, float* right, int num)
|
|||
const float maxFc = 0.4f * (float) sr;
|
||||
const float minFc = 30.0f;
|
||||
|
||||
// Free-running slow-evolution clock: every ~8 s the running patch rolls a
|
||||
// new wander target, and evoCur slews toward it, so harmonic character,
|
||||
// tuning instability and cross-mod bloom all slowly drift and come back.
|
||||
// Generative evolution clock. evoCur is a true brownian walk that roams the
|
||||
// whole [-1,1] range without ever repeating, plus occasional "excursions"
|
||||
// that push it to a freshly rolled extreme for 7-18 s. evoSlow is a second,
|
||||
// much slower wander that drives the long-arc soundscape drift over 1-3
|
||||
// minutes. Together they make a held note slowly change character forever.
|
||||
for (int s = 0; s < num; ++s)
|
||||
{
|
||||
if (--evoGoalT <= 0.0)
|
||||
{
|
||||
evoGoalT = sr * (7.0 + rng.nextDouble() * 11.0);
|
||||
evoGoal = (rng.nextFloat() < 0.5f ? -1.0f : 1.0f)
|
||||
* (0.65f + 0.35f * rng.nextFloat());
|
||||
for (auto& v : voices)
|
||||
if (v.active)
|
||||
v.driftT = rng.nextFloat() * 2.0f - 1.0f;
|
||||
}
|
||||
evoCur += (rng.nextFloat() - 0.5f) * 0.0022f
|
||||
+ (evoGoal - evoCur) * 0.00035f;
|
||||
evoCur = std::max (-1.0f, std::min (1.0f, evoCur));
|
||||
|
||||
evoSlow += (rng.nextFloat() - 0.5f) * 0.0028f
|
||||
+ (0.0f - evoSlow) * 0.0000002f;
|
||||
evoSlow = std::max (-1.0f, std::min (1.0f, evoSlow));
|
||||
|
||||
float mixL = 0.0f, mixR = 0.0f;
|
||||
int activeCount = 0;
|
||||
for (auto& v : voices)
|
||||
|
|
@ -172,29 +289,74 @@ void SynthEngine::render (const VParams& p, float* left, float* right, int num)
|
|||
float freq = v.curFreq * tuneRatio;
|
||||
if ((int) p.lfoTarget == 1)
|
||||
freq *= std::exp2f (lfo * p.lfoDepth * 1.6f / 12.0f);
|
||||
if (p.evolve > 0.001f)
|
||||
{
|
||||
// slow random tuning instability, re-rolled with each excursion
|
||||
v.drift += (v.driftT - v.drift) * 0.0020f;
|
||||
freq *= std::exp2f (v.drift * p.evolve * 14.0f / 1200.0f);
|
||||
}
|
||||
if (bendSmooth != bendCents)
|
||||
bendSmooth += (bendCents - bendSmooth) * 0.08f;
|
||||
freq *= std::exp2f (bendSmooth / 1200.0f);
|
||||
|
||||
const float d1 = (float) (freq / sr) * detuneRatio1;
|
||||
const float d2 = (float) (freq / sr) * detuneRatio2;
|
||||
const float d1 = (float) (freq / sr) * detuneRatio1 * std::exp2f (v.dtSp / 1200.0f);
|
||||
// soundscape detune sway: osc2 slowly zooms its detune in/out
|
||||
const float swayT = std::exp2f (evoSlow * p.evolve * 16.0f / 1200.0f);
|
||||
const float d2 = (float) (freq / sr) * detuneRatio2 * swayT;
|
||||
|
||||
v.ph1 += d1; if (v.ph1 >= 1.0) v.ph1 -= 1.0;
|
||||
v.ph2 += d2; if (v.ph2 >= 1.0) v.ph2 -= 1.0;
|
||||
v.ph1r += d1;
|
||||
|
||||
const float o1 = osc ((int) p.osc1w, v.ph1);
|
||||
const float o2 = osc ((int) p.osc2w, v.ph2);
|
||||
const float mixb = p.oscMix * 0.01f;
|
||||
// cross-mod "bloom": the amount itself breathes with the evolution walk,
|
||||
// sometimes vanishing almost entirely, sometimes saturating
|
||||
float xmA = 0.0f;
|
||||
if ((int) p.xmod > 0 && p.xmix > 0.001f)
|
||||
xmA = p.xmix * (0.10f + 0.90f * (0.5f + 0.5f * evoCur));
|
||||
|
||||
// oscillators, with osc1 phase-modulating osc2 when in FM cross-mod
|
||||
const float o1 = osc ((int) p.osc1w, v.ph1, v.ph1r);
|
||||
float d2step = d2;
|
||||
if ((int) p.xmod == 2 && xmA > 0.0f)
|
||||
d2step = d2 * (1.0f + o1 * xmA);
|
||||
v.ph2 += d2step; if (v.ph2 >= 1.0) v.ph2 -= 1.0;
|
||||
v.ph2r += d2step;
|
||||
const float o2 = osc ((int) p.osc2w, v.ph2, v.ph2r);
|
||||
// osc-mix crossfade: the o1<->o2 balance slowly sways with the
|
||||
// soundscape wander, visibly respraying the whole timbre over ~a minute
|
||||
const float mixBase = p.oscMix * 0.01f;
|
||||
float mixb = mixBase * (1.0f + evoSlow * p.evolve * 0.8f);
|
||||
mixb = std::max (0.0f, std::min (0.98f, mixb));
|
||||
float sig = o1 * (1.0f - mixb) + o2 * mixb;
|
||||
|
||||
// ring / AM cross-mod spiced into the mix
|
||||
if (xmA > 0.0f)
|
||||
{
|
||||
const int xm = (int) p.xmod;
|
||||
if (xm == 1) sig += o1 * o2 * 0.6f * xmA;
|
||||
else if (xm == 3) sig += o1 * o2 * 0.9f * xmA;
|
||||
}
|
||||
|
||||
// spectral warp: drive + bias swing hard with the texture wander,
|
||||
// folding harmonics way in and pulling back out over tens of seconds
|
||||
if (p.warp > 0.001f)
|
||||
{
|
||||
const float drive = 1.0f + p.warp * (1.0f + 3.2f * std::max (0.0f, evoCur));
|
||||
sig = std::tanh (sig * drive + evoCur * 0.30f * p.warp);
|
||||
}
|
||||
|
||||
const float fe = v.flt.next();
|
||||
|
||||
// gentle analog drive ahead of the filter (resonance pushes harder)
|
||||
sig = std::tanh (sig * (1.0f + p.fltRes * 0.15f));
|
||||
|
||||
// cutoff with keytrack + filter envelope + LFO + mod wheel
|
||||
float fc = p.fltCut;
|
||||
fc *= std::exp2f (p.fltKey * 0.01f * std::log2f (freq / 261.6256f));
|
||||
fc *= std::exp2f (p.fltEnv * 0.01f * fe * std::log2f (maxFc / fc));
|
||||
if ((int) p.lfoTarget == 0)
|
||||
fc *= std::exp2f (lfo * p.lfoDepth * 10.0f / 12.0f);
|
||||
if (p.evolve > 0.001f)
|
||||
fc *= std::exp2f (evoCur * p.evolve * 4.0f / 12.0f);
|
||||
fc *= std::exp2f (mod);
|
||||
fc = std::min (maxFc, std::max (minFc, fc));
|
||||
v.fcSm += (fc - v.fcSm) * 0.25f;
|
||||
|
|
@ -203,18 +365,23 @@ void SynthEngine::render (const VParams& p, float* left, float* right, int num)
|
|||
// SVF (cap f1 to keep the Chamberlin structure stable; past ~1.5 the
|
||||
// resonance feedback can self-oscillate and sputter at maxed cutoff+res)
|
||||
const float f1 = std::min (1.50f, 2.0f * std::sin (juce::MathConstants<float>::pi * fc / (float) sr));
|
||||
const float q1 = 1.0f / (1.0f + p.fltRes * 3.0f);
|
||||
// resonance growl: filter tightens/loosens with the soundscape wander
|
||||
const float q1 = 1.0f / (1.0f + p.fltRes * (3.0f + evoCur * p.evolve * 2.5f));
|
||||
v.f1c = f1;
|
||||
const float hp = sig - v.lp - q1 * v.bp;
|
||||
v.bp += f1 * hp;
|
||||
v.lp += f1 * v.bp;
|
||||
|
||||
// The Chamberlin band-pass and high-pass taps carry much less energy
|
||||
// than the low-pass tap for the harmonically rich osc waves (2-4x
|
||||
// quieter in practice), so compensate to keep filter types at a
|
||||
// comparable loudness level.
|
||||
float filtered = sig;
|
||||
switch ((int) p.fltType)
|
||||
{
|
||||
case 1: filtered = v.lp; break;
|
||||
case 2: filtered = v.bp; break;
|
||||
case 3: filtered = hp; break;
|
||||
case 2: filtered = v.bp * 2.9f; break;
|
||||
case 3: filtered = hp * 2.7f; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
|
@ -223,6 +390,7 @@ void SynthEngine::render (const VParams& p, float* left, float* right, int num)
|
|||
float ampMod = 1.0f;
|
||||
if ((int) p.lfoTarget == 2)
|
||||
ampMod = 1.0f - p.lfoDepth * 0.5f * (1.0f + lfo);
|
||||
ampMod *= 1.0f + evoSlow * p.evolve * 0.10f;
|
||||
|
||||
v.outSmooth += (filtered - v.outSmooth) * 0.12f;
|
||||
float o = v.outSmooth * (ae * ampMod) * v.vel * voiceGain;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue