aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/WinVST/Bite
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/WinVST/Bite
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/WinVST/Bite')
-rwxr-xr-xplugins/WinVST/Bite/.vs/VSTProject/v14/.suobin23552 -> 22528 bytes
-rwxr-xr-xplugins/WinVST/Bite/Bite.cpp7
-rwxr-xr-xplugins/WinVST/Bite/Bite.h7
-rwxr-xr-xplugins/WinVST/Bite/BiteProc.cpp62
4 files changed, 22 insertions, 54 deletions
diff --git a/plugins/WinVST/Bite/.vs/VSTProject/v14/.suo b/plugins/WinVST/Bite/.vs/VSTProject/v14/.suo
index a8fee43..3113a75 100755
--- a/plugins/WinVST/Bite/.vs/VSTProject/v14/.suo
+++ b/plugins/WinVST/Bite/.vs/VSTProject/v14/.suo
Binary files differ
diff --git a/plugins/WinVST/Bite/Bite.cpp b/plugins/WinVST/Bite/Bite.cpp
index b563f54..c9d0fcb 100755
--- a/plugins/WinVST/Bite/Bite.cpp
+++ b/plugins/WinVST/Bite/Bite.cpp
@@ -34,11 +34,8 @@ Bite::Bite(audioMasterCallback audioMaster) :
sampleHR = 0.0;
sampleIR = 0.0;
- fpNShapeLA = 0.0;
- fpNShapeLB = 0.0;
- fpNShapeRA = 0.0;
- fpNShapeRB = 0.0;
- fpFlip = true;
+ fpNShapeL = 0.0;
+ fpNShapeR = 0.0;
//this is reset: values being initialized only once. Startup values, whatever they are.
_canDo.insert("plugAsChannelInsert"); // plug-in can be used as a channel insert effect.
diff --git a/plugins/WinVST/Bite/Bite.h b/plugins/WinVST/Bite/Bite.h
index d6f9e44..288ac7f 100755
--- a/plugins/WinVST/Bite/Bite.h
+++ b/plugins/WinVST/Bite/Bite.h
@@ -53,11 +53,8 @@ private:
char _programName[kVstMaxProgNameLen + 1];
std::set< std::string > _canDo;
- long double fpNShapeLA;
- long double fpNShapeLB;
- long double fpNShapeRA;
- long double fpNShapeRB;
- bool fpFlip;
+ long double fpNShapeL;
+ long double fpNShapeR;
//default stuff
double sampleAL;
double sampleBL;
diff --git a/plugins/WinVST/Bite/BiteProc.cpp b/plugins/WinVST/Bite/BiteProc.cpp
index 690a998..64e0ac4 100755
--- a/plugins/WinVST/Bite/BiteProc.cpp
+++ b/plugins/WinVST/Bite/BiteProc.cpp
@@ -17,9 +17,6 @@ void Bite::processReplacing(float **inputs, float **outputs, VstInt32 sampleFram
double overallscale = 1.3;
overallscale /= 44100.0;
overallscale *= getSampleRate();
- float fpTemp;
- long double fpOld = 0.618033988749894848204586; //golden ratio!
- long double fpNew = 1.0 - fpOld;
double gain = ((A*2.0)-1.0)*overallscale;
double outputgain = B;
@@ -119,25 +116,14 @@ void Bite::processReplacing(float **inputs, float **outputs, VstInt32 sampleFram
inputSampleR *= outputgain;
}
- //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;
@@ -159,9 +145,6 @@ void Bite::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sa
double overallscale = 1.3;
overallscale /= 44100.0;
overallscale *= getSampleRate();
- double fpTemp; //this is different from singlereplacing
- long double fpOld = 0.618033988749894848204586; //golden ratio!
- long double fpNew = 1.0 - fpOld;
double gain = ((A*2.0)-1.0)*overallscale;
double outputgain = B;
@@ -261,25 +244,16 @@ void Bite::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sa
inputSampleR *= outputgain;
}
- //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;