diff options
author | Chris Johnson <jinx6568@sover.net> | 2019-01-27 21:13:54 -0500 |
---|---|---|
committer | Chris Johnson <jinx6568@sover.net> | 2019-01-27 21:13:54 -0500 |
commit | 966f2d253cd2ee6ce140ad68095a20a9d2b63052 (patch) | |
tree | b0400d95bd06512531ade6ddf55190a58b6a5623 /plugins/WinVST/BussColors4 | |
parent | 0887543349dbbec0721a1fc8b1c7deba9afefa8b (diff) | |
download | airwindows-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/BussColors4')
-rwxr-xr-x | plugins/WinVST/BussColors4/.vs/VSTProject/v14/.suo | bin | 23040 -> 23040 bytes | |||
-rwxr-xr-x | plugins/WinVST/BussColors4/BussColors4.cpp | 22 | ||||
-rwxr-xr-x | plugins/WinVST/BussColors4/BussColors4.h | 7 | ||||
-rwxr-xr-x | plugins/WinVST/BussColors4/BussColors4Proc.cpp | 62 |
4 files changed, 22 insertions, 69 deletions
diff --git a/plugins/WinVST/BussColors4/.vs/VSTProject/v14/.suo b/plugins/WinVST/BussColors4/.vs/VSTProject/v14/.suo Binary files differindex 8ad21ec..d45891a 100755 --- a/plugins/WinVST/BussColors4/.vs/VSTProject/v14/.suo +++ b/plugins/WinVST/BussColors4/.vs/VSTProject/v14/.suo diff --git a/plugins/WinVST/BussColors4/BussColors4.cpp b/plugins/WinVST/BussColors4/BussColors4.cpp index 720dbf9..c7de380 100755 --- a/plugins/WinVST/BussColors4/BussColors4.cpp +++ b/plugins/WinVST/BussColors4/BussColors4.cpp @@ -44,11 +44,8 @@ BussColors4::BussColors4(audioMasterCallback audioMaster) : slowdynR = 0; gcount = 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. @@ -114,21 +111,6 @@ void BussColors4::setParameter(VstInt32 index, float value) { case kParamD: D = value; break; //this is the popup, stored as a float default: throw; // unknown parameter, shouldn't happen! } - //we can also set other defaults here, and do calculations that only have to happen - //once when parameters actually change. Here is the 'popup' setting its (global) values. - //variables can also be set in the processreplacing loop, and there they'll be set every buffersize - //here they're set when a parameter's actually changed, which should be less frequent, but - //you must use global variables in the BussColors4.h file to do it. - switch((VstInt32)( D * 3.999 )) - { - case 0: fpFlip = true; break; //choice A - case 1: fpFlip = false; break; //choice B - case 2: break; //choice C - case 3: break; //choice D - default: break; //should not happen - } - //this relates to using D as a 'popup' and changing things based on that switch. - //we are using fpFlip just because it's already there globally, as an example. } float BussColors4::getParameter(VstInt32 index) { diff --git a/plugins/WinVST/BussColors4/BussColors4.h b/plugins/WinVST/BussColors4/BussColors4.h index d07460e..6452555 100755 --- a/plugins/WinVST/BussColors4/BussColors4.h +++ b/plugins/WinVST/BussColors4/BussColors4.h @@ -68,11 +68,8 @@ private: double slowdynR; int gcount; - long double fpNShapeLA; - long double fpNShapeLB; - long double fpNShapeRA; - long double fpNShapeRB; - bool fpFlip; + long double fpNShapeL; + long double fpNShapeR; //default stuff float A; diff --git a/plugins/WinVST/BussColors4/BussColors4Proc.cpp b/plugins/WinVST/BussColors4/BussColors4Proc.cpp index 2629ee8..b1b9451 100755 --- a/plugins/WinVST/BussColors4/BussColors4Proc.cpp +++ b/plugins/WinVST/BussColors4/BussColors4Proc.cpp @@ -31,9 +31,6 @@ void BussColors4::processReplacing(float **inputs, float **outputs, VstInt32 sam double gain = 0.436; double outgain = 1.0; double bridgerectifier; - float fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; long double inputSampleL; long double inputSampleR; @@ -795,25 +792,14 @@ void BussColors4::processReplacing(float **inputs, float **outputs, VstInt32 sam 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; @@ -849,9 +835,6 @@ void BussColors4::processDoubleReplacing(double **inputs, double **outputs, VstI double gain = 0.436; double outgain = 1.0; double bridgerectifier; - double fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; long double inputSampleL; long double inputSampleR; @@ -1613,25 +1596,16 @@ void BussColors4::processDoubleReplacing(double **inputs, double **outputs, VstI 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; |