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/NCSeventeen/NCSeventeen.cpp | 29 ++++----------- plugins/MacAU/NCSeventeen/NCSeventeen.h | 4 +-- .../christopherjohnson.pbxuser | 30 ++++++++-------- .../christopherjohnson.perspectivev3 | 41 ++++++++++------------ 4 files changed, 42 insertions(+), 62 deletions(-) (limited to 'plugins/MacAU/NCSeventeen') diff --git a/plugins/MacAU/NCSeventeen/NCSeventeen.cpp b/plugins/MacAU/NCSeventeen/NCSeventeen.cpp index cc27033..14f0cf2 100755 --- a/plugins/MacAU/NCSeventeen/NCSeventeen.cpp +++ b/plugins/MacAU/NCSeventeen/NCSeventeen.cpp @@ -173,9 +173,7 @@ void NCSeventeen::NCSeventeenKernel::Reset() basslev = 0.0; treblev = 0.0; cheblev = 0.0; - fpNShapeA = 0.0; - fpNShapeB = 0.0; - fpFlip = true; + fpNShape = 0.0; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -189,12 +187,7 @@ void NCSeventeen::NCSeventeenKernel::Process( const Float32 *inSourceP, { UInt32 nSampleFrames = inFramesToProcess; const Float32 *sourceP = inSourceP; - Float32 *destP = inDestP; - - Float32 fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; - + Float32 *destP = inDestP; Float64 inP2; Float64 chebyshev; Float64 overallscale = 1.0; @@ -389,19 +382,11 @@ void NCSeventeen::NCSeventeenKernel::Process( const Float32 *inSourceP, if (inputSample < -0.95) inputSample = -0.95; //iron bar - //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; //built in output trim and dry/wet by default diff --git a/plugins/MacAU/NCSeventeen/NCSeventeen.h b/plugins/MacAU/NCSeventeen/NCSeventeen.h index 80575ef..571f64f 100755 --- a/plugins/MacAU/NCSeventeen/NCSeventeen.h +++ b/plugins/MacAU/NCSeventeen/NCSeventeen.h @@ -133,9 +133,7 @@ public: Float64 basslev; Float64 treblev; Float64 cheblev; - long double fpNShapeA; - long double fpNShapeB; - bool fpFlip; + long double fpNShape; //default stuff }; diff --git a/plugins/MacAU/NCSeventeen/NCSeventeen.xcodeproj/christopherjohnson.pbxuser b/plugins/MacAU/NCSeventeen/NCSeventeen.xcodeproj/christopherjohnson.pbxuser index f9c1f79..6f69541 100755 --- a/plugins/MacAU/NCSeventeen/NCSeventeen.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacAU/NCSeventeen/NCSeventeen.xcodeproj/christopherjohnson.pbxuser @@ -49,43 +49,43 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 531741948; - PBXWorkspaceStateSaveDate = 531741948; + PBXPerProjectTemplateStateSaveDate = 569651037; + PBXWorkspaceStateSaveDate = 569651037; }; perUserProjectItems = { - 8B66929D1FA3B6DF007B3434 /* PBXTextBookmark */ = 8B66929D1FA3B6DF007B3434 /* PBXTextBookmark */; - 8B6692BF1FB1BEBD007B3434 /* PBXTextBookmark */ = 8B6692BF1FB1BEBD007B3434 /* PBXTextBookmark */; + 8B792E2D21F42FE2006E9731 /* PBXTextBookmark */ = 8B792E2D21F42FE2006E9731 /* PBXTextBookmark */; + 8B792E3221F43005006E9731 /* PBXTextBookmark */ = 8B792E3221F43005006E9731 /* PBXTextBookmark */; }; sourceControlManager = 8BD3CCB8148830B20062E48C /* Source Control */; userBuildSettings = { }; }; - 8B66929D1FA3B6DF007B3434 /* PBXTextBookmark */ = { + 8B792E2D21F42FE2006E9731 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 8BC6025B073B072D006C4272 /* NCSeventeen.h */; name = "NCSeventeen.h: 1"; rLen = 0; rLoc = 0; rType = 0; - vrLen = 47; + vrLen = 26; vrLoc = 0; }; - 8B6692BF1FB1BEBD007B3434 /* PBXTextBookmark */ = { + 8B792E3221F43005006E9731 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 8BC6025B073B072D006C4272 /* NCSeventeen.h */; name = "NCSeventeen.h: 1"; rLen = 0; rLoc = 0; rType = 0; - vrLen = 29; + vrLen = 26; vrLoc = 0; }; 8BA05A660720730100365D66 /* NCSeventeen.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {1098, 5460}}"; - sepNavSelRange = "{16304, 0}"; - sepNavVisRange = "{15087, 1879}"; - sepNavWindowFrame = "{{295, 66}, {1145, 812}}"; + sepNavIntBoundsRect = "{{0, 0}, {1098, 5317}}"; + sepNavSelRange = "{16560, 0}"; + sepNavVisRange = "{14728, 1968}"; + sepNavWindowFrame = "{{152, 66}, {1145, 812}}"; }; }; 8BA05A690720730100365D66 /* NCSeventeenVersion.h */ = { @@ -98,10 +98,10 @@ }; 8BC6025B073B072D006C4272 /* NCSeventeen.h */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {554, 1963}}"; + sepNavIntBoundsRect = "{{0, 0}, {554, 1937}}"; sepNavSelRange = "{0, 0}"; - sepNavVisRange = "{0, 29}"; - sepNavWindowFrame = "{{413, 43}, {1027, 835}}"; + sepNavVisRange = "{0, 26}"; + sepNavWindowFrame = "{{244, 43}, {1027, 835}}"; }; }; 8BD3CCB8148830B20062E48C /* Source Control */ = { diff --git a/plugins/MacAU/NCSeventeen/NCSeventeen.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacAU/NCSeventeen/NCSeventeen.xcodeproj/christopherjohnson.perspectivev3 index 8047d9f..b049979 100755 --- a/plugins/MacAU/NCSeventeen/NCSeventeen.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacAU/NCSeventeen/NCSeventeen.xcodeproj/christopherjohnson.perspectivev3 @@ -225,8 +225,8 @@ PerspectiveWidths - -1 - -1 + 810 + 810 Perspectives @@ -256,8 +256,6 @@ Layout - BecomeActive - ContentConfiguration PBXBottomSmartGroupGIDs @@ -300,7 +298,7 @@ PBXSmartGroupTreeModuleOutlineStateSelectionKey - 4 + 3 2 1 0 @@ -324,7 +322,7 @@ 185 RubberWindowFrame - 613 385 810 487 0 0 1440 878 + 460 371 810 487 0 0 1440 878 Module PBXSmartGroupTreeModule @@ -352,10 +350,10 @@ _historyCapacity 0 bookmark - 8B6692BF1FB1BEBD007B3434 + 8B792E3221F43005006E9731 history - 8B66929D1FA3B6DF007B3434 + 8B792E2D21F42FE2006E9731 SplitCount @@ -369,18 +367,18 @@ GeometryConfiguration Frame - {{0, 0}, {603, 69}} + {{0, 0}, {603, 51}} RubberWindowFrame - 613 385 810 487 0 0 1440 878 + 460 371 810 487 0 0 1440 878 Module PBXNavigatorGroup Proportion - 69pt + 51pt Proportion - 372pt + 390pt Tabs @@ -394,9 +392,7 @@ GeometryConfiguration Frame - {{10, 27}, {603, 345}} - RubberWindowFrame - 613 385 810 487 0 0 1440 878 + {{10, 27}, {603, 363}} Module XCDetailModule @@ -450,7 +446,9 @@ GeometryConfiguration Frame - {{10, 31}, {603, 297}} + {{10, 27}, {603, 363}} + RubberWindowFrame + 460 371 810 487 0 0 1440 878 Module PBXBuildResultsModule @@ -478,11 +476,11 @@ TableOfContents - 8B6692C01FB1BEBD007B3434 + 8B792E3321F43005006E9731 1CA23ED40692098700951B8B - 8B6692C11FB1BEBD007B3434 + 8B792E3421F43005006E9731 8B67C76A1FA2B03A008C64D6 - 8B6692C21FB1BEBD007B3434 + 8B792E3521F43005006E9731 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -635,7 +633,7 @@ StatusbarIsVisible TimeStamp - 531742397.05920899 + 569651205.03675902 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -652,11 +650,10 @@ 5 WindowOrderList - 8B6692C31FB1BEBD007B3434 /Users/christopherjohnson/Desktop/MacAU/NCSeventeen/NCSeventeen.xcodeproj WindowString - 613 385 810 487 0 0 1440 878 + 460 371 810 487 0 0 1440 878 WindowToolsV3 -- cgit v1.2.3