aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/MacAU/Slew/Slew.cpp
diff options
context:
space:
mode:
authorChris Johnson <jinx6568@sover.net>2019-01-27 21:13:54 -0500
committerChris Johnson <jinx6568@sover.net>2019-01-27 21:13:54 -0500
commit966f2d253cd2ee6ce140ad68095a20a9d2b63052 (patch)
treeb0400d95bd06512531ade6ddf55190a58b6a5623 /plugins/MacAU/Slew/Slew.cpp
parent0887543349dbbec0721a1fc8b1c7deba9afefa8b (diff)
downloadairwindows-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/Slew/Slew.cpp')
-rwxr-xr-xplugins/MacAU/Slew/Slew.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/plugins/MacAU/Slew/Slew.cpp b/plugins/MacAU/Slew/Slew.cpp
index 3c1a7bf..5eee0ab 100755
--- a/plugins/MacAU/Slew/Slew.cpp
+++ b/plugins/MacAU/Slew/Slew.cpp
@@ -159,6 +159,7 @@ ComponentResult Slew::Initialize()
void Slew::SlewKernel::Reset()
{
lastSample = 0.0;
+ fpNShape = 0.0;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -224,6 +225,12 @@ void Slew::SlewKernel::Process( const Float32 *inSourceP,
outputSample = lastSample - threshold;
lastSample = outputSample;
+ //32 bit dither, made small and tidy.
+ int expon; frexpf((Float32)outputSample, &expon);
+ long double dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62);
+ outputSample += (dither-fpNShape); fpNShape = dither;
+ //end 32 bit dither
+
*destP = outputSample;
destP += inNumChannels;
}