Skip to content

Commit

Permalink
Initialize All Filters
Browse files Browse the repository at this point in the history
In two places, filters were using uninitialized memory at
creation. In some cases, for some values, in some instances,
this would create a large "pop" as the filter went unstable
with crazy coefficients or history values.

In my headless simulator, without these initialization changes
we get a click and pop within the first 100 instances. With them
there is no unstable run within 20,000 instances.

In theory this
Closes surge-synthesizer#790
Closes surge-synthesizer#753
Closes surge-synthesizer#699
Closes surge-synthesizer#698
Closes surge-synthesizer#662
Closes surge-synthesizer#660
  • Loading branch information
baconpaul committed Apr 1, 2019
1 parent acba954 commit 07de83c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/common/SurgeSynthesizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ SurgeSynthesizer::SurgeSynthesizer(PluginLayer* parent)
FBQ[1] =
(QuadFilterChainState*)_aligned_malloc((MAX_VOICES >> 2) * sizeof(QuadFilterChainState), 16);

for(int i=0; i<(MAX_VOICES >> 2); ++i)
{
FBQ[0][i].initToZero();
FBQ[1][i].initToZero();
}


SurgePatch& patch = storage.getPatch();

patch.polylimit.val.i = 8;
Expand Down
33 changes: 33 additions & 0 deletions src/common/dsp/QuadFilterChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,39 @@ struct QuadFilterChainState

__m128 OutL, OutR, dOutL, dOutR;
__m128 Out2L, Out2R, dOut2L, dOut2R; // fb_stereo only

void initToZero()
{
Gain = _mm_setzero_ps();
FB = _mm_setzero_ps();
Mix1 = _mm_setzero_ps();
Mix2 = _mm_setzero_ps();
Drive = _mm_setzero_ps();
dGain = _mm_setzero_ps();
dFB = _mm_setzero_ps();
dMix1 = _mm_setzero_ps();
dMix2 = _mm_setzero_ps();
dDrive = _mm_setzero_ps();

wsLPF = _mm_setzero_ps();
FBlineL = _mm_setzero_ps();
FBlineR = _mm_setzero_ps();

for(auto i=0; i<BLOCK_SIZE_OS; ++i)
{
DL[i] = _mm_setzero_ps();
DR[i] = _mm_setzero_ps();
}

OutL = _mm_setzero_ps();
OutR = _mm_setzero_ps();
dOutL = _mm_setzero_ps();
dOutR = _mm_setzero_ps();
Out2L = _mm_setzero_ps();
Out2R = _mm_setzero_ps();
dOut2L = _mm_setzero_ps();
dOut2R = _mm_setzero_ps();
}
};

struct fbq_global
Expand Down
5 changes: 5 additions & 0 deletions src/common/vt_dsp/halfratefilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,11 @@ void HalfRateFilter::set_coefficients(float* cA, float* cB)

void HalfRateFilter::load_coefficients()
{
for (int i = 0; i < M; i++)
{
va[i] = _mm_setzero_ps();
}

int order = M << 1;
if (steep)
{
Expand Down

0 comments on commit 07de83c

Please sign in to comment.