aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/WinVST/Chorus
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/Chorus
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/Chorus')
-rwxr-xr-xplugins/WinVST/Chorus/.vs/VSTProject/v14/.suobin22528 -> 22528 bytes
-rwxr-xr-xplugins/WinVST/Chorus/Chorus.cpp7
-rwxr-xr-xplugins/WinVST/Chorus/Chorus.h8
-rwxr-xr-xplugins/WinVST/Chorus/ChorusProc.cpp62
4 files changed, 24 insertions, 53 deletions
diff --git a/plugins/WinVST/Chorus/.vs/VSTProject/v14/.suo b/plugins/WinVST/Chorus/.vs/VSTProject/v14/.suo
index 6891b3b..113c667 100755
--- a/plugins/WinVST/Chorus/.vs/VSTProject/v14/.suo
+++ b/plugins/WinVST/Chorus/.vs/VSTProject/v14/.suo
Binary files differ
diff --git a/plugins/WinVST/Chorus/Chorus.cpp b/plugins/WinVST/Chorus/Chorus.cpp
index a0699ec..1f3965a 100755
--- a/plugins/WinVST/Chorus/Chorus.cpp
+++ b/plugins/WinVST/Chorus/Chorus.cpp
@@ -27,12 +27,9 @@ Chorus::Chorus(audioMasterCallback audioMaster) :
airEvenR = 0.0;
airOddR = 0.0;
airFactorR = 0.0;
-
- 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/Chorus/Chorus.h b/plugins/WinVST/Chorus/Chorus.h
index fb2fb44..5508ac3 100755
--- a/plugins/WinVST/Chorus/Chorus.h
+++ b/plugins/WinVST/Chorus/Chorus.h
@@ -54,11 +54,8 @@ private:
char _programName[kVstMaxProgNameLen + 1];
std::set< std::string > _canDo;
- long double fpNShapeLA;
- long double fpNShapeLB;
- long double fpNShapeRA;
- long double fpNShapeRB;
- bool fpFlip;
+ long double fpNShapeL;
+ long double fpNShapeR;
//default stuff
const static int totalsamples = 16386;
float dL[totalsamples];
@@ -73,6 +70,7 @@ private:
double airEvenR;
double airOddR;
double airFactorR;
+ bool fpFlip;
float A;
float B;
diff --git a/plugins/WinVST/Chorus/ChorusProc.cpp b/plugins/WinVST/Chorus/ChorusProc.cpp
index aed2bc0..368ade7 100755
--- a/plugins/WinVST/Chorus/ChorusProc.cpp
+++ b/plugins/WinVST/Chorus/ChorusProc.cpp
@@ -30,9 +30,6 @@ void Chorus::processReplacing(float **inputs, float **outputs, VstInt32 sampleFr
double offset;
//this is a double buffer so we will be splitting it in two
- float fpTemp;
- long double fpOld = 0.618033988749894848204586; //golden ratio!
- long double fpNew = 1.0 - fpOld;
long double inputSampleL;
long double inputSampleR;
@@ -134,26 +131,16 @@ void Chorus::processReplacing(float **inputs, float **outputs, VstInt32 sampleFr
inputSampleL = (inputSampleL * wet) + (drySampleL * dry);
inputSampleR = (inputSampleR * wet) + (drySampleR * dry);
}
-
- //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;
@@ -188,9 +175,6 @@ void Chorus::processDoubleReplacing(double **inputs, double **outputs, VstInt32
double offset;
//this is a double buffer so we will be splitting it in two
- double fpTemp; //this is different from singlereplacing
- long double fpOld = 0.618033988749894848204586; //golden ratio!
- long double fpNew = 1.0 - fpOld;
long double inputSampleL;
long double inputSampleR;
@@ -293,25 +277,17 @@ void Chorus::processDoubleReplacing(double **inputs, double **outputs, VstInt32
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;
- }
+ //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
fpFlip = !fpFlip;
- //end noise shaping on 64 bit output
*out1 = inputSampleL;
*out2 = inputSampleR;