aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/MacVST/Righteous4/source/Righteous4Proc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/MacVST/Righteous4/source/Righteous4Proc.cpp')
-rwxr-xr-xplugins/MacVST/Righteous4/source/Righteous4Proc.cpp56
1 files changed, 20 insertions, 36 deletions
diff --git a/plugins/MacVST/Righteous4/source/Righteous4Proc.cpp b/plugins/MacVST/Righteous4/source/Righteous4Proc.cpp
index 7ed44cf..630360f 100755
--- a/plugins/MacVST/Righteous4/source/Righteous4Proc.cpp
+++ b/plugins/MacVST/Righteous4/source/Righteous4Proc.cpp
@@ -300,17 +300,14 @@ void Righteous4::processReplacing(float **inputs, float **outputs, VstInt32 samp
//output dither section
if (bitDepth == 3) {
- //noise shaping to 32-bit floating point
- float fpTemp = inputSampleL;
- fpNShapeL += (inputSampleL-fpTemp);
- inputSampleL += fpNShapeL;
- fpTemp = inputSampleR;
- fpNShapeR += (inputSampleR-fpTemp);
- inputSampleR += fpNShapeR;
- //for deeper space and warmth, we try a non-oscillating noise shaping
- //that is kind of ruthless: it will forever retain the rounding errors
- //except we'll dial it back a hair at the end of every buffer processed
- //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
} else {
//entire Naturalize section used when not on 32 bit out
@@ -515,12 +512,6 @@ void Righteous4::processReplacing(float **inputs, float **outputs, VstInt32 samp
*out1++;
*out2++;
}
- fpNShapeL *= 0.999999;
- fpNShapeR *= 0.999999;
- //we will just delicately dial back the FP noise shaping, not even every sample
- //this is a good place to put subtle 'no runaway' calculations, though bear in mind
- //that it will be called more often when you use shorter sample buffers in the DAW.
- //So, very low latency operation will call these calculations more often.
}
void Righteous4::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames)
@@ -529,11 +520,11 @@ void Righteous4::processDoubleReplacing(double **inputs, double **outputs, VstIn
double* in2 = inputs[1];
double* out1 = outputs[0];
double* out2 = outputs[1];
- long double fpOld = 0.618033988749894848204586; //golden ratio!
- long double fpNew = 1.0 - fpOld;
double overallscale = 1.0;
overallscale /= 44100.0;
overallscale *= getSampleRate();
+ long double fpOld = 0.618033988749894848204586; //golden ratio!
+ long double fpNew = 1.0 - fpOld;
double IIRscaleback = 0.0002597;//scaleback of harmonic avg
IIRscaleback /= overallscale;
IIRscaleback = 1.0 - IIRscaleback;
@@ -816,17 +807,16 @@ void Righteous4::processDoubleReplacing(double **inputs, double **outputs, VstIn
//output dither section
if (bitDepth == 3) {
- //noise shaping to 32-bit floating point
- double fpTemp = inputSampleL;
- fpNShapeL += (inputSampleL-fpTemp);
- inputSampleL += fpNShapeL;
- fpTemp = inputSampleR;
- fpNShapeR += (inputSampleR-fpTemp);
- inputSampleR += fpNShapeR;
- //for deeper space and warmth, we try a non-oscillating noise shaping
- //that is kind of ruthless: it will forever retain the rounding errors
- //except we'll dial it back a hair at the end of every buffer processed
- //end noise shaping on 32 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
} else {
//entire Naturalize section used when not on 32 bit out
@@ -1031,10 +1021,4 @@ void Righteous4::processDoubleReplacing(double **inputs, double **outputs, VstIn
*out1++;
*out2++;
}
- fpNShapeL *= 0.999999;
- fpNShapeR *= 0.999999;
- //we will just delicately dial back the FP noise shaping, not even every sample
- //this is a good place to put subtle 'no runaway' calculations, though bear in mind
- //that it will be called more often when you use shorter sample buffers in the DAW.
- //So, very low latency operation will call these calculations more often.
} \ No newline at end of file