aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/WinVST/Logical4
diff options
context:
space:
mode:
authorChris Johnson <jinx6568@sover.net>2019-01-27 21:13:54 -0500
committerChris Johnson <jinx6568@sover.net>2019-01-27 21:13:54 -0500
commit966f2d253cd2ee6ce140ad68095a20a9d2b63052 (patch)
treeb0400d95bd06512531ade6ddf55190a58b6a5623 /plugins/WinVST/Logical4
parent0887543349dbbec0721a1fc8b1c7deba9afefa8b (diff)
downloadairwindows-lv2-port-966f2d253cd2ee6ce140ad68095a20a9d2b63052.tar.gz
airwindows-lv2-port-966f2d253cd2ee6ce140ad68095a20a9d2b63052.tar.bz2
airwindows-lv2-port-966f2d253cd2ee6ce140ad68095a20a9d2b63052.zip
Floating Point Dither For All
Diffstat (limited to 'plugins/WinVST/Logical4')
-rwxr-xr-xplugins/WinVST/Logical4/.vs/VSTProject/v14/.suobin23040 -> 23040 bytes
-rwxr-xr-xplugins/WinVST/Logical4/Logical4.cpp7
-rwxr-xr-xplugins/WinVST/Logical4/Logical4.h6
-rwxr-xr-xplugins/WinVST/Logical4/Logical4Proc.cpp68
4 files changed, 28 insertions, 53 deletions
diff --git a/plugins/WinVST/Logical4/.vs/VSTProject/v14/.suo b/plugins/WinVST/Logical4/.vs/VSTProject/v14/.suo
index 0a67ad3..34fa65c 100755
--- a/plugins/WinVST/Logical4/.vs/VSTProject/v14/.suo
+++ b/plugins/WinVST/Logical4/.vs/VSTProject/v14/.suo
Binary files differ
diff --git a/plugins/WinVST/Logical4/Logical4.cpp b/plugins/WinVST/Logical4/Logical4.cpp
index b17cc55..15d185b 100755
--- a/plugins/WinVST/Logical4/Logical4.cpp
+++ b/plugins/WinVST/Logical4/Logical4.cpp
@@ -77,12 +77,9 @@ Logical4::Logical4(audioMasterCallback audioMaster) :
gcount = 0;
//end Power Sags
-
- fpNShapeLA = 0.0;
- fpNShapeLB = 0.0;
- fpNShapeRA = 0.0;
- fpNShapeRB = 0.0;
fpFlip = true;
+ fpNShapeL = 0.0;
+ fpNShapeR = 0.0;
//this is reset: values being initialized only once. Startup values, whatever they are.
_canDo.insert("plugAsChannelInsert"); // plug-in can be used as a channel insert effect.
diff --git a/plugins/WinVST/Logical4/Logical4.h b/plugins/WinVST/Logical4/Logical4.h
index 71e118e..fd802c8 100755
--- a/plugins/WinVST/Logical4/Logical4.h
+++ b/plugins/WinVST/Logical4/Logical4.h
@@ -143,10 +143,8 @@ private:
int gcount;
- double fpNShapeLA;
- double fpNShapeLB;
- double fpNShapeRA;
- double fpNShapeRB;
+ double fpNShapeL;
+ double fpNShapeR;
bool fpFlip;
//default stuff
diff --git a/plugins/WinVST/Logical4/Logical4Proc.cpp b/plugins/WinVST/Logical4/Logical4Proc.cpp
index 0d09fcf..5d079f3 100755
--- a/plugins/WinVST/Logical4/Logical4Proc.cpp
+++ b/plugins/WinVST/Logical4/Logical4Proc.cpp
@@ -17,9 +17,8 @@ void Logical4::processReplacing(float **inputs, float **outputs, VstInt32 sample
double overallscale = 1.0;
overallscale /= 44100.0;
overallscale *= getSampleRate();
- float fpTemp;
- double fpOld = 0.618033988749894848204586; //golden ratio!
- double fpNew = 1.0 - fpOld;
+ long double fpOld = 0.618033988749894848204586; //golden ratio!
+ long double fpNew = 1.0 - fpOld;
float drySampleL;
float drySampleR;
@@ -869,27 +868,17 @@ void Logical4::processReplacing(float **inputs, float **outputs, VstInt32 sample
inputSampleL = (inputSampleL * wet) + (drySampleL * dry);
inputSampleR = (inputSampleR * wet) + (drySampleR * dry);
}
+ fpFlip = !fpFlip;
- //noise shaping to 32-bit floating point
- if (fpFlip) {
- fpTemp = inputSampleL;
- fpNShapeLA = (fpNShapeLA*fpOld)+((inputSampleL-fpTemp)*fpNew);
- inputSampleL += fpNShapeLA;
- fpTemp = inputSampleR;
- fpNShapeRA = (fpNShapeRA*fpOld)+((inputSampleR-fpTemp)*fpNew);
- inputSampleR += fpNShapeRA;
- }
- else {
- fpTemp = inputSampleL;
- fpNShapeLB = (fpNShapeLB*fpOld)+((inputSampleL-fpTemp)*fpNew);
- inputSampleL += fpNShapeLB;
- fpTemp = inputSampleR;
- fpNShapeRB = (fpNShapeRB*fpOld)+((inputSampleR-fpTemp)*fpNew);
- inputSampleR += fpNShapeRB;
- }
- fpFlip = !fpFlip;
- //end noise shaping on 32 bit output
+ //stereo 32 bit dither, made small and tidy.
+ int expon; frexpf((float)inputSampleL, &expon);
+ long double dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
+ inputSampleL += (dither-fpNShapeL); fpNShapeL = dither;
+ frexpf((float)inputSampleR, &expon);
+ dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
+ inputSampleR += (dither-fpNShapeR); fpNShapeR = dither;
+ //end 32 bit dither
*out1 = inputSampleL;
*out2 = inputSampleR;
@@ -911,9 +900,8 @@ void Logical4::processDoubleReplacing(double **inputs, double **outputs, VstInt3
double overallscale = 1.0;
overallscale /= 44100.0;
overallscale *= getSampleRate();
- double fpTemp; //this is different from singlereplacing
- double fpOld = 0.618033988749894848204586; //golden ratio!
- double fpNew = 1.0 - fpOld;
+ long double fpOld = 0.618033988749894848204586; //golden ratio!
+ long double fpNew = 1.0 - fpOld;
float drySampleL;
float drySampleR;
@@ -1762,26 +1750,18 @@ void Logical4::processDoubleReplacing(double **inputs, double **outputs, VstInt3
inputSampleL = (inputSampleL * wet) + (drySampleL * dry);
inputSampleR = (inputSampleR * wet) + (drySampleR * dry);
}
-
- //noise shaping to 64-bit floating point
- if (fpFlip) {
- fpTemp = inputSampleL;
- fpNShapeLA = (fpNShapeLA*fpOld)+((inputSampleL-fpTemp)*fpNew);
- inputSampleL += fpNShapeLA;
- fpTemp = inputSampleR;
- fpNShapeRA = (fpNShapeRA*fpOld)+((inputSampleR-fpTemp)*fpNew);
- inputSampleR += fpNShapeRA;
- }
- else {
- fpTemp = inputSampleL;
- fpNShapeLB = (fpNShapeLB*fpOld)+((inputSampleL-fpTemp)*fpNew);
- inputSampleL += fpNShapeLB;
- fpTemp = inputSampleR;
- fpNShapeRB = (fpNShapeRB*fpOld)+((inputSampleR-fpTemp)*fpNew);
- inputSampleR += fpNShapeRB;
- }
fpFlip = !fpFlip;
- //end noise shaping on 64 bit output
+
+ //stereo 64 bit dither, made small and tidy.
+ int expon; frexp((double)inputSampleL, &expon);
+ long double dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
+ dither /= 536870912.0; //needs this to scale to 64 bit zone
+ inputSampleL += (dither-fpNShapeL); fpNShapeL = dither;
+ frexp((double)inputSampleR, &expon);
+ dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
+ dither /= 536870912.0; //needs this to scale to 64 bit zone
+ inputSampleR += (dither-fpNShapeR); fpNShapeR = dither;
+ //end 64 bit dither
*out1 = inputSampleL;
*out2 = inputSampleR;