diff options
author | Chris Johnson <jinx6568@sover.net> | 2019-01-27 21:13:54 -0500 |
---|---|---|
committer | Chris Johnson <jinx6568@sover.net> | 2019-01-27 21:13:54 -0500 |
commit | 966f2d253cd2ee6ce140ad68095a20a9d2b63052 (patch) | |
tree | b0400d95bd06512531ade6ddf55190a58b6a5623 /plugins/MacAU/CStrip/CStrip.cpp | |
parent | 0887543349dbbec0721a1fc8b1c7deba9afefa8b (diff) | |
download | airwindows-lv2-port-966f2d253cd2ee6ce140ad68095a20a9d2b63052.tar.gz airwindows-lv2-port-966f2d253cd2ee6ce140ad68095a20a9d2b63052.tar.bz2 airwindows-lv2-port-966f2d253cd2ee6ce140ad68095a20a9d2b63052.zip |
Floating Point Dither For All
Diffstat (limited to 'plugins/MacAU/CStrip/CStrip.cpp')
-rwxr-xr-x | plugins/MacAU/CStrip/CStrip.cpp | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/plugins/MacAU/CStrip/CStrip.cpp b/plugins/MacAU/CStrip/CStrip.cpp index 78b3c31..494d6b5 100755 --- a/plugins/MacAU/CStrip/CStrip.cpp +++ b/plugins/MacAU/CStrip/CStrip.cpp @@ -257,9 +257,7 @@ ComponentResult CStrip::Initialize() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void CStrip::CStripKernel::Reset() { - fpNShapeA = 0.0; - fpNShapeB = 0.0; - fpFlip = true; + fpNShape = 0.0; lastSample = 0.0; last2Sample = 0.0; @@ -347,9 +345,8 @@ void CStrip::CStripKernel::Process( const Float32 *inSourceP, overallscale = GetSampleRate(); compscale = compscale * overallscale; //compscale is the one that's 1 or something like 2.2 for 96K rates - Float32 fpTemp; - Float64 fpOld = 0.618033988749894848204586; //golden ratio! - Float64 fpNew = 1.0 - fpOld; + long double fpOld = 0.618033988749894848204586; //golden ratio! + long double fpNew = 1.0 - fpOld; Float64 inputSample; Float64 highSample = 0.0; @@ -767,19 +764,11 @@ void CStrip::CStripKernel::Process( const Float32 *inSourceP, //built in output trim and dry/wet if desired if (outputgain != 1.0) inputSample *= outputgain; - //noise shaping to 32-bit floating point - if (fpFlip) { - fpTemp = inputSample; - fpNShapeA = (fpNShapeA*fpOld)+((inputSample-fpTemp)*fpNew); - inputSample += fpNShapeA; - } - else { - fpTemp = inputSample; - fpNShapeB = (fpNShapeB*fpOld)+((inputSample-fpTemp)*fpNew); - inputSample += fpNShapeB; - } - fpFlip = not fpFlip; - //end noise shaping on 32 bit output + //32 bit dither, made small and tidy. + int expon; frexpf((Float32)inputSample, &expon); + long double dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62); + inputSample += (dither-fpNShape); fpNShape = dither; + //end 32 bit dither *destP = inputSample; |