From 966f2d253cd2ee6ce140ad68095a20a9d2b63052 Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Sun, 27 Jan 2019 21:13:54 -0500 Subject: Floating Point Dither For All --- plugins/WinVST/Pressure4/.vs/VSTProject/v14/.suo | Bin 23040 -> 22528 bytes plugins/WinVST/Pressure4/Pressure4.cpp | 6 +-- plugins/WinVST/Pressure4/Pressure4.h | 6 +-- plugins/WinVST/Pressure4/Pressure4Proc.cpp | 66 +++++++---------------- 4 files changed, 22 insertions(+), 56 deletions(-) (limited to 'plugins/WinVST/Pressure4') diff --git a/plugins/WinVST/Pressure4/.vs/VSTProject/v14/.suo b/plugins/WinVST/Pressure4/.vs/VSTProject/v14/.suo index a911044..b3e9f08 100755 Binary files a/plugins/WinVST/Pressure4/.vs/VSTProject/v14/.suo and b/plugins/WinVST/Pressure4/.vs/VSTProject/v14/.suo differ diff --git a/plugins/WinVST/Pressure4/Pressure4.cpp b/plugins/WinVST/Pressure4/Pressure4.cpp index 8ae2adc..10ed5fa 100755 --- a/plugins/WinVST/Pressure4/Pressure4.cpp +++ b/plugins/WinVST/Pressure4/Pressure4.cpp @@ -16,10 +16,8 @@ Pressure4::Pressure4(audioMasterCallback audioMaster) : B = 0.2; C = 1.0; D = 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/Pressure4/Pressure4.h b/plugins/WinVST/Pressure4/Pressure4.h index 29d20eb..6cf3448 100755 --- a/plugins/WinVST/Pressure4/Pressure4.h +++ b/plugins/WinVST/Pressure4/Pressure4.h @@ -62,10 +62,8 @@ private: double muSpeedB; double muCoefficientA; double muCoefficientB; - 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/Pressure4/Pressure4Proc.cpp b/plugins/WinVST/Pressure4/Pressure4Proc.cpp index 02b8a78..7e285df 100755 --- a/plugins/WinVST/Pressure4/Pressure4Proc.cpp +++ b/plugins/WinVST/Pressure4/Pressure4Proc.cpp @@ -43,9 +43,6 @@ void Pressure4::processReplacing(float **inputs, float **outputs, VstInt32 sampl unmewiness = 1.0-mewiness; } // µ µ µ µ µ µ µ µ µ µ µ µ is the kitten song o/~ - float fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; long double inputSampleL; long double inputSampleR; @@ -195,27 +192,14 @@ void Pressure4::processReplacing(float **inputs, float **outputs, VstInt32 sampl else {inputSampleR = -bridgerectifier;} //second stage of overdrive to prevent overs and allow bloody loud extremeness - //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 *outputL = inputSampleL; *outputR = inputSampleR; @@ -263,9 +247,6 @@ void Pressure4::processDoubleReplacing(double **inputs, double **outputs, VstInt unmewiness = 1.0-mewiness; } // µ µ µ µ µ µ µ µ µ µ µ µ is the kitten song o/~ - 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; @@ -416,27 +397,16 @@ void Pressure4::processDoubleReplacing(double **inputs, double **outputs, VstInt else {inputSampleR = -bridgerectifier;} //second stage of overdrive to prevent overs and allow bloody loud extremeness - //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 *outputL = inputSampleL; *outputR = inputSampleR; -- cgit v1.2.3