Skip to content

Commit

Permalink
Add an optional LFO onepole for FROM_LAST envelope mode (#6699)
Browse files Browse the repository at this point in the history
* Add an optional LFO onepole for FROM_LAST envelope mode

In envelope mode with high deform in FROM_LAST mode the
signal from the envelope is not continuous. This is basically
unsolvable analytically - the deform plus state is too hard -
and so leave it on by default but add an optional one pole to
smooth it out, which may be useful in some cases.

Expose configurations of that to the rack LFO

Addresses surge-synthesizer/surge-rack#607
  • Loading branch information
baconpaul authored Nov 13, 2022
1 parent 20846fb commit 70aca67
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/common/dsp/modulators/LFOModulationSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ void LFOModulationSource::assign(SurgeStorage *storage, LFOStorage *lfo, pdata *
{
wf_history[i] = 0.f;
}

for (int i = 0; i < 3; ++i)
onepoleState[i] = 0.f;
}

float LFOModulationSource::bend1(float x)
Expand Down Expand Up @@ -1289,6 +1292,16 @@ void LFOModulationSource::process_block()
output_multi[1] *= useenvval;
output_multi[1] += useenv0;
}

if (envRetrigMode == FROM_LAST && lfo->deform.deform_type != type_3)
{
// Now appy the one pole
float alpha = onepoleFactor;
output_multi[0] = (1.0 - alpha) * output_multi[0] + alpha * onepoleState[0];
output_multi[1] = (1.0 - alpha) * output_multi[1] + alpha * onepoleState[1];
onepoleState[0] = output_multi[0];
onepoleState[1] = output_multi[1];
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/common/dsp/modulators/LFOModulationSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class LFOModulationSource : public ModulationSource
inline int getEnvState() { return env_state; }
inline int getStep() { return step; }

float onepoleFactor{0};

private:
pdata *localcopy;
bool phaseInitialized;
Expand All @@ -128,6 +130,8 @@ class LFOModulationSource : public ModulationSource
int step, shuffle_id;
int magn, rate, iattack, idecay, idelay, ihold, isustain, irelease, startphase, ideform;

float onepoleState[3];

std::default_random_engine gen;
std::uniform_real_distribution<float> distro;
std::function<float()> urng;
Expand Down

0 comments on commit 70aca67

Please sign in to comment.