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/Density/Density.cpp | 25 +++------ plugins/MacAU/Density/Density.exp | 2 +- plugins/MacAU/Density/Density.h | 3 +- .../Density.xcodeproj/christopherjohnson.pbxuser | 60 ++++++++++++---------- .../christopherjohnson.perspectivev3 | 39 +++++++------- 5 files changed, 63 insertions(+), 66 deletions(-) (limited to 'plugins/MacAU/Density') diff --git a/plugins/MacAU/Density/Density.cpp b/plugins/MacAU/Density/Density.cpp index 68c3828..7edf12b 100755 --- a/plugins/MacAU/Density/Density.cpp +++ b/plugins/MacAU/Density/Density.cpp @@ -184,8 +184,7 @@ void Density::DensityKernel::Reset() { iirSampleA = 0.0; iirSampleB = 0.0; - fpNShapeA = 0.0; - fpNShapeB = 0.0; + fpNShape = 0.0; fpFlip = true; } @@ -220,9 +219,6 @@ void Density::DensityKernel::Process( const Float32 *inSourceP, Float64 out = fabs(density); density = density * fabs(density); Float64 count; - Float32 fpTemp; - Float64 fpOld = 0.618033988749894848204586; //golden ratio! - Float64 fpNew = 1.0 - fpOld; while (nSampleFrames-- > 0) { inputSample = *sourceP; @@ -291,20 +287,13 @@ void Density::DensityKernel::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; diff --git a/plugins/MacAU/Density/Density.exp b/plugins/MacAU/Density/Density.exp index 8d6e23b..85300f6 100755 --- a/plugins/MacAU/Density/Density.exp +++ b/plugins/MacAU/Density/Density.exp @@ -1 +1 @@ -_DensityEntry \ No newline at end of file +_DensityEntry diff --git a/plugins/MacAU/Density/Density.h b/plugins/MacAU/Density/Density.h index ac8d445..0d9af29 100755 --- a/plugins/MacAU/Density/Density.h +++ b/plugins/MacAU/Density/Density.h @@ -138,8 +138,7 @@ public: private: Float64 iirSampleA; Float64 iirSampleB; - Float64 fpNShapeA; - Float64 fpNShapeB; + long double fpNShape; bool fpFlip; }; }; diff --git a/plugins/MacAU/Density/Density.xcodeproj/christopherjohnson.pbxuser b/plugins/MacAU/Density/Density.xcodeproj/christopherjohnson.pbxuser index bbb10da..76445ad 100755 --- a/plugins/MacAU/Density/Density.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacAU/Density/Density.xcodeproj/christopherjohnson.pbxuser @@ -49,33 +49,51 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 553737317; - PBXWorkspaceStateSaveDate = 553737317; + PBXPerProjectTemplateStateSaveDate = 569597523; + PBXWorkspaceStateSaveDate = 569597523; }; perUserProjectItems = { - 8B241C8921015F29001BBF7E /* PBXTextBookmark */ = 8B241C8921015F29001BBF7E /* PBXTextBookmark */; - 8BC5CD4B208D59FB0058B257 /* PBXTextBookmark */ = 8BC5CD4B208D59FB0058B257 /* PBXTextBookmark */; + 8B792A5721F35EBB006E9731 /* PBXTextBookmark */ = 8B792A5721F35EBB006E9731 /* PBXTextBookmark */; + 8B792A5D21F35ED5006E9731 /* PBXTextBookmark */ = 8B792A5D21F35ED5006E9731 /* PBXTextBookmark */; }; sourceControlManager = 8BD3CCB8148830B20062E48C /* Source Control */; userBuildSettings = { }; }; - 8B241C8921015F29001BBF7E /* PBXTextBookmark */ = { + 8B792A5721F35EBB006E9731 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 8BA05A660720730100365D66 /* Density.cpp */; - name = "Density.cpp: 290"; + name = "Density.cpp: 286"; rLen = 68; - rLoc = 12813; + rLoc = 12685; rType = 0; - vrLen = 106; - vrLoc = 27; + vrLen = 91; + vrLoc = 42; + }; + 8B792A5D21F35ED5006E9731 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 8BA05A660720730100365D66 /* Density.cpp */; + name = "Density.cpp: 286"; + rLen = 68; + rLoc = 12685; + rType = 0; + vrLen = 91; + vrLoc = 42; }; 8BA05A660720730100365D66 /* Density.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {803, 4108}}"; - sepNavSelRange = "{12813, 68}"; - sepNavVisRange = "{27, 106}"; - sepNavWindowFrame = "{{545, 59}, {895, 819}}"; + sepNavIntBoundsRect = "{{0, 0}, {803, 4069}}"; + sepNavSelRange = "{12685, 68}"; + sepNavVisRange = "{42, 91}"; + sepNavWindowFrame = "{{414, 59}, {895, 819}}"; + }; + }; + 8BA05A670720730100365D66 /* Density.exp */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1253, 694}}"; + sepNavSelRange = "{14, 0}"; + sepNavVisRange = "{0, 14}"; + sepNavWindowFrame = "{{15, 51}, {1300, 822}}"; }; }; 8BA05A690720730100365D66 /* DensityVersion.h */ = { @@ -86,21 +104,11 @@ sepNavWindowFrame = "{{15, 38}, {731, 835}}"; }; }; - 8BC5CD4B208D59FB0058B257 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 8BA05A660720730100365D66 /* Density.cpp */; - name = "Density.cpp: 290"; - rLen = 68; - rLoc = 12813; - rType = 0; - vrLen = 109; - vrLoc = 24; - }; 8BC6025B073B072D006C4272 /* Density.h */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {856, 1950}}"; - sepNavSelRange = "{5537, 44}"; - sepNavVisRange = "{4519, 1228}"; + sepNavIntBoundsRect = "{{0, 0}, {856, 2158}}"; + sepNavSelRange = "{5604, 0}"; + sepNavVisRange = "{4448, 1275}"; sepNavWindowFrame = "{{537, 146}, {903, 692}}"; }; }; diff --git a/plugins/MacAU/Density/Density.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacAU/Density/Density.xcodeproj/christopherjohnson.perspectivev3 index 8c57043..affa75d 100755 --- a/plugins/MacAU/Density/Density.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacAU/Density/Density.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 - 619 361 810 487 0 0 1440 878 + 482 370 810 487 0 0 1440 878 Module PBXSmartGroupTreeModule @@ -352,10 +352,10 @@ _historyCapacity 0 bookmark - 8B241C8921015F29001BBF7E + 8B792A5D21F35ED5006E9731 history - 8BC5CD4B208D59FB0058B257 + 8B792A5721F35EBB006E9731 SplitCount @@ -369,18 +369,18 @@ GeometryConfiguration Frame - {{0, 0}, {603, 102}} + {{0, 0}, {603, 86}} RubberWindowFrame - 619 361 810 487 0 0 1440 878 + 482 370 810 487 0 0 1440 878 Module PBXNavigatorGroup Proportion - 102pt + 86pt Proportion - 339pt + 355pt Tabs @@ -394,9 +394,7 @@ GeometryConfiguration Frame - {{10, 27}, {603, 312}} - RubberWindowFrame - 619 361 810 487 0 0 1440 878 + {{10, 27}, {603, 328}} Module XCDetailModule @@ -450,7 +448,9 @@ GeometryConfiguration Frame - {{10, 31}, {603, 297}} + {{10, 27}, {603, 328}} + RubberWindowFrame + 482 370 810 487 0 0 1440 878 Module PBXBuildResultsModule @@ -478,11 +478,11 @@ TableOfContents - 8B241C8A21015F29001BBF7E + 8B792A5E21F35ED5006E9731 1CA23ED40692098700951B8B - 8B241C8B21015F29001BBF7E + 8B792A5F21F35ED5006E9731 8BE3FF9D1DAAD40200A5AAF5 - 8B241C8C21015F29001BBF7E + 8B792A6021F35ED5006E9731 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -635,7 +635,7 @@ StatusbarIsVisible TimeStamp - 553738025.40924096 + 569597652.99950302 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -652,10 +652,11 @@ 5 WindowOrderList + 8B792A6121F35ED5006E9731 /Users/christopherjohnson/Desktop/MacAU/Density/Density.xcodeproj WindowString - 619 361 810 487 0 0 1440 878 + 482 370 810 487 0 0 1440 878 WindowToolsV3 -- cgit v1.2.3