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/Thunder | |
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/Thunder')
-rwxr-xr-x | plugins/WinVST/Thunder/.vs/VSTProject/v14/.suo | bin | 22528 -> 22528 bytes | |||
-rwxr-xr-x | plugins/WinVST/Thunder/Thunder.cpp | 6 | ||||
-rwxr-xr-x | plugins/WinVST/Thunder/Thunder.h | 6 | ||||
-rwxr-xr-x | plugins/WinVST/Thunder/ThunderProc.cpp | 66 |
4 files changed, 22 insertions, 56 deletions
diff --git a/plugins/WinVST/Thunder/.vs/VSTProject/v14/.suo b/plugins/WinVST/Thunder/.vs/VSTProject/v14/.suo Binary files differindex b01488d..a6a6a16 100755 --- a/plugins/WinVST/Thunder/.vs/VSTProject/v14/.suo +++ b/plugins/WinVST/Thunder/.vs/VSTProject/v14/.suo diff --git a/plugins/WinVST/Thunder/Thunder.cpp b/plugins/WinVST/Thunder/Thunder.cpp index 015eabd..7bc8226 100755 --- a/plugins/WinVST/Thunder/Thunder.cpp +++ b/plugins/WinVST/Thunder/Thunder.cpp @@ -15,10 +15,8 @@ Thunder::Thunder(audioMasterCallback audioMaster) : A = 0.0; B = 1.0; - fpNShapeAL = 0.0; - fpNShapeBL = 0.0; - fpNShapeAR = 0.0; - fpNShapeBR = 0.0; + fpNShapeL = 0.0; + fpNShapeR = 0.0; muSpeedA = 10000; muSpeedB = 10000; muCoefficientA = 1; diff --git a/plugins/WinVST/Thunder/Thunder.h b/plugins/WinVST/Thunder/Thunder.h index 1ef1d03..9e49054 100755 --- a/plugins/WinVST/Thunder/Thunder.h +++ b/plugins/WinVST/Thunder/Thunder.h @@ -69,10 +69,8 @@ private: double iirSampleAM; double iirSampleBM; double iirSampleCM; - long double fpNShapeAL; - long double fpNShapeBL; - long double fpNShapeAR; - long double fpNShapeBR; + long double fpNShapeL; + long double fpNShapeR; bool flip; float A; diff --git a/plugins/WinVST/Thunder/ThunderProc.cpp b/plugins/WinVST/Thunder/ThunderProc.cpp index bd401d4..2cf454d 100755 --- a/plugins/WinVST/Thunder/ThunderProc.cpp +++ b/plugins/WinVST/Thunder/ThunderProc.cpp @@ -40,9 +40,6 @@ void Thunder::processReplacing(float **inputs, float **outputs, VstInt32 sampleF double resultML; double resultMR; - float fpTemp; - double fpOld = 0.618033988749894848204586; //golden ratio! - double fpNew = 1.0 - fpOld; long double inputSampleL; long double inputSampleR; @@ -225,27 +222,14 @@ void Thunder::processReplacing(float **inputs, float **outputs, VstInt32 sampleF inputSampleR *= outputGain; } - //noise shaping to 32-bit floating point - if (flip) { - fpTemp = inputSampleL; - fpNShapeAL = (fpNShapeAL*fpOld)+((inputSampleL-fpTemp)*fpNew); - inputSampleL += fpNShapeAL; - - fpTemp = inputSampleR; - fpNShapeAR = (fpNShapeAR*fpOld)+((inputSampleR-fpTemp)*fpNew); - inputSampleR += fpNShapeAR; - } - else { - fpTemp = inputSampleL; - fpNShapeBL = (fpNShapeBL*fpOld)+((inputSampleL-fpTemp)*fpNew); - inputSampleL += fpNShapeBL; - - fpTemp = inputSampleR; - fpNShapeBR = (fpNShapeBR*fpOld)+((inputSampleR-fpTemp)*fpNew); - inputSampleR += fpNShapeBR; - } - flip = !flip; - //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; @@ -291,9 +275,6 @@ void Thunder::processDoubleReplacing(double **inputs, double **outputs, VstInt32 double resultML; double resultMR; - double fpTemp; - double fpOld = 0.618033988749894848204586; //golden ratio! - double fpNew = 1.0 - fpOld; long double inputSampleL; long double inputSampleR; @@ -476,27 +457,16 @@ void Thunder::processDoubleReplacing(double **inputs, double **outputs, VstInt32 inputSampleR *= outputGain; } - //noise shaping to 32-bit floating point - if (flip) { - fpTemp = inputSampleL; - fpNShapeAL = (fpNShapeAL*fpOld)+((inputSampleL-fpTemp)*fpNew); - inputSampleL += fpNShapeAL; - - fpTemp = inputSampleR; - fpNShapeAR = (fpNShapeAR*fpOld)+((inputSampleR-fpTemp)*fpNew); - inputSampleR += fpNShapeAR; - } - else { - fpTemp = inputSampleL; - fpNShapeBL = (fpNShapeBL*fpOld)+((inputSampleL-fpTemp)*fpNew); - inputSampleL += fpNShapeBL; - - fpTemp = inputSampleR; - fpNShapeBR = (fpNShapeBR*fpOld)+((inputSampleR-fpTemp)*fpNew); - inputSampleR += fpNShapeBR; - } - flip = !flip; - //end noise shaping on 32 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; |