From 07de83c28ca6031bb0a9f1826ad9fc8508d93241 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 1 Apr 2019 11:30:40 -0400 Subject: [PATCH] Initialize All Filters 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 #790 Closes #753 Closes #699 Closes #698 Closes #662 Closes #660 --- src/common/SurgeSynthesizer.cpp | 7 ++++++ src/common/dsp/QuadFilterChain.h | 33 ++++++++++++++++++++++++++++ src/common/vt_dsp/halfratefilter.cpp | 5 +++++ 3 files changed, 45 insertions(+) diff --git a/src/common/SurgeSynthesizer.cpp b/src/common/SurgeSynthesizer.cpp index 77a2e93ba9d..a372f2d2d30 100644 --- a/src/common/SurgeSynthesizer.cpp +++ b/src/common/SurgeSynthesizer.cpp @@ -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; diff --git a/src/common/dsp/QuadFilterChain.h b/src/common/dsp/QuadFilterChain.h index 163b7fbf251..d107e859449 100644 --- a/src/common/dsp/QuadFilterChain.h +++ b/src/common/dsp/QuadFilterChain.h @@ -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