aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/WinVST/Melt
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/Melt
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/Melt')
-rwxr-xr-xplugins/WinVST/Melt/.vs/VSTProject/v14/.suobin22528 -> 22528 bytes
-rwxr-xr-xplugins/WinVST/Melt/Melt.cpp7
-rwxr-xr-xplugins/WinVST/Melt/Melt.h7
-rwxr-xr-xplugins/WinVST/Melt/MeltProc.cpp62
4 files changed, 22 insertions, 54 deletions
diff --git a/plugins/WinVST/Melt/.vs/VSTProject/v14/.suo b/plugins/WinVST/Melt/.vs/VSTProject/v14/.suo
index ee90f48..e2993f2 100755
--- a/plugins/WinVST/Melt/.vs/VSTProject/v14/.suo
+++ b/plugins/WinVST/Melt/.vs/VSTProject/v14/.suo
Binary files differ
diff --git a/plugins/WinVST/Melt/Melt.cpp b/plugins/WinVST/Melt/Melt.cpp
index 9722e1f..35ede1e 100755
--- a/plugins/WinVST/Melt/Melt.cpp
+++ b/plugins/WinVST/Melt/Melt.cpp
@@ -26,11 +26,8 @@ Melt::Melt(audioMasterCallback audioMaster) :
slowCount = 0;
gcount = 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/Melt/Melt.h b/plugins/WinVST/Melt/Melt.h
index a8e0f38..af11f0f 100755
--- a/plugins/WinVST/Melt/Melt.h
+++ b/plugins/WinVST/Melt/Melt.h
@@ -70,11 +70,8 @@ private:
int slowCount;
int gcount;
- long double fpNShapeLA;
- long double fpNShapeLB;
- long double fpNShapeRA;
- long double fpNShapeRB;
- bool fpFlip;
+ long double fpNShapeL;
+ long double fpNShapeR;
//default stuff
float A;
diff --git a/plugins/WinVST/Melt/MeltProc.cpp b/plugins/WinVST/Melt/MeltProc.cpp
index 48a1c11..8a55732 100755
--- a/plugins/WinVST/Melt/MeltProc.cpp
+++ b/plugins/WinVST/Melt/MeltProc.cpp
@@ -21,9 +21,6 @@ void Melt::processReplacing(float **inputs, float **outputs, VstInt32 sampleFram
double wet = D;
double dry = 1.0-wet;
- float fpTemp;
- long double fpOld = 0.618033988749894848204586; //golden ratio!
- long double fpNew = 1.0 - fpOld;
long double inputSampleL;
long double inputSampleR;
@@ -271,25 +268,14 @@ void Melt::processReplacing(float **inputs, float **outputs, VstInt32 sampleFram
//nice little output stage template: if we have another scale of floating point
//number, we really don't want to meaninglessly multiply that by 1.0.
- //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;
@@ -315,9 +301,6 @@ void Melt::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sa
double wet = D;
double dry = 1.0-wet;
- 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;
@@ -565,25 +548,16 @@ void Melt::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sa
//nice little output stage template: if we have another scale of floating point
//number, we really don't want to meaninglessly multiply that by 1.0.
- //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;