diff options
Diffstat (limited to 'plugins/WinVST/CStrip/CStripProc.cpp')
-rwxr-xr-x | plugins/WinVST/CStrip/CStripProc.cpp | 62 |
1 files changed, 19 insertions, 43 deletions
diff --git a/plugins/WinVST/CStrip/CStripProc.cpp b/plugins/WinVST/CStrip/CStripProc.cpp index 272b9b6..60ce59c 100755 --- a/plugins/WinVST/CStrip/CStripProc.cpp +++ b/plugins/WinVST/CStrip/CStripProc.cpp @@ -20,10 +20,8 @@ void CStrip::processReplacing(float **inputs, float **outputs, VstInt32 sampleFr overallscale = getSampleRate(); compscale = compscale * overallscale; //compscale is the one that's 1 or something like 2.2 for 96K rates - float fpTemp; long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; - + long double fpNew = 1.0 - fpOld; long double inputSampleL; long double inputSampleR; @@ -728,25 +726,14 @@ void CStrip::processReplacing(float **inputs, float **outputs, VstInt32 sampleFr 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; @@ -771,10 +758,8 @@ void CStrip::processDoubleReplacing(double **inputs, double **outputs, VstInt32 overallscale = getSampleRate(); compscale = compscale * overallscale; //compscale is the one that's 1 or something like 2.2 for 96K rates - double fpTemp; long double fpOld = 0.618033988749894848204586; //golden ratio! long double fpNew = 1.0 - fpOld; - long double inputSampleL; long double inputSampleR; @@ -1479,25 +1464,16 @@ void CStrip::processDoubleReplacing(double **inputs, double **outputs, VstInt32 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; |