diff options
Diffstat (limited to 'plugins/WinVST/EdIsDim/EdIsDimProc.cpp')
-rwxr-xr-x | plugins/WinVST/EdIsDim/EdIsDimProc.cpp | 62 |
1 files changed, 18 insertions, 44 deletions
diff --git a/plugins/WinVST/EdIsDim/EdIsDimProc.cpp b/plugins/WinVST/EdIsDim/EdIsDimProc.cpp index 8ee927d..0d033eb 100755 --- a/plugins/WinVST/EdIsDim/EdIsDimProc.cpp +++ b/plugins/WinVST/EdIsDim/EdIsDimProc.cpp @@ -14,9 +14,6 @@ void EdIsDim::processReplacing(float **inputs, float **outputs, VstInt32 sampleF float* out1 = outputs[0]; float* out2 = outputs[1]; - float fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; long double inputSampleL; long double inputSampleR; @@ -75,25 +72,14 @@ void EdIsDim::processReplacing(float **inputs, float **outputs, VstInt32 sampleF mid = (inputSampleL+inputSampleR)/2.0; side = (inputSampleL-inputSampleR)/2.0; - //noise shaping to 32-bit floating point - if (fpFlip) { - fpTemp = mid; - fpNShapeLA = (fpNShapeLA*fpOld)+((mid-fpTemp)*fpNew); - mid += fpNShapeLA; - fpTemp = side; - fpNShapeRA = (fpNShapeRA*fpOld)+((side-fpTemp)*fpNew); - side += fpNShapeRA; - } - else { - fpTemp = mid; - fpNShapeLB = (fpNShapeLB*fpOld)+((mid-fpTemp)*fpNew); - mid += fpNShapeLB; - fpTemp = side; - fpNShapeRB = (fpNShapeRB*fpOld)+((side-fpTemp)*fpNew); - side += fpNShapeRB; - } - fpFlip = !fpFlip; - //end noise shaping on 32 bit output + //stereo 32 bit dither, made small and tidy. + int expon; frexpf((float)mid, &expon); + long double dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62); + mid += (dither-fpNShapeL); fpNShapeL = dither; + frexpf((float)side, &expon); + dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62); + side += (dither-fpNShapeR); fpNShapeR = dither; + //end 32 bit dither *out1 = mid; *out2 = side; @@ -112,9 +98,6 @@ void EdIsDim::processDoubleReplacing(double **inputs, double **outputs, VstInt32 double* out1 = outputs[0]; double* out2 = outputs[1]; - 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; @@ -174,25 +157,16 @@ void EdIsDim::processDoubleReplacing(double **inputs, double **outputs, VstInt32 mid = (inputSampleL+inputSampleR)/2.0; side = (inputSampleL-inputSampleR)/2.0; - //noise shaping to 64-bit floating point - if (fpFlip) { - fpTemp = mid; - fpNShapeLA = (fpNShapeLA*fpOld)+((mid-fpTemp)*fpNew); - mid += fpNShapeLA; - fpTemp = side; - fpNShapeRA = (fpNShapeRA*fpOld)+((side-fpTemp)*fpNew); - side += fpNShapeRA; - } - else { - fpTemp = mid; - fpNShapeLB = (fpNShapeLB*fpOld)+((mid-fpTemp)*fpNew); - mid += fpNShapeLB; - fpTemp = side; - fpNShapeRB = (fpNShapeRB*fpOld)+((side-fpTemp)*fpNew); - side += fpNShapeRB; - } - fpFlip = !fpFlip; - //end noise shaping on 64 bit output + //stereo 64 bit dither, made small and tidy. + int expon; frexp((double)mid, &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 + mid += (dither-fpNShapeL); fpNShapeL = dither; + frexp((double)side, &expon); + dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62); + dither /= 536870912.0; //needs this to scale to 64 bit zone + side += (dither-fpNShapeR); fpNShapeR = dither; + //end 64 bit dither *out1 = mid; *out2 = side; |