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/Point | |
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/Point')
-rwxr-xr-x | plugins/WinVST/Point/.vs/VSTProject/v14/.suo | bin | 22528 -> 22528 bytes | |||
-rwxr-xr-x | plugins/WinVST/Point/Point.cpp | 6 | ||||
-rwxr-xr-x | plugins/WinVST/Point/Point.h | 6 | ||||
-rwxr-xr-x | plugins/WinVST/Point/PointProc.cpp | 64 |
4 files changed, 24 insertions, 52 deletions
diff --git a/plugins/WinVST/Point/.vs/VSTProject/v14/.suo b/plugins/WinVST/Point/.vs/VSTProject/v14/.suo Binary files differindex 8ad608b..b4a9ec3 100755 --- a/plugins/WinVST/Point/.vs/VSTProject/v14/.suo +++ b/plugins/WinVST/Point/.vs/VSTProject/v14/.suo diff --git a/plugins/WinVST/Point/Point.cpp b/plugins/WinVST/Point/Point.cpp index 22885b5..f795470 100755 --- a/plugins/WinVST/Point/Point.cpp +++ b/plugins/WinVST/Point/Point.cpp @@ -24,10 +24,8 @@ Point::Point(audioMasterCallback audioMaster) : nibBR = 0.0; nobBR = 0.0; - fpNShapeLA = 0.0; - fpNShapeLB = 0.0; - fpNShapeRA = 0.0; - fpNShapeRB = 0.0; + fpNShapeL = 0.0; + fpNShapeR = 0.0; fpFlip = true; //this is reset: values being initialized only once. Startup values, whatever they are. diff --git a/plugins/WinVST/Point/Point.h b/plugins/WinVST/Point/Point.h index 12c8001..ff898cb 100755 --- a/plugins/WinVST/Point/Point.h +++ b/plugins/WinVST/Point/Point.h @@ -54,10 +54,8 @@ private: char _programName[kVstMaxProgNameLen + 1]; std::set< std::string > _canDo; - long double fpNShapeLA; - long double fpNShapeLB; - long double fpNShapeRA; - long double fpNShapeRB; + long double fpNShapeL; + long double fpNShapeR; bool fpFlip; //default stuff double nibAL; diff --git a/plugins/WinVST/Point/PointProc.cpp b/plugins/WinVST/Point/PointProc.cpp index a00263d..a3bbe3c 100755 --- a/plugins/WinVST/Point/PointProc.cpp +++ b/plugins/WinVST/Point/PointProc.cpp @@ -27,9 +27,6 @@ void Point::processReplacing(float **inputs, float **outputs, VstInt32 sampleFra double nibnobFactor = 0.0; //start with the fallthrough value, why not double absolute; - float fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; long double inputSampleL; long double inputSampleR; @@ -128,26 +125,16 @@ void Point::processReplacing(float **inputs, float **outputs, VstInt32 sampleFra } } inputSampleR *= nibnobFactor; - - //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; @@ -179,9 +166,6 @@ void Point::processDoubleReplacing(double **inputs, double **outputs, VstInt32 s double nibnobFactor = 0.0; //start with the fallthrough value, why not double absolute; - 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; @@ -280,26 +264,18 @@ void Point::processDoubleReplacing(double **inputs, double **outputs, VstInt32 s } } inputSampleR *= nibnobFactor; - - //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; |