Skip to content

Commit

Permalink
Fix an Init Delay Timing Condition (#1453)
Browse files Browse the repository at this point in the history
Init on Delay with temposync could happen before the global
tempo was set when you unstreamed in a DAW. As a result the
lag for the time would catch up on the first and only first
play leading to glitches. To fix it, detect if setvars(true)
(the init condition) is called when temposync hasn't been set
yet and defer the initialization if so.

The frequency shifter would have the same bug so fix that also.

Closes #1444.
  • Loading branch information
baconpaul authored Jan 5, 2020
1 parent d24c1b7 commit 7b9b120
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/common/SurgeStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ SurgeStorage::SurgeStorage(std::string suppliedDataPath)
last_key[0] = 60;
last_key[1] = 60;
temposyncratio = 1.f;
temposyncratio_inv = 0.0f; // Use this as a sentinel (since it was not initialized prior to 1.6.5 this was the value at least win and mac had). #1444

songpos = 0;

for (int i = 0; i < n_customcontrollers; i++)
Expand Down
12 changes: 12 additions & 0 deletions src/common/dsp/effect/DualDelayEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,22 @@ void DualDelayEffect::init()
lp.suspend();
hp.suspend();
setvars(true);
inithadtempo = true;
// See issue #1444 and the fix for this stuff
if( storage->temposyncratio_inv == 0 )
{
inithadtempo = false;
}
}

void DualDelayEffect::setvars(bool init)
{
if( ! inithadtempo && storage->temposyncratio_inv != 0 )
{
init = true;
inithadtempo = true;
}

float fb = amp_to_linear(*f[2]);
float cf = amp_to_linear(*f[3]);

Expand Down
14 changes: 14 additions & 0 deletions src/common/dsp/effect/FreqshiftEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,24 @@ void FreqshiftEffect::init()
fi.reset();
ringout = 10000000;
setvars(true);

inithadtempo = true;
// See issue #1444 and the fix for this stuff
if( storage->temposyncratio_inv == 0 )
{
inithadtempo = false;
}

}

void FreqshiftEffect::setvars(bool init)
{
if( ! inithadtempo && storage->temposyncratio_inv != 0 )
{
init = true;
inithadtempo = true;
}

feedback.newValue(amp_to_linear(*f[fsp_feedback]));

if (init)
Expand Down
2 changes: 2 additions & 0 deletions src/common/dsp/effect/effect_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class DualDelayEffect : public Effect

private:
lag<float, true> timeL, timeR;
bool inithadtempo;
float envf;
int wpos;
BiquadFilter lp, hp;
Expand Down Expand Up @@ -121,6 +122,7 @@ class FreqshiftEffect : public Effect
private:
lipol<float, true> feedback;
lag<float, true> time, shiftL, shiftR;
bool inithadtempo;
float buffer[2][max_delay_length];
int wpos;
// CHalfBandFilter<6> frL,fiL,frR,fiR;
Expand Down

0 comments on commit 7b9b120

Please sign in to comment.