From 966f2d253cd2ee6ce140ad68095a20a9d2b63052 Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Sun, 27 Jan 2019 21:13:54 -0500 Subject: Floating Point Dither For All --- plugins/WinVST/Channel6/.vs/VSTProject/v14/.suo | Bin 23040 -> 23040 bytes plugins/WinVST/Channel6/Channel6Proc.cpp | 54 ++++++++---------------- 2 files changed, 18 insertions(+), 36 deletions(-) (limited to 'plugins/WinVST/Channel6') diff --git a/plugins/WinVST/Channel6/.vs/VSTProject/v14/.suo b/plugins/WinVST/Channel6/.vs/VSTProject/v14/.suo index 521c0d0..7d5f2f1 100755 Binary files a/plugins/WinVST/Channel6/.vs/VSTProject/v14/.suo and b/plugins/WinVST/Channel6/.vs/VSTProject/v14/.suo differ diff --git a/plugins/WinVST/Channel6/Channel6Proc.cpp b/plugins/WinVST/Channel6/Channel6Proc.cpp index d206851..9f16b2a 100755 --- a/plugins/WinVST/Channel6/Channel6Proc.cpp +++ b/plugins/WinVST/Channel6/Channel6Proc.cpp @@ -121,18 +121,14 @@ void Channel6::processReplacing(float **inputs, float **outputs, VstInt32 sample inputSampleR *= output; } - //noise shaping to 32-bit floating point - float fpTemp = inputSampleL; - fpNShapeL += (inputSampleL-fpTemp); - inputSampleL += fpNShapeL; - //if this confuses you look at the wordlength for fpTemp :) - 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 *out1 = inputSampleL; *out2 = inputSampleR; @@ -142,12 +138,6 @@ void Channel6::processReplacing(float **inputs, float **outputs, VstInt32 sample *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 Channel6::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames) @@ -264,18 +254,16 @@ void Channel6::processDoubleReplacing(double **inputs, double **outputs, VstInt3 inputSampleR *= output; } - //noise shaping to 64-bit floating point - double fpTemp = inputSampleL; - fpNShapeL += (inputSampleL-fpTemp); - inputSampleL += fpNShapeL; - //if this confuses you look at the wordlength for fpTemp :) - 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 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; @@ -285,10 +273,4 @@ void Channel6::processDoubleReplacing(double **inputs, double **outputs, VstInt3 *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. } -- cgit v1.2.3