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/BitGlitter/BitGlitterProc.cpp | |
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/BitGlitter/BitGlitterProc.cpp')
-rwxr-xr-x | plugins/WinVST/BitGlitter/BitGlitterProc.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/plugins/WinVST/BitGlitter/BitGlitterProc.cpp b/plugins/WinVST/BitGlitter/BitGlitterProc.cpp index 321d0b6..ff2968c 100755 --- a/plugins/WinVST/BitGlitter/BitGlitterProc.cpp +++ b/plugins/WinVST/BitGlitter/BitGlitterProc.cpp @@ -202,6 +202,14 @@ void BitGlitter::processReplacing(float **inputs, float **outputs, VstInt32 samp outputSampleL = (drySampleL * (1.0-wet)) + (outputSampleL * wet); outputSampleR = (drySampleR * (1.0-wet)) + (outputSampleR * wet); } + //stereo 32 bit dither, made small and tidy. + int expon; frexpf((float)outputSampleL, &expon); + long double dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62); + outputSampleL += (dither-fpNShapeL); fpNShapeL = dither; + frexpf((float)outputSampleR, &expon); + dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62); + outputSampleR += (dither-fpNShapeR); fpNShapeR = dither; + //end 32 bit dither *out1 = outputSampleL; *out2 = outputSampleR; @@ -408,6 +416,17 @@ void BitGlitter::processDoubleReplacing(double **inputs, double **outputs, VstIn outputSampleR = (drySampleR * (1.0-wet)) + (outputSampleR * wet); } + //stereo 64 bit dither, made small and tidy. + int expon; frexp((double)outputSampleL, &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 + outputSampleL += (dither-fpNShapeL); fpNShapeL = dither; + frexp((double)outputSampleR, &expon); + dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62); + dither /= 536870912.0; //needs this to scale to 64 bit zone + outputSampleR += (dither-fpNShapeR); fpNShapeR = dither; + //end 64 bit dither + *out1 = outputSampleL; *out2 = outputSampleR; |