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 --- plugins/MacAU/Fracture/Fracture.cpp | 28 +++--------- plugins/MacAU/Fracture/Fracture.exp | 2 +- plugins/MacAU/Fracture/Fracture.h | 4 +- .../Fracture.xcodeproj/christopherjohnson.pbxuser | 50 ++++++++++++++++++---- .../christopherjohnson.perspectivev3 | 47 +++++++++++--------- 5 files changed, 77 insertions(+), 54 deletions(-) (limited to 'plugins/MacAU/Fracture') diff --git a/plugins/MacAU/Fracture/Fracture.cpp b/plugins/MacAU/Fracture/Fracture.cpp index f6a7186..4818270 100755 --- a/plugins/MacAU/Fracture/Fracture.cpp +++ b/plugins/MacAU/Fracture/Fracture.cpp @@ -182,9 +182,7 @@ ComponentResult Fracture::Initialize() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void Fracture::FractureKernel::Reset() { - fpNShapeA = 0.0; - fpNShapeB = 0.0; - fpFlip = true; + fpNShape = 0.0; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -211,11 +209,7 @@ void Fracture::FractureKernel::Process( const Float32 *inSourceP, Float64 wet = GetParameter( kParam_Four ); Float64 dry = 1.0-wet; Float64 bridgerectifier; - density = density * fabs(density); - Float32 fpTemp; - Float64 fpOld = 0.618033988749894848204586; //golden ratio! - Float64 fpNew = 1.0 - fpOld; - + density = density * fabs(density); while (nSampleFrames-- > 0) { inputSample = *sourceP; @@ -261,19 +255,11 @@ void Fracture::FractureKernel::Process( const Float32 *inSourceP, inputSample = (drySample * dry)+(inputSample*wet); //that simple. - //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; sourceP += inNumChannels; diff --git a/plugins/MacAU/Fracture/Fracture.exp b/plugins/MacAU/Fracture/Fracture.exp index b485428..9eb17a5 100755 --- a/plugins/MacAU/Fracture/Fracture.exp +++ b/plugins/MacAU/Fracture/Fracture.exp @@ -1 +1 @@ -_FractureEntry \ No newline at end of file +_FractureEntry diff --git a/plugins/MacAU/Fracture/Fracture.h b/plugins/MacAU/Fracture/Fracture.h index aa9a6f5..1dccb92 100755 --- a/plugins/MacAU/Fracture/Fracture.h +++ b/plugins/MacAU/Fracture/Fracture.h @@ -134,9 +134,7 @@ public: virtual void Reset(); private: - Float64 fpNShapeA; - Float64 fpNShapeB; - bool fpFlip; + long double fpNShape; }; }; diff --git a/plugins/MacAU/Fracture/Fracture.xcodeproj/christopherjohnson.pbxuser b/plugins/MacAU/Fracture/Fracture.xcodeproj/christopherjohnson.pbxuser index 9e2cdb2..4efb520 100755 --- a/plugins/MacAU/Fracture/Fracture.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacAU/Fracture/Fracture.xcodeproj/christopherjohnson.pbxuser @@ -49,19 +49,51 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 528456201; - PBXWorkspaceStateSaveDate = 528456201; + PBXPerProjectTemplateStateSaveDate = 569645423; + PBXWorkspaceStateSaveDate = 569645423; + }; + perUserProjectItems = { + 8B792C5521F41A58006E9731 /* PBXTextBookmark */ = 8B792C5521F41A58006E9731 /* PBXTextBookmark */; + 8B792C5B21F41AB6006E9731 /* PBXTextBookmark */ = 8B792C5B21F41AB6006E9731 /* PBXTextBookmark */; }; sourceControlManager = 8BD3CCB8148830B20062E48C /* Source Control */; userBuildSettings = { }; }; + 8B792C5521F41A58006E9731 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 8BA05A660720730100365D66 /* Fracture.cpp */; + name = "Fracture.cpp: 248"; + rLen = 0; + rLoc = 11543; + rType = 0; + vrLen = 312; + vrLoc = 11562; + }; + 8B792C5B21F41AB6006E9731 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 8BA05A660720730100365D66 /* Fracture.cpp */; + name = "Fracture.cpp: 248"; + rLen = 0; + rLoc = 11543; + rType = 0; + vrLen = 312; + vrLoc = 11562; + }; 8BA05A660720730100365D66 /* Fracture.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {964, 3913}}"; - sepNavSelRange = "{11687, 0}"; - sepNavVisRange = "{9717, 2345}"; - sepNavWindowFrame = "{{517, 41}, {923, 837}}"; + sepNavIntBoundsRect = "{{0, 0}, {621, 3718}}"; + sepNavSelRange = "{11543, 0}"; + sepNavVisRange = "{11562, 312}"; + sepNavWindowFrame = "{{365, 41}, {923, 837}}"; + }; + }; + 8BA05A670720730100365D66 /* Fracture.exp */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1253, 694}}"; + sepNavSelRange = "{15, 0}"; + sepNavVisRange = "{0, 15}"; + sepNavWindowFrame = "{{15, 51}, {1300, 822}}"; }; }; 8BA05A690720730100365D66 /* FractureVersion.h */ = { @@ -74,9 +106,9 @@ }; 8BC6025B073B072D006C4272 /* Fracture.h */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {922, 1846}}"; - sepNavSelRange = "{5434, 0}"; - sepNavVisRange = "{3891, 1652}"; + sepNavIntBoundsRect = "{{0, 0}, {922, 1859}}"; + sepNavSelRange = "{5401, 0}"; + sepNavVisRange = "{3843, 1667}"; sepNavWindowFrame = "{{517, 39}, {923, 837}}"; }; }; diff --git a/plugins/MacAU/Fracture/Fracture.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacAU/Fracture/Fracture.xcodeproj/christopherjohnson.perspectivev3 index 46cfa67..a5f791e 100755 --- a/plugins/MacAU/Fracture/Fracture.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacAU/Fracture/Fracture.xcodeproj/christopherjohnson.perspectivev3 @@ -225,8 +225,8 @@ PerspectiveWidths - -1 - -1 + 810 + 810 Perspectives @@ -300,7 +300,7 @@ PBXSmartGroupTreeModuleOutlineStateSelectionKey - 4 + 5 2 1 0 @@ -324,7 +324,7 @@ 185 RubberWindowFrame - 362 267 810 487 0 0 1440 878 + 431 299 810 487 0 0 1440 878 Module PBXSmartGroupTreeModule @@ -340,7 +340,7 @@ PBXProjectModuleGUID 8B9CE5211DFF96EB00A5DC6F PBXProjectModuleLabel - + Fracture.cpp PBXSplitModuleInNavigatorKey Split0 @@ -348,7 +348,15 @@ PBXProjectModuleGUID 8B9CE5221DFF96EB00A5DC6F PBXProjectModuleLabel - + Fracture.cpp + _historyCapacity + 0 + bookmark + 8B792C5B21F41AB6006E9731 + history + + 8B792C5521F41A58006E9731 + SplitCount 1 @@ -361,18 +369,18 @@ GeometryConfiguration Frame - {{0, 0}, {603, 0}} + {{0, 0}, {603, 132}} RubberWindowFrame - 362 267 810 487 0 0 1440 878 + 431 299 810 487 0 0 1440 878 Module PBXNavigatorGroup Proportion - 0pt + 132pt Proportion - 441pt + 309pt Tabs @@ -386,9 +394,7 @@ GeometryConfiguration Frame - {{10, 27}, {603, 414}} - RubberWindowFrame - 362 267 810 487 0 0 1440 878 + {{10, 27}, {603, 282}} Module XCDetailModule @@ -442,7 +448,9 @@ GeometryConfiguration Frame - {{10, 27}, {603, 414}} + {{10, 27}, {603, 282}} + RubberWindowFrame + 431 299 810 487 0 0 1440 878 Module PBXBuildResultsModule @@ -470,11 +478,11 @@ TableOfContents - 8B9D742C1F7F9A57007AB60F + 8B792C5C21F41AB6006E9731 1CA23ED40692098700951B8B - 8B9D742D1F7F9A57007AB60F + 8B792C5D21F41AB6006E9731 8B9CE5211DFF96EB00A5DC6F - 8B9D742E1F7F9A57007AB60F + 8B792C5E21F41AB6006E9731 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -627,7 +635,7 @@ StatusbarIsVisible TimeStamp - 528456279.90402597 + 569645750.04603803 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -644,11 +652,10 @@ 5 WindowOrderList - 8B9D742F1F7F9A57007AB60F /Users/christopherjohnson/Desktop/MacAU/Fracture/Fracture.xcodeproj WindowString - 362 267 810 487 0 0 1440 878 + 431 299 810 487 0 0 1440 878 WindowToolsV3 -- cgit v1.2.3