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/Swell | |
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/Swell')
-rwxr-xr-x | plugins/WinVST/Swell/.vs/VSTProject/v14/.suo | bin | 24576 -> 22528 bytes | |||
-rwxr-xr-x | plugins/WinVST/Swell/Swell.cpp | 7 | ||||
-rwxr-xr-x | plugins/WinVST/Swell/Swell.h | 7 | ||||
-rwxr-xr-x | plugins/WinVST/Swell/SwellProc.cpp | 62 |
4 files changed, 22 insertions, 54 deletions
diff --git a/plugins/WinVST/Swell/.vs/VSTProject/v14/.suo b/plugins/WinVST/Swell/.vs/VSTProject/v14/.suo Binary files differindex f1f16de..3124884 100755 --- a/plugins/WinVST/Swell/.vs/VSTProject/v14/.suo +++ b/plugins/WinVST/Swell/.vs/VSTProject/v14/.suo diff --git a/plugins/WinVST/Swell/Swell.cpp b/plugins/WinVST/Swell/Swell.cpp index 30518d8..e197cfb 100755 --- a/plugins/WinVST/Swell/Swell.cpp +++ b/plugins/WinVST/Swell/Swell.cpp @@ -21,11 +21,8 @@ Swell::Swell(audioMasterCallback audioMaster) : louderL = false; louderR = false; - 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/Swell/Swell.h b/plugins/WinVST/Swell/Swell.h index c383df2..7c108b7 100755 --- a/plugins/WinVST/Swell/Swell.h +++ b/plugins/WinVST/Swell/Swell.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 diff --git a/plugins/WinVST/Swell/SwellProc.cpp b/plugins/WinVST/Swell/SwellProc.cpp index 28c0aba..3ab1e9b 100755 --- a/plugins/WinVST/Swell/SwellProc.cpp +++ b/plugins/WinVST/Swell/SwellProc.cpp @@ -17,9 +17,6 @@ void Swell::processReplacing(float **inputs, float **outputs, VstInt32 sampleFra double overallscale = 1.0; overallscale /= 44100.0; overallscale *= getSampleRate(); - float fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; double thresholdOn = pow(A,2) * B; double speedOn = (pow(B,2)*0.001)/overallscale; @@ -97,25 +94,14 @@ void Swell::processReplacing(float **inputs, float **outputs, VstInt32 sampleFra 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; @@ -137,9 +123,6 @@ void Swell::processDoubleReplacing(double **inputs, double **outputs, VstInt32 s double overallscale = 1.0; overallscale /= 44100.0; overallscale *= getSampleRate(); - double fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; double thresholdOn = pow(A,2) * B; double speedOn = (pow(B,2)*0.001)/overallscale; @@ -217,25 +200,16 @@ void Swell::processDoubleReplacing(double **inputs, double **outputs, VstInt32 s 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; |