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/Bite/Bite.cpp | 27 ++++---------- plugins/MacAU/Bite/Bite.h | 5 +-- .../Bite/Bite.xcodeproj/christopherjohnson.pbxuser | 42 +++++++++++----------- .../christopherjohnson.perspectivev3 | 39 ++++++++++---------- 4 files changed, 47 insertions(+), 66 deletions(-) (limited to 'plugins/MacAU/Bite') diff --git a/plugins/MacAU/Bite/Bite.cpp b/plugins/MacAU/Bite/Bite.cpp index 99d3134..c34bb3d 100755 --- a/plugins/MacAU/Bite/Bite.cpp +++ b/plugins/MacAU/Bite/Bite.cpp @@ -175,10 +175,7 @@ void Bite::BiteKernel::Reset() sampleG = 0.0; sampleH = 0.0; sampleI = 0.0; - - fpNShapeA = 0.0; - fpNShapeB = 0.0; - fpFlip = true; + fpNShape = 0.0; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -203,10 +200,7 @@ void Bite::BiteKernel::Process( const Float32 *inSourceP, Float64 midC; Float64 midD; Float64 trigger; - Float64 result; - Float64 fpOld = 0.618033988749894848204586; //golden ratio! - Float64 fpNew = 1.0 - fpOld; - Float32 fpTemp; + long double result; while (nSampleFrames-- > 0) { sampleI = sampleH; @@ -273,18 +267,11 @@ void Bite::BiteKernel::Process( const Float32 *inSourceP, if (outputgain != 1.0) result *= outputgain; - if (fpFlip) { - fpTemp = result; - fpNShapeA = (fpNShapeA*fpOld)+((result-fpTemp)*fpNew); - result += fpNShapeA; - } - else { - fpTemp = result; - fpNShapeB = (fpNShapeB*fpOld)+((result-fpTemp)*fpNew); - result += fpNShapeB; - } - fpFlip = not fpFlip; - //end noise shaping on 32 bit output + //32 bit dither, made small and tidy. + int expon; frexpf((Float32)result, &expon); + long double dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62); + result += (dither-fpNShape); fpNShape = dither; + //end 32 bit dither *destP = result; //output. diff --git a/plugins/MacAU/Bite/Bite.h b/plugins/MacAU/Bite/Bite.h index c7a5b06..b36870b 100755 --- a/plugins/MacAU/Bite/Bite.h +++ b/plugins/MacAU/Bite/Bite.h @@ -138,10 +138,7 @@ public: Float64 sampleG; Float64 sampleH; Float64 sampleI; - Float64 fpNShapeA; - Float64 fpNShapeB; - bool fpFlip; - + Float64 fpNShape; }; }; diff --git a/plugins/MacAU/Bite/Bite.xcodeproj/christopherjohnson.pbxuser b/plugins/MacAU/Bite/Bite.xcodeproj/christopherjohnson.pbxuser index f9c81c4..b8ac588 100755 --- a/plugins/MacAU/Bite/Bite.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacAU/Bite/Bite.xcodeproj/christopherjohnson.pbxuser @@ -49,43 +49,43 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 528421171; - PBXWorkspaceStateSaveDate = 528421171; + PBXPerProjectTemplateStateSaveDate = 569589737; + PBXWorkspaceStateSaveDate = 569589737; }; perUserProjectItems = { - 8B9D63401F7C8264007AB60F /* PBXTextBookmark */ = 8B9D63401F7C8264007AB60F /* PBXTextBookmark */; - 8B9D72D41F7F114A007AB60F /* PBXTextBookmark */ = 8B9D72D41F7F114A007AB60F /* PBXTextBookmark */; + 8B79281021F3405A006E9731 /* PBXTextBookmark */ = 8B79281021F3405A006E9731 /* PBXTextBookmark */; + 8B79281521F34076006E9731 /* PBXTextBookmark */ = 8B79281521F34076006E9731 /* PBXTextBookmark */; }; sourceControlManager = 8BD3CCB8148830B20062E48C /* Source Control */; userBuildSettings = { }; }; - 8B9D63401F7C8264007AB60F /* PBXTextBookmark */ = { + 8B79281021F3405A006E9731 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 8BA05A660720730100365D66 /* Bite.cpp */; - name = "Bite.cpp: 289"; + name = "Bite.cpp: 276"; rLen = 0; - rLoc = 11935; + rLoc = 11735; rType = 0; - vrLen = 433; - vrLoc = 10004; + vrLen = 155; + vrLoc = 10210; }; - 8B9D72D41F7F114A007AB60F /* PBXTextBookmark */ = { + 8B79281521F34076006E9731 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 8BA05A660720730100365D66 /* Bite.cpp */; - name = "Bite.cpp: 289"; + name = "Bite.cpp: 276"; rLen = 0; - rLoc = 11935; + rLoc = 11735; rType = 0; - vrLen = 402; - vrLoc = 10035; + vrLen = 155; + vrLoc = 10210; }; 8BA05A660720730100365D66 /* Bite.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {677, 3913}}"; - sepNavSelRange = "{11935, 0}"; - sepNavVisRange = "{10035, 402}"; - sepNavWindowFrame = "{{295, 66}, {1145, 812}}"; + sepNavIntBoundsRect = "{{0, 0}, {677, 3887}}"; + sepNavSelRange = "{11735, 0}"; + sepNavVisRange = "{10210, 155}"; + sepNavWindowFrame = "{{170, 66}, {1145, 812}}"; }; }; 8BA05A670720730100365D66 /* Bite.exp */ = { @@ -106,9 +106,9 @@ }; 8BC6025B073B072D006C4272 /* Bite.h */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {1062, 1963}}"; - sepNavSelRange = "{5170, 171}"; - sepNavVisRange = "{3327, 1862}"; + sepNavIntBoundsRect = "{{0, 0}, {1062, 1898}}"; + sepNavSelRange = "{5360, 0}"; + sepNavVisRange = "{3983, 1489}"; sepNavWindowFrame = "{{382, 39}, {1053, 839}}"; }; }; diff --git a/plugins/MacAU/Bite/Bite.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacAU/Bite/Bite.xcodeproj/christopherjohnson.perspectivev3 index 87e6588..4e2e4c6 100755 --- a/plugins/MacAU/Bite/Bite.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacAU/Bite/Bite.xcodeproj/christopherjohnson.perspectivev3 @@ -225,8 +225,8 @@ PerspectiveWidths - -1 - -1 + 810 + 810 Perspectives @@ -256,8 +256,6 @@ Layout - BecomeActive - ContentConfiguration PBXBottomSmartGroupGIDs @@ -324,7 +322,7 @@ 185 RubberWindowFrame - 612 285 810 487 0 0 1440 878 + 476 284 810 487 0 0 1440 878 Module PBXSmartGroupTreeModule @@ -352,10 +350,10 @@ _historyCapacity 0 bookmark - 8B9D72D41F7F114A007AB60F + 8B79281521F34076006E9731 history - 8B9D63401F7C8264007AB60F + 8B79281021F3405A006E9731 SplitCount @@ -369,18 +367,18 @@ GeometryConfiguration Frame - {{0, 0}, {603, 102}} + {{0, 0}, {603, 86}} RubberWindowFrame - 612 285 810 487 0 0 1440 878 + 476 284 810 487 0 0 1440 878 Module PBXNavigatorGroup Proportion - 102pt + 86pt Proportion - 339pt + 355pt Tabs @@ -394,9 +392,7 @@ GeometryConfiguration Frame - {{10, 27}, {603, 312}} - RubberWindowFrame - 612 285 810 487 0 0 1440 878 + {{10, 27}, {603, 328}} Module XCDetailModule @@ -450,7 +446,9 @@ GeometryConfiguration Frame - {{10, 27}, {603, 414}} + {{10, 27}, {603, 328}} + RubberWindowFrame + 476 284 810 487 0 0 1440 878 Module PBXBuildResultsModule @@ -478,11 +476,11 @@ TableOfContents - 8B9D72D51F7F114A007AB60F + 8B79281621F34076006E9731 1CA23ED40692098700951B8B - 8B9D72D61F7F114A007AB60F + 8B79281721F34076006E9731 8BDB25E81EAA6D6E001F42B2 - 8B9D72D71F7F114A007AB60F + 8B79281821F34076006E9731 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -635,7 +633,7 @@ StatusbarIsVisible TimeStamp - 528421194.64885902 + 569589878.38768005 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -652,11 +650,10 @@ 5 WindowOrderList - 8B9D72D81F7F114A007AB60F /Users/christopherjohnson/Desktop/MacAU/Bite/Bite.xcodeproj WindowString - 612 285 810 487 0 0 1440 878 + 476 284 810 487 0 0 1440 878 WindowToolsV3 -- cgit v1.2.3