aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/MacVST/BitGlitter/source
diff options
context:
space:
mode:
authorChris Johnson <jinx6568@sover.net>2019-01-27 21:13:54 -0500
committerChris Johnson <jinx6568@sover.net>2019-01-27 21:13:54 -0500
commit966f2d253cd2ee6ce140ad68095a20a9d2b63052 (patch)
treeb0400d95bd06512531ade6ddf55190a58b6a5623 /plugins/MacVST/BitGlitter/source
parent0887543349dbbec0721a1fc8b1c7deba9afefa8b (diff)
downloadairwindows-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/MacVST/BitGlitter/source')
-rwxr-xr-xplugins/MacVST/BitGlitter/source/BitGlitter.cpp3
-rwxr-xr-xplugins/MacVST/BitGlitter/source/BitGlitter.h3
-rwxr-xr-xplugins/MacVST/BitGlitter/source/BitGlitterProc.cpp19
3 files changed, 25 insertions, 0 deletions
diff --git a/plugins/MacVST/BitGlitter/source/BitGlitter.cpp b/plugins/MacVST/BitGlitter/source/BitGlitter.cpp
index 7e9cfdb..a1e1a9b 100755
--- a/plugins/MacVST/BitGlitter/source/BitGlitter.cpp
+++ b/plugins/MacVST/BitGlitter/source/BitGlitter.cpp
@@ -17,6 +17,9 @@ BitGlitter::BitGlitter(audioMasterCallback audioMaster) :
C = 0.5;
D = 1.0;
+ fpNShapeL = 0.0;
+ fpNShapeR = 0.0;
+
ataLastSampleL = 0.0;
ataHalfwaySampleL = 0.0;
lastSampleL = 0.0;
diff --git a/plugins/MacVST/BitGlitter/source/BitGlitter.h b/plugins/MacVST/BitGlitter/source/BitGlitter.h
index d87e277..4f108cd 100755
--- a/plugins/MacVST/BitGlitter/source/BitGlitter.h
+++ b/plugins/MacVST/BitGlitter/source/BitGlitter.h
@@ -55,6 +55,9 @@ private:
char _programName[kVstMaxProgNameLen + 1];
std::set< std::string > _canDo;
+ long double fpNShapeL;
+ long double fpNShapeR;
+
double ataLastSampleL;
double ataHalfwaySampleL;
double ataDrySampleL;
diff --git a/plugins/MacVST/BitGlitter/source/BitGlitterProc.cpp b/plugins/MacVST/BitGlitter/source/BitGlitterProc.cpp
index 321d0b6..ff2968c 100755
--- a/plugins/MacVST/BitGlitter/source/BitGlitterProc.cpp
+++ b/plugins/MacVST/BitGlitter/source/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;