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 --- .../DeEss.xcodeproj/christopherjohnson.pbxuser | 34 ++++++++++++-- .../christopherjohnson.perspectivev3 | 42 +++++++++-------- plugins/MacVST/DeEss/source/DeEssProc.cpp | 54 ++++++++-------------- 3 files changed, 71 insertions(+), 59 deletions(-) (limited to 'plugins/MacVST/DeEss') diff --git a/plugins/MacVST/DeEss/DeEss.xcodeproj/christopherjohnson.pbxuser b/plugins/MacVST/DeEss/DeEss.xcodeproj/christopherjohnson.pbxuser index 71fc919..fd07bbd 100755 --- a/plugins/MacVST/DeEss/DeEss.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacVST/DeEss/DeEss.xcodeproj/christopherjohnson.pbxuser @@ -49,8 +49,12 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 561683712; - PBXWorkspaceStateSaveDate = 561683712; + PBXPerProjectTemplateStateSaveDate = 569734238; + PBXWorkspaceStateSaveDate = 569734238; + }; + perUserProjectItems = { + 8B79377321F5746E006E9731 /* PBXTextBookmark */ = 8B79377321F5746E006E9731 /* PBXTextBookmark */; + 8B79377421F5746E006E9731 /* PBXTextBookmark */ = 8B79377421F5746E006E9731 /* PBXTextBookmark */; }; sourceControlManager = 8B02375E1D42B1C400E1E8C8 /* Source Control */; userBuildSettings = { @@ -82,9 +86,9 @@ }; 24D8286F09A914000093AEF8 /* DeEssProc.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {848, 4589}}"; - sepNavSelRange = "{10846, 0}"; - sepNavVisRange = "{9960, 1917}"; + sepNavIntBoundsRect = "{{0, 0}, {796, 4355}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRange = "{4813, 714}"; sepNavWindowFrame = "{{47, 47}, {895, 831}}"; }; }; @@ -102,6 +106,26 @@ isa = PBXCodeSenseManager; indexTemplatePath = ""; }; + 8B79377321F5746E006E9731 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 24D8286F09A914000093AEF8 /* DeEssProc.cpp */; + name = "DeEssProc.cpp: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 211; + vrLoc = 0; + }; + 8B79377421F5746E006E9731 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 24D8286F09A914000093AEF8 /* DeEssProc.cpp */; + name = "DeEssProc.cpp: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 714; + vrLoc = 4813; + }; 8D01CCC60486CAD60068D4B7 /* DeEss */ = { activeExec = 0; }; diff --git a/plugins/MacVST/DeEss/DeEss.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacVST/DeEss/DeEss.xcodeproj/christopherjohnson.perspectivev3 index 51981f2..b85a83a 100755 --- a/plugins/MacVST/DeEss/DeEss.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacVST/DeEss/DeEss.xcodeproj/christopherjohnson.perspectivev3 @@ -300,7 +300,7 @@ PBXSmartGroupTreeModuleOutlineStateSelectionKey - 5 + 6 4 0 @@ -323,7 +323,7 @@ 185 RubberWindowFrame - 12 385 810 487 0 0 1440 878 + 304 315 810 487 0 0 1440 878 Module PBXSmartGroupTreeModule @@ -339,7 +339,7 @@ PBXProjectModuleGUID 8B0237581D42B1C400E1E8C8 PBXProjectModuleLabel - Gain.h + DeEssProc.cpp PBXSplitModuleInNavigatorKey Split0 @@ -347,7 +347,15 @@ PBXProjectModuleGUID 8B0237591D42B1C400E1E8C8 PBXProjectModuleLabel - Gain.h + DeEssProc.cpp + _historyCapacity + 0 + bookmark + 8B79377421F5746E006E9731 + history + + 8B79377321F5746E006E9731 + SplitCount 1 @@ -360,18 +368,18 @@ GeometryConfiguration Frame - {{0, 0}, {603, 0}} + {{0, 0}, {603, 319}} RubberWindowFrame - 12 385 810 487 0 0 1440 878 + 304 315 810 487 0 0 1440 878 Module PBXNavigatorGroup Proportion - 0pt + 319pt Proportion - 441pt + 122pt Tabs @@ -385,9 +393,9 @@ GeometryConfiguration Frame - {{10, 27}, {603, 414}} + {{10, 27}, {603, 95}} RubberWindowFrame - 12 385 810 487 0 0 1440 878 + 304 315 810 487 0 0 1440 878 Module XCDetailModule @@ -469,11 +477,11 @@ TableOfContents - 8B15DCFB217AA408007AD769 + 8B79377521F5746E006E9731 1CA23ED40692098700951B8B - 8B15DCFC217AA408007AD769 + 8B79377621F5746E006E9731 8B0237581D42B1C400E1E8C8 - 8B15DCFD217AA408007AD769 + 8B79377721F5746E006E9731 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -626,7 +634,7 @@ StatusbarIsVisible TimeStamp - 561685512.74774003 + 569734254.77218902 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -643,12 +651,10 @@ 5 WindowOrderList - 8B15DCFE217AA408007AD769 - 8B15DCFF217AA408007AD769 - /Users/christopherjohnson/Desktop/DeEss/DeEss.xcodeproj + /Users/christopherjohnson/Desktop/MacVST/DeEss/DeEss.xcodeproj WindowString - 12 385 810 487 0 0 1440 878 + 304 315 810 487 0 0 1440 878 WindowToolsV3 diff --git a/plugins/MacVST/DeEss/source/DeEssProc.cpp b/plugins/MacVST/DeEss/source/DeEssProc.cpp index 9a8e14b..9b030a4 100755 --- a/plugins/MacVST/DeEss/source/DeEssProc.cpp +++ b/plugins/MacVST/DeEss/source/DeEssProc.cpp @@ -148,18 +148,14 @@ void DeEss::processReplacing(float **inputs, float **outputs, VstInt32 sampleFra flip = !flip; - //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; @@ -169,12 +165,6 @@ void DeEss::processReplacing(float **inputs, float **outputs, VstInt32 sampleFra *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 DeEss::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames) @@ -318,18 +308,16 @@ void DeEss::processDoubleReplacing(double **inputs, double **outputs, VstInt32 s flip = !flip; - //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; @@ -339,10 +327,4 @@ void DeEss::processDoubleReplacing(double **inputs, double **outputs, VstInt32 s *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