summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2019-06-29 12:23:07 +1000
committerDamien Zammit <damien@zamaudio.com>2019-06-29 12:23:07 +1000
commit82b18110e5c625732c13500cf5fd2ba4a64a1d3f (patch)
tree4bb0cacaa272be5dda8a55841a79b29fea1304b0
parent551903a38ad69268dfcfcd33da0127de57410aa9 (diff)
Compressors: 5% speedup by using fabsf instead of fabs && reduce MAX_SAMPLES
-rw-r--r--plugins/ZaMultiComp/ZaMultiCompPlugin.cpp6
-rw-r--r--plugins/ZaMultiComp/ZaMultiCompUI.cpp6
-rw-r--r--plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.cpp16
-rw-r--r--plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.hpp2
-rw-r--r--plugins/ZaMultiCompX2/ZaMultiCompX2UI.cpp6
-rw-r--r--plugins/ZamComp/ZamCompPlugin.cpp4
-rw-r--r--plugins/ZamCompX2/ZamCompX2Plugin.cpp10
7 files changed, 25 insertions, 25 deletions
diff --git a/plugins/ZaMultiComp/ZaMultiCompPlugin.cpp b/plugins/ZaMultiComp/ZaMultiCompPlugin.cpp
index 433b18e..5d3b9c6 100644
--- a/plugins/ZaMultiComp/ZaMultiCompPlugin.cpp
+++ b/plugins/ZaMultiComp/ZaMultiCompPlugin.cpp
@@ -795,10 +795,10 @@ void ZaMultiCompPlugin::run_comp(int k, float in, float *out)
Lyg = 0.f;
in = sanitize_denormal(in);
- Lxg = (in==0.f) ? -160.f : to_dB(fabs(in));
+ Lxg = (in==0.f) ? -160.f : to_dB(fabsf(in));
Lxg = sanitize_denormal(Lxg);
- checkwidth = 2.f*fabs(Lxg-thresdb[k]);
+ checkwidth = 2.f*fabsf(Lxg-thresdb[k]);
if (2.f*(Lxg-thresdb[k]) < -width) {
Lyg = Lxg;
} else if (checkwidth <= width) {
@@ -881,7 +881,7 @@ void ZaMultiCompPlugin::run(const float** inputs, float** outputs, uint32_t fram
float fil1[2], fil2[2], fil3[2], fil4[2];
float outL[MAX_COMP+1] = {0.f};
float inl = sanitize_denormal(inputs[0][i]);
- inl = (fabs(inl) < DANGER) ? inl : 0.f;
+ inl = (fabsf(inl) < DANGER) ? inl : 0.f;
int listenmode = 0;
diff --git a/plugins/ZaMultiComp/ZaMultiCompUI.cpp b/plugins/ZaMultiComp/ZaMultiCompUI.cpp
index b6d93e1..0963524 100644
--- a/plugins/ZaMultiComp/ZaMultiCompUI.cpp
+++ b/plugins/ZaMultiComp/ZaMultiCompUI.cpp
@@ -315,12 +315,12 @@ void ZaMultiCompUI::compcurve(float in, int k, float *outx, float* outy) {
float xg, yg;
yg = 0.f;
- xg = (in==0.f) ? -160.f : to_dB(fabs(in));
+ xg = (in==0.f) ? -160.f : to_dB(fabsf(in));
xg = sanitize_denormal(xg);
if (2.f*(xg-thresdb)<-width) {
yg = xg;
- } else if (2.f*fabs(xg-thresdb)<=width) {
+ } else if (2.f*fabsf(xg-thresdb)<=width) {
yg = xg + (1.f/ratio-1.f)*(xg-thresdb+width/2.f)*(xg-thresdb+width/2.f)/(2.f*width);
} else if (2.f*(xg-thresdb)>width) {
yg = thresdb + (xg-thresdb)/ratio;
@@ -337,7 +337,7 @@ void ZaMultiCompUI::compdot(float in, int k, float *outx, float* outy) {
float xg, yg;
yg = 0.f;
- xg = (in==0.f) ? -160.f : to_dB(fabs(in));
+ xg = (in==0.f) ? -160.f : to_dB(fabsf(in));
xg = sanitize_denormal(xg);
yg = xg - fLedRedValue[k];
yg = sanitize_denormal(yg);
diff --git a/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.cpp b/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.cpp
index 0ec325b..6c54a8f 100644
--- a/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.cpp
+++ b/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.cpp
@@ -817,12 +817,12 @@ void ZaMultiCompX2Plugin::run_comp(int k, float inL, float inR, float *outL, flo
Lyg = Ryg = 0.f;
inL = sanitize_denormal(inL);
inR = sanitize_denormal(inR);
- Lxg = (inL==0.f) ? -160.f : to_dB(fabs(inL));
- Rxg = (inR==0.f) ? -160.f : to_dB(fabs(inR));
+ Lxg = (inL==0.f) ? -160.f : to_dB(fabsf(inL));
+ Rxg = (inR==0.f) ? -160.f : to_dB(fabsf(inR));
Lxg = sanitize_denormal(Lxg);
Rxg = sanitize_denormal(Rxg);
- checkwidth = 2.f*fabs(Lxg-thresdb[k]);
+ checkwidth = 2.f*fabsf(Lxg-thresdb[k]);
if (2.f*(Lxg-thresdb[k]) < -width) {
Lyg = Lxg;
} else if (checkwidth <= width) {
@@ -833,7 +833,7 @@ void ZaMultiCompX2Plugin::run_comp(int k, float inL, float inR, float *outL, flo
Lyg = sanitize_denormal(Lyg);
}
- checkwidth = 2.f*fabs(Rxg-thresdb[k]);
+ checkwidth = 2.f*fabsf(Rxg-thresdb[k]);
if (2.f*(Rxg-thresdb[k]) < -width) {
Ryg = Rxg;
} else if (checkwidth <= width) {
@@ -906,10 +906,10 @@ float ZaMultiCompX2Plugin::averageabs(float samples[])
float average = 0.f;
for (i = 0; i < MAX_SAMPLES; i++) {
- average += samples[i]*samples[i];
+ average += fabsf(samples[i]);
}
average /= (float) MAX_SAMPLES;
- return sqrt(average);
+ return average;
}
void ZaMultiCompX2Plugin::run(const float** inputs, float** outputs, uint32_t frames)
@@ -945,8 +945,8 @@ void ZaMultiCompX2Plugin::run(const float** inputs, float** outputs, uint32_t fr
float outR[MAX_COMP+1] = {0.f};
float inl = sanitize_denormal(inputs[0][i]);
float inr = sanitize_denormal(inputs[1][i]);
- inl = (fabs(inl) < DANGER) ? inl : 0.f;
- inr = (fabs(inr) < DANGER) ? inr : 0.f;
+ inl = (fabsf(inl) < DANGER) ? inl : 0.f;
+ inr = (fabsf(inr) < DANGER) ? inr : 0.f;
int listenmode = 0;
diff --git a/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.hpp b/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.hpp
index 069b60c..535a7ff 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 480
+#define MAX_SAMPLES 240
#define STEREOLINK_MAX 1
#define STEREOLINK_AVERAGE 0
#define DANGER 100000.f
diff --git a/plugins/ZaMultiCompX2/ZaMultiCompX2UI.cpp b/plugins/ZaMultiCompX2/ZaMultiCompX2UI.cpp
index ff45585..a263aa7 100644
--- a/plugins/ZaMultiCompX2/ZaMultiCompX2UI.cpp
+++ b/plugins/ZaMultiCompX2/ZaMultiCompX2UI.cpp
@@ -320,12 +320,12 @@ void ZaMultiCompX2UI::compcurve(float in, int k, float *outx, float* outy) {
float xg, yg;
yg = 0.f;
- xg = (in==0.f) ? -160.f : to_dB(fabs(in));
+ xg = (in==0.f) ? -160.f : to_dB(fabsf(in));
xg = sanitize_denormal(xg);
if (2.f*(xg-thresdb)<-width) {
yg = xg;
- } else if (2.f*fabs(xg-thresdb)<=width) {
+ } else if (2.f*fabsf(xg-thresdb)<=width) {
yg = xg + (1.f/ratio-1.f)*(xg-thresdb+width/2.f)*(xg-thresdb+width/2.f)/(2.f*width);
} else if (2.f*(xg-thresdb)>width) {
yg = thresdb + (xg-thresdb)/ratio;
@@ -342,7 +342,7 @@ void ZaMultiCompX2UI::compdot(float in, int k, float *outx, float* outy) {
float xg, yg;
yg = 0.f;
- xg = (in==0.f) ? -160.f : to_dB(fabs(in));
+ xg = (in==0.f) ? -160.f : to_dB(fabsf(in));
xg = sanitize_denormal(xg);
yg = xg - fLedRedValue[k];
yg = sanitize_denormal(yg);
diff --git a/plugins/ZamComp/ZamCompPlugin.cpp b/plugins/ZamComp/ZamCompPlugin.cpp
index 53aae56..7c0651c 100644
--- a/plugins/ZamComp/ZamCompPlugin.cpp
+++ b/plugins/ZamComp/ZamCompPlugin.cpp
@@ -314,12 +314,12 @@ void ZamCompPlugin::run(const float** inputs, float** outputs, uint32_t frames)
ingain = usesidechain ? in1 : in0;
attslew = 0;
Lyg = 0.f;
- Lxg = (ingain==0.f) ? -160.f : to_dB(fabs(ingain));
+ Lxg = (ingain==0.f) ? -160.f : to_dB(fabsf(ingain));
Lxg = sanitize_denormal(Lxg);
Lyg = Lxg + (1.f/ratio-1.f)*(Lxg-thresdb+width/2.f)*(Lxg-thresdb+width/2.f)/(2.f*width);
- checkwidth = 2.f*fabs(Lxg-thresdb);
+ checkwidth = 2.f*fabsf(Lxg-thresdb);
if (2.f*(Lxg-thresdb) < -width) {
Lyg = Lxg;
} else if (checkwidth <= width) {
diff --git a/plugins/ZamCompX2/ZamCompX2Plugin.cpp b/plugins/ZamCompX2/ZamCompX2Plugin.cpp
index 3be916d..87824ba 100644
--- a/plugins/ZamCompX2/ZamCompX2Plugin.cpp
+++ b/plugins/ZamCompX2/ZamCompX2Plugin.cpp
@@ -337,11 +337,11 @@ void ZamCompX2Plugin::run(const float** inputs, float** outputs, uint32_t frames
attslew = 0;
Lyg = Ryg = 0.f;
if (usesidechain) {
- Lxg = (ingain==0.f) ? -160.f : to_dB(fabs(ingain));
+ Lxg = (ingain==0.f) ? -160.f : to_dB(fabsf(ingain));
Rxg = Lxg;
} else {
- Lxg = (in0==0.f) ? -160.f : to_dB(fabs(in0));
- Rxg = (in1==0.f) ? -160.f : to_dB(fabs(in1));
+ Lxg = (in0==0.f) ? -160.f : to_dB(fabsf(in0));
+ Rxg = (in1==0.f) ? -160.f : to_dB(fabsf(in1));
}
Lxg = sanitize_denormal(Lxg);
Rxg = sanitize_denormal(Rxg);
@@ -349,7 +349,7 @@ void ZamCompX2Plugin::run(const float** inputs, float** outputs, uint32_t frames
Lyg = Lxg + (1.f/ratio-1.f)*(Lxg-thresdb+width/2.f)*(Lxg-thresdb+width/2.f)/(2.f*width);
Ryg = Rxg + (1.f/ratio-1.f)*(Rxg-thresdb+width/2.f)*(Rxg-thresdb+width/2.f)/(2.f*width);
- checkwidth = 2.f*fabs(Lxg-thresdb);
+ checkwidth = 2.f*fabsf(Lxg-thresdb);
if (2.f*(Lxg-thresdb) < -width) {
Lyg = Lxg;
} else if (checkwidth <= width) {
@@ -365,7 +365,7 @@ void ZamCompX2Plugin::run(const float** inputs, float** outputs, uint32_t frames
Lyg = sanitize_denormal(Lyg);
}
- checkwidth = 2.f*fabs(Rxg-thresdb);
+ checkwidth = 2.f*fabsf(Rxg-thresdb);
if (2.f*(Rxg-thresdb) < -width) {
Ryg = Rxg;
} else if (checkwidth <= width) {