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 --- .../ADT/ADT.xcodeproj/christopherjohnson.pbxuser | 43 ++++++++++------- .../ADT.xcodeproj/christopherjohnson.perspectivev3 | 24 +++++----- plugins/MacVST/ADT/source/ADTProc.cpp | 54 ++++++++-------------- 3 files changed, 57 insertions(+), 64 deletions(-) (limited to 'plugins/MacVST/ADT') diff --git a/plugins/MacVST/ADT/ADT.xcodeproj/christopherjohnson.pbxuser b/plugins/MacVST/ADT/ADT.xcodeproj/christopherjohnson.pbxuser index 883fa84..8d10b59 100755 --- a/plugins/MacVST/ADT/ADT.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacVST/ADT/ADT.xcodeproj/christopherjohnson.pbxuser @@ -49,12 +49,13 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 561773367; - PBXWorkspaceStateSaveDate = 561773367; + PBXPerProjectTemplateStateSaveDate = 569707657; + PBXWorkspaceStateSaveDate = 569707657; }; perUserProjectItems = { - 8B15DB9A21743644007AD769 /* PBXTextBookmark */ = 8B15DB9A21743644007AD769 /* PBXTextBookmark */; - 8B15DD60217BFB50007AD769 /* PBXTextBookmark */ = 8B15DD60217BFB50007AD769 /* PBXTextBookmark */; + 8B79334D21F50CB2006E9731 /* PBXTextBookmark */ = 8B79334D21F50CB2006E9731 /* PBXTextBookmark */; + 8B79334E21F50CB2006E9731 /* PBXTextBookmark */ = 8B79334E21F50CB2006E9731 /* PBXTextBookmark */; + 8B79334F21F50CB2006E9731 /* PBXTextBookmark */ = 8B79334F21F50CB2006E9731 /* PBXTextBookmark */; }; sourceControlManager = 8B02375E1D42B1C400E1E8C8 /* Source Control */; userBuildSettings = { @@ -62,9 +63,9 @@ }; 2407DEB6089929BA00EB68BF /* ADT.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {740, 2093}}"; + sepNavIntBoundsRect = "{{0, 0}, {691, 2002}}"; sepNavSelRange = "{4290, 0}"; - sepNavVisRange = "{3343, 2609}"; + sepNavVisRange = "{4100, 345}"; sepNavWindowFrame = "{{735, 48}, {705, 830}}"; }; }; @@ -86,9 +87,9 @@ }; 24D8286F09A914000093AEF8 /* ADTProc.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {649, 4875}}"; + sepNavIntBoundsRect = "{{0, 0}, {782, 4446}}"; sepNavSelRange = "{7166, 0}"; - sepNavVisRange = "{7098, 143}"; + sepNavVisRange = "{5269, 841}"; sepNavWindowFrame = "{{129, 47}, {895, 831}}"; }; }; @@ -106,25 +107,35 @@ isa = PBXCodeSenseManager; indexTemplatePath = ""; }; - 8B15DB9A21743644007AD769 /* PBXTextBookmark */ = { + 8B79334D21F50CB2006E9731 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 2407DEB6089929BA00EB68BF /* ADT.cpp */; + name = "ADT.cpp: 121"; + rLen = 0; + rLoc = 4290; + rType = 0; + vrLen = 345; + vrLoc = 4100; + }; + 8B79334E21F50CB2006E9731 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 24D8286F09A914000093AEF8 /* ADTProc.cpp */; - name = "ADTProc.cpp: 207"; + name = "ADTProc.cpp: 213"; rLen = 0; rLoc = 7166; rType = 0; - vrLen = 178; - vrLoc = 7098; + vrLen = 256; + vrLoc = 7031; }; - 8B15DD60217BFB50007AD769 /* PBXTextBookmark */ = { + 8B79334F21F50CB2006E9731 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 24D8286F09A914000093AEF8 /* ADTProc.cpp */; - name = "ADTProc.cpp: 207"; + name = "ADTProc.cpp: 213"; rLen = 0; rLoc = 7166; rType = 0; - vrLen = 143; - vrLoc = 7098; + vrLen = 841; + vrLoc = 5269; }; 8D01CCC60486CAD60068D4B7 /* ADT */ = { activeExec = 0; diff --git a/plugins/MacVST/ADT/ADT.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacVST/ADT/ADT.xcodeproj/christopherjohnson.perspectivev3 index 1eef004..05aaf68 100755 --- a/plugins/MacVST/ADT/ADT.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacVST/ADT/ADT.xcodeproj/christopherjohnson.perspectivev3 @@ -300,7 +300,7 @@ PBXSmartGroupTreeModuleOutlineStateSelectionKey - 5 + 6 4 0 @@ -351,10 +351,11 @@ _historyCapacity 0 bookmark - 8B15DD60217BFB50007AD769 + 8B79334F21F50CB2006E9731 history - 8B15DB9A21743644007AD769 + 8B79334D21F50CB2006E9731 + 8B79334E21F50CB2006E9731 SplitCount @@ -368,18 +369,18 @@ GeometryConfiguration Frame - {{0, 0}, {603, 117}} + {{0, 0}, {603, 322}} RubberWindowFrame 162 338 810 487 0 0 1440 878 Module PBXNavigatorGroup Proportion - 117pt + 322pt Proportion - 324pt + 119pt Tabs @@ -393,7 +394,7 @@ GeometryConfiguration Frame - {{10, 27}, {603, 297}} + {{10, 27}, {603, 92}} RubberWindowFrame 162 338 810 487 0 0 1440 878 @@ -477,11 +478,11 @@ TableOfContents - 8B15DD52217BFB50007AD769 + 8B79335021F50CB2006E9731 1CA23ED40692098700951B8B - 8B15DD53217BFB50007AD769 + 8B79335121F50CB2006E9731 8B0237581D42B1C400E1E8C8 - 8B15DD54217BFB50007AD769 + 8B79335221F50CB2006E9731 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -634,7 +635,7 @@ StatusbarIsVisible TimeStamp - 561773392.88148701 + 569707698.51112998 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -651,7 +652,6 @@ 5 WindowOrderList - 8B15DD55217BFB50007AD769 /Users/christopherjohnson/Desktop/MacVST/ADT/ADT.xcodeproj WindowString diff --git a/plugins/MacVST/ADT/source/ADTProc.cpp b/plugins/MacVST/ADT/source/ADTProc.cpp index f963f2f..74d23dd 100755 --- a/plugins/MacVST/ADT/source/ADTProc.cpp +++ b/plugins/MacVST/ADT/source/ADTProc.cpp @@ -156,18 +156,14 @@ void ADT::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrame if (output < 1.0) {inputSampleL *= output; 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; @@ -177,12 +173,6 @@ void ADT::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrame *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 ADT::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames) @@ -334,18 +324,16 @@ void ADT::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sam if (output < 1.0) {inputSampleL *= output; 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; @@ -355,10 +343,4 @@ void ADT::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sam *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