aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/WinVST/EveryTrim/EveryTrimProc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/WinVST/EveryTrim/EveryTrimProc.cpp')
-rwxr-xr-xplugins/WinVST/EveryTrim/EveryTrimProc.cpp62
1 files changed, 18 insertions, 44 deletions
diff --git a/plugins/WinVST/EveryTrim/EveryTrimProc.cpp b/plugins/WinVST/EveryTrim/EveryTrimProc.cpp
index 30d764f..3c30eda 100755
--- a/plugins/WinVST/EveryTrim/EveryTrimProc.cpp
+++ b/plugins/WinVST/EveryTrim/EveryTrimProc.cpp
@@ -14,9 +14,6 @@ void EveryTrim::processReplacing(float **inputs, float **outputs, VstInt32 sampl
float* out1 = outputs[0];
float* out2 = outputs[1];
- float fpTemp;
- long double fpOld = 0.618033988749894848204586; //golden ratio!
- long double fpNew = 1.0 - fpOld;
double leftgain = pow(10.0,((A*24.0)-12.0)/20.0);
double rightgain = pow(10.0,((B*24.0)-12.0)/20.0);
@@ -83,25 +80,14 @@ void EveryTrim::processReplacing(float **inputs, float **outputs, VstInt32 sampl
inputSampleR = (mid-side) * rightgain;
//contains mastergain and the gain trim fixing the mid/side
- //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;
@@ -120,9 +106,6 @@ void EveryTrim::processDoubleReplacing(double **inputs, double **outputs, VstInt
double* out1 = outputs[0];
double* out2 = outputs[1];
- double fpTemp;
- long double fpOld = 0.618033988749894848204586; //golden ratio!
- long double fpNew = 1.0 - fpOld;
double leftgain = pow(10.0,((A*24.0)-12.0)/20.0);
double rightgain = pow(10.0,((B*24.0)-12.0)/20.0);
@@ -189,25 +172,16 @@ void EveryTrim::processDoubleReplacing(double **inputs, double **outputs, VstInt
inputSampleR = (mid-side) * rightgain;
//contains mastergain and the gain trim fixing the mid/side
- //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;