summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2019-06-29 18:29:20 +1000
committerDamien Zammit <damien@zamaudio.com>2019-06-29 18:29:20 +1000
commit5dc6f88dfcac4b27ce15c42f107fb20b726454af (patch)
treeab11fe9c2b1bd221547e01aa32ccd5870b4ac629
parente55da597442a617b7ac91d2a4f093d429d5762b6 (diff)
ZaMultiCompX2: Fix averaging
-rw-r--r--plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.cpp17
-rw-r--r--plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.hpp2
2 files changed, 12 insertions, 7 deletions
diff --git a/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.cpp b/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.cpp
index 3c9b447..d752e46 100644
--- a/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.cpp
+++ b/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.cpp
@@ -894,15 +894,20 @@ void ZaMultiCompX2Plugin::run_comp(int k, float inL, float inR, float *outL, flo
void ZaMultiCompX2Plugin::pushsample(float samples[], float sample, int k)
{
- float l1norm = 0.f;
+ int idx0, idx1, idx2;
- l1norm += fabsf(sample);
+ idx1 = pos[k];
++pos[k];
- if (pos[k] >= MAX_SAMPLES)
+ if (pos[k] >= MAX_SAMPLES) {
pos[k] = 0;
- l1norm -= fabsf(samples[pos[k]]);
- samples[pos[k]] = sample;
- average[k] += l1norm / (float) MAX_SAMPLES;
+ }
+ idx2 = pos[k];
+ idx0 = pos[k] + 1;
+ if (idx0 >= MAX_SAMPLES) {
+ idx0 = 0;
+ }
+ samples[idx2] = samples[idx1] + fabsf(sample);
+ average[k] = ( samples[idx2] - samples[idx0] ) / (float) MAX_SAMPLES;
}
void ZaMultiCompX2Plugin::run(const float** inputs, float** outputs, uint32_t frames)
diff --git a/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.hpp b/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.hpp
index 059180a..58b323d 100644
--- a/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.hpp
+++ b/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.hpp
@@ -23,7 +23,7 @@ START_NAMESPACE_DISTRHO
#define MAX_FILT 4
#define MAX_COMP 3
-#define MAX_SAMPLES 240
+#define MAX_SAMPLES 480
#define STEREOLINK_MAX 1
#define STEREOLINK_AVERAGE 0
#define DANGER 100000.f