aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/MacAU/Drive/Drive.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/MacAU/Drive/Drive.cpp')
-rwxr-xr-xplugins/MacAU/Drive/Drive.cpp26
1 files changed, 7 insertions, 19 deletions
diff --git a/plugins/MacAU/Drive/Drive.cpp b/plugins/MacAU/Drive/Drive.cpp
index 179d9ae..ab3c0bc 100755
--- a/plugins/MacAU/Drive/Drive.cpp
+++ b/plugins/MacAU/Drive/Drive.cpp
@@ -184,8 +184,7 @@ void Drive::DriveKernel::Reset()
{
iirSampleA = 0.0;
iirSampleB = 0.0;
- fpNShapeA = 0.0;
- fpNShapeB = 0.0;
+ fpNShape = 0.0;
fpFlip = true;
}
@@ -220,10 +219,6 @@ void Drive::DriveKernel::Process( const Float32 *inSourceP,
Float64 glitch = 0.60;
Float64 out;
- Float32 fpTemp;
- Float64 fpOld = 0.618033988749894848204586; //golden ratio!
- Float64 fpNew = 1.0 - fpOld;
-
while (nSampleFrames-- > 0) {
inputSample = *sourceP;
if (inputSample<1.2e-38 && -inputSample<1.2e-38) {
@@ -282,20 +277,13 @@ void Drive::DriveKernel::Process( const Float32 *inSourceP,
if (wet < 1.0) inputSample = (drySample * dry)+(inputSample*wet);
//nice little output stage template: if we have another scale of floating point
//number, we really don't want to meaninglessly multiply that by 1.0.
-
- //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 = !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;