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/Air/Air.cpp | 29 ++++------------ plugins/MacAU/Air/Air.h | 7 +--- .../Air/Air.xcodeproj/christopherjohnson.pbxuser | 40 +++++++++++----------- .../Air.xcodeproj/christopherjohnson.perspectivev3 | 28 +++++++-------- 4 files changed, 41 insertions(+), 63 deletions(-) (limited to 'plugins/MacAU/Air') diff --git a/plugins/MacAU/Air/Air.cpp b/plugins/MacAU/Air/Air.cpp index 716f907..7ba3efe 100755 --- a/plugins/MacAU/Air/Air.cpp +++ b/plugins/MacAU/Air/Air.cpp @@ -222,11 +222,7 @@ void Air::AirKernel::Reset() tripletC = 0.0; tripletFactor = 0.0; count = 1; - - fpNShapeA = 0.0; - fpNShapeB = 0.0; - fpFlip = true; - + fpNShape = 0.0; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -254,11 +250,6 @@ void Air::AirKernel::Process( const Float32 *inSourceP, Float64 wet = GetParameter( kParam_Six ); Float64 dry = 1.0-wet; - - Float64 fpOld = 0.618033988749894848204586; //golden ratio! - Float64 fpNew = 1.0 - fpOld; - Float32 fpTemp; - long double inputSample; Float64 drySample; Float64 correction; @@ -399,19 +390,11 @@ void Air::AirKernel::Process( const Float32 *inSourceP, //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. - if (fpFlip) { - fpTemp = inputSample; - fpNShapeA = (fpNShapeA*fpOld)+((inputSample-fpTemp)*fpNew); - inputSample += fpNShapeA; - } - else { - fpTemp = inputSample; - fpNShapeB = (fpNShapeB*fpOld)+((inputSample-fpTemp)*fpNew); - inputSample += fpNShapeB; - } - fpFlip = not 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; destP += inNumChannels; diff --git a/plugins/MacAU/Air/Air.h b/plugins/MacAU/Air/Air.h index 571b8ac..6dcd06c 100755 --- a/plugins/MacAU/Air/Air.h +++ b/plugins/MacAU/Air/Air.h @@ -164,12 +164,7 @@ public: Float64 tripletC; Float64 tripletFactor; int count; - - - long double fpNShapeA; - long double fpNShapeB; - bool fpFlip; - + long double fpNShape; }; }; diff --git a/plugins/MacAU/Air/Air.xcodeproj/christopherjohnson.pbxuser b/plugins/MacAU/Air/Air.xcodeproj/christopherjohnson.pbxuser index 2af057b..3a436a8 100755 --- a/plugins/MacAU/Air/Air.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacAU/Air/Air.xcodeproj/christopherjohnson.pbxuser @@ -49,34 +49,34 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 528421060; - PBXWorkspaceStateSaveDate = 528421060; + PBXPerProjectTemplateStateSaveDate = 569588293; + PBXWorkspaceStateSaveDate = 569588293; }; perUserProjectItems = { - 8B9D72161F7EFB8B007AB60F /* PBXTextBookmark */ = 8B9D72161F7EFB8B007AB60F /* PBXTextBookmark */; - 8B9D72A71F7F10F4007AB60F /* PBXTextBookmark */ = 8B9D72A71F7F10F4007AB60F /* PBXTextBookmark */; + 8B79276221F33AB6006E9731 /* PBXTextBookmark */ = 8B79276221F33AB6006E9731 /* PBXTextBookmark */; + 8B79276821F33AE6006E9731 /* PBXTextBookmark */ = 8B79276821F33AE6006E9731 /* PBXTextBookmark */; 8B9F0C261EB403E000D3B900 /* PBXTextBookmark */ = 8B9F0C261EB403E000D3B900 /* PBXTextBookmark */; }; sourceControlManager = 8BD3CCB8148830B20062E48C /* Source Control */; userBuildSettings = { }; }; - 8B9D72161F7EFB8B007AB60F /* PBXTextBookmark */ = { + 8B79276221F33AB6006E9731 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 8BA05A660720730100365D66 /* Air.cpp */; - name = "Air.cpp: 397"; + name = "Air.cpp: 394"; rLen = 0; - rLoc = 15339; + rLoc = 15189; rType = 0; - vrLen = 94; - vrLoc = 14078; + vrLen = 0; + vrLoc = 0; }; - 8B9D72A71F7F10F4007AB60F /* PBXTextBookmark */ = { + 8B79276821F33AE6006E9731 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 8BA05A660720730100365D66 /* Air.cpp */; - name = "Air.cpp: 398"; + name = "Air.cpp: 389"; rLen = 0; - rLoc = 15339; + rLoc = 15189; rType = 0; vrLen = 0; vrLoc = 0; @@ -86,17 +86,17 @@ fRef = 8BC6025B073B072D006C4272 /* Air.h */; name = "Air.h: 169"; rLen = 0; - rLoc = 6210; + rLoc = 6204; rType = 0; vrLen = 107; vrLoc = 6071; }; 8BA05A660720730100365D66 /* Air.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {554, 5512}}"; - sepNavSelRange = "{15339, 0}"; + sepNavIntBoundsRect = "{{0, 0}, {554, 5421}}"; + sepNavSelRange = "{15189, 0}"; sepNavVisRange = "{0, 0}"; - sepNavWindowFrame = "{{255, 66}, {1145, 812}}"; + sepNavWindowFrame = "{{152, 66}, {1145, 812}}"; }; }; 8BA05A690720730100365D66 /* AirVersion.h */ = { @@ -109,10 +109,10 @@ }; 8BC6025B073B072D006C4272 /* Air.h */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {656, 2574}}"; - sepNavSelRange = "{6210, 0}"; - sepNavVisRange = "{6071, 107}"; - sepNavWindowFrame = "{{505, 39}, {1053, 839}}"; + sepNavIntBoundsRect = "{{0, 0}, {1006, 2483}}"; + sepNavSelRange = "{6190, 0}"; + sepNavVisRange = "{5126, 1198}"; + sepNavWindowFrame = "{{387, 39}, {1053, 839}}"; }; }; 8BD3CCB8148830B20062E48C /* Source Control */ = { diff --git a/plugins/MacAU/Air/Air.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacAU/Air/Air.xcodeproj/christopherjohnson.perspectivev3 index f7348cf..c4d0cd5 100755 --- a/plugins/MacAU/Air/Air.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacAU/Air/Air.xcodeproj/christopherjohnson.perspectivev3 @@ -352,11 +352,11 @@ _historyCapacity 0 bookmark - 8B9D72A71F7F10F4007AB60F + 8B79276821F33AE6006E9731 history 8B9F0C261EB403E000D3B900 - 8B9D72161F7EFB8B007AB60F + 8B79276221F33AB6006E9731 SplitCount @@ -370,18 +370,18 @@ GeometryConfiguration Frame - {{0, 0}, {603, 32}} + {{0, 0}, {603, 13}} RubberWindowFrame 484 346 810 487 0 0 1440 878 Module PBXNavigatorGroup Proportion - 32pt + 13pt Proportion - 409pt + 428pt Tabs @@ -395,9 +395,7 @@ GeometryConfiguration Frame - {{10, 27}, {603, 382}} - RubberWindowFrame - 484 346 810 487 0 0 1440 878 + {{10, 27}, {603, 401}} Module XCDetailModule @@ -451,7 +449,9 @@ GeometryConfiguration Frame - {{10, 27}, {603, 328}} + {{10, 27}, {603, 401}} + RubberWindowFrame + 484 346 810 487 0 0 1440 878 Module PBXBuildResultsModule @@ -479,11 +479,11 @@ TableOfContents - 8B9D72A81F7F10F4007AB60F + 8B79276921F33AE6006E9731 1CA23ED40692098700951B8B - 8B9D72A91F7F10F4007AB60F + 8B79276A21F33AE6006E9731 8BDB25A91EAA638A001F42B2 - 8B9D72AA1F7F10F4007AB60F + 8B79276B21F33AE6006E9731 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -636,7 +636,7 @@ StatusbarIsVisible TimeStamp - 528421108.41774899 + 569588454.36706197 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -653,7 +653,7 @@ 5 WindowOrderList - 8B9D72AB1F7F10F4007AB60F + 8B79276C21F33AE6006E9731 /Users/christopherjohnson/Desktop/MacAU/Air/Air.xcodeproj WindowString -- cgit v1.2.3