@@ -35,13 +35,15 @@ Division::Division(Engine& engine, const String& name)
3535 , _midiChannel{0 }
3636 , _tremulantEnabled{false }
3737 , _tremulantLevel{0 .0f }
38- , _tremulantMaxLevel{1 . 0f }
38+ , _tremulantMaxLevel{TREMULANT_TARGET_LEVEL }
3939 , _tremulantTargetLevel{0 .0f }
4040 , _paramGain{nullptr }
4141 , _params{Division::NUM_PARAMS}
4242 , _swellFilterSpec{}
4343 , _swellFilterStateL{}
4444 , _swellFilterStateR{}
45+ , _tremulantDelayL(TREMULANT_DELAY_LENGTH)
46+ , _tremulantDelayR(TREMULANT_DELAY_LENGTH)
4547 , _stops{}
4648 , _activeVoices{}
4749 , _keysState{}
@@ -313,7 +315,7 @@ float Division::getTremulantLevel(bool update)
313315 const auto level = _tremulantLevel;
314316
315317 if (update)
316- _tremulantLevel += 0 .5f * (_tremulantTargetLevel - _tremulantLevel);
318+ _tremulantLevel += 0 .1f * (_tremulantTargetLevel - _tremulantLevel);
317319
318320 return level;
319321}
@@ -473,9 +475,20 @@ void Division::modulate(juce::AudioBuffer<float>& targetBuffer, const juce::Audi
473475 jassert (outR != nullptr );
474476
475477 for (int i = 0 ; i < SUB_FRAME_LENGTH; ++i) {
478+ _tremulantDelayL.write (outL[i]);
479+ _tremulantDelayR.write (outR[i]);
480+
476481 const float g = (1 .0f + gain[i] * lvl) * paramGain.nextValue ();
477- outL[i] *= g;
478- outR[i] *= g;
482+
483+ constexpr float freqModCenter = TREMULANT_DELAY_LENGTH * 0 .5f ;
484+ constexpr float freqModAmp = TREMULANT_DELAY_LENGTH * 0 .5f * TREMULANT_DELAY_MODULATION_LEVEL;
485+
486+ const float p = freqModCenter + freqModAmp * (0 .5f - gain[i] * lvl);
487+ outL[i] = _tremulantDelayL.read (p) * g;
488+ outR[i] = _tremulantDelayR.read (p) * g;
489+
490+ // outL[i] *= g;
491+ // outR[i] *= g;
479492 }
480493
481494 // Apply swell filter
0 commit comments