aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/MacAU/AtmosphereChannel/AtmosphereChannel.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/AtmosphereChannel/AtmosphereChannel.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/AtmosphereChannel/AtmosphereChannel.cpp')
-rwxr-xr-xplugins/MacAU/AtmosphereChannel/AtmosphereChannel.cpp19
1 files changed, 5 insertions, 14 deletions
diff --git a/plugins/MacAU/AtmosphereChannel/AtmosphereChannel.cpp b/plugins/MacAU/AtmosphereChannel/AtmosphereChannel.cpp
index d0ca7aa..6ca9131 100755
--- a/plugins/MacAU/AtmosphereChannel/AtmosphereChannel.cpp
+++ b/plugins/MacAU/AtmosphereChannel/AtmosphereChannel.cpp
@@ -203,7 +203,6 @@ void AtmosphereChannel::AtmosphereChannelKernel::Process( const Float32 *inSou
UInt32 nSampleFrames = inFramesToProcess;
const Float32 *sourceP = inSourceP;
Float32 *destP = inDestP;
- Float32 fpTemp;
Float64 overallscale = 1.0;
overallscale /= 44100.0;
overallscale *= GetSampleRate();
@@ -339,23 +338,15 @@ void AtmosphereChannel::AtmosphereChannelKernel::Process( const Float32 *inSou
lastSampleA = drySample;
//store the raw input sample again for use next time
- //noise shaping to 32-bit floating point
- fpTemp = inputSample;
- fpNShape += (inputSample-fpTemp);
- inputSample += fpNShape;
- //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
+ //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;
sourceP += inNumChannels; destP += inNumChannels;
}
- fpNShape *= 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.
}