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 --- .../MacAU/GuitarConditioner/GuitarConditioner.cpp | 25 ++++-------- .../MacAU/GuitarConditioner/GuitarConditioner.h | 3 +- .../christopherjohnson.pbxuser | 46 +++++++++++----------- .../christopherjohnson.perspectivev3 | 40 +++++++++---------- 4 files changed, 50 insertions(+), 64 deletions(-) (limited to 'plugins/MacAU/GuitarConditioner') diff --git a/plugins/MacAU/GuitarConditioner/GuitarConditioner.cpp b/plugins/MacAU/GuitarConditioner/GuitarConditioner.cpp index 232fd21..d3d23e6 100755 --- a/plugins/MacAU/GuitarConditioner/GuitarConditioner.cpp +++ b/plugins/MacAU/GuitarConditioner/GuitarConditioner.cpp @@ -150,8 +150,7 @@ ComponentResult GuitarConditioner::Initialize() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void GuitarConditioner::GuitarConditionerKernel::Reset() { - fpNShapeA = 0.0; - fpNShapeB = 0.0; + fpNShape = 0.0; fpFlip = true; lastSampleT = 0.0; lastSampleB = 0.0; //for Slews. T for treble, B for bass @@ -176,9 +175,6 @@ void GuitarConditioner::GuitarConditionerKernel::Process( const Float32 *inSou long double overallscale = 1.0; overallscale /= 44100.0; overallscale *= GetSampleRate(); - Float32 fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; long double inputSample; long double treble; long double bass; @@ -264,21 +260,14 @@ void GuitarConditioner::GuitarConditionerKernel::Process( const Float32 *inSou lastSampleB = bass; //bass slew inputSample = treble + bass; //final merge + fpFlip = !fpFlip; + //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 - //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 = not fpFlip; - //end noise shaping on 32 bit output *destP = inputSample; sourceP += inNumChannels; destP += inNumChannels; } diff --git a/plugins/MacAU/GuitarConditioner/GuitarConditioner.h b/plugins/MacAU/GuitarConditioner/GuitarConditioner.h index 834905f..4ad6669 100755 --- a/plugins/MacAU/GuitarConditioner/GuitarConditioner.h +++ b/plugins/MacAU/GuitarConditioner/GuitarConditioner.h @@ -121,8 +121,7 @@ public: virtual void Reset(); private: - long double fpNShapeA; - long double fpNShapeB; + long double fpNShape; bool fpFlip; Float64 lastSampleT; Float64 lastSampleB; //for Slews diff --git a/plugins/MacAU/GuitarConditioner/GuitarConditioner.xcodeproj/christopherjohnson.pbxuser b/plugins/MacAU/GuitarConditioner/GuitarConditioner.xcodeproj/christopherjohnson.pbxuser index 27ab557..34d863a 100755 --- a/plugins/MacAU/GuitarConditioner/GuitarConditioner.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacAU/GuitarConditioner/GuitarConditioner.xcodeproj/christopherjohnson.pbxuser @@ -49,14 +49,14 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 528456379; - PBXWorkspaceStateSaveDate = 528456379; + PBXPerProjectTemplateStateSaveDate = 569648041; + PBXWorkspaceStateSaveDate = 569648041; }; perUserProjectItems = { 8B3BE93A1D667DD60098F86C /* PBXTextBookmark */ = 8B3BE93A1D667DD60098F86C /* PBXTextBookmark */; 8B3BE93B1D667DD60098F86C /* PBXTextBookmark */ = 8B3BE93B1D667DD60098F86C /* PBXTextBookmark */; - 8B9D64EE1F7C8859007AB60F /* PBXTextBookmark */ = 8B9D64EE1F7C8859007AB60F /* PBXTextBookmark */; - 8B9D74491F7F9ACF007AB60F /* PBXTextBookmark */ = 8B9D74491F7F9ACF007AB60F /* PBXTextBookmark */; + 8B792CD321F42407006E9731 /* PBXTextBookmark */ = 8B792CD321F42407006E9731 /* PBXTextBookmark */; + 8B792CD921F42423006E9731 /* PBXTextBookmark */ = 8B792CD921F42423006E9731 /* PBXTextBookmark */; 8BC032BB1D6667CB0039F36E /* PlistBookmark */ = 8BC032BB1D6667CB0039F36E /* PlistBookmark */; }; sourceControlManager = 8BD3CCB8148830B20062E48C /* Source Control */; @@ -68,7 +68,7 @@ fRef = 8BC6025B073B072D006C4272 /* GuitarConditioner.h */; name = "GuitarConditioner.h: 126"; rLen = 0; - rLoc = 5114; + rLoc = 5088; rType = 0; vrLen = 474; vrLoc = 4808; @@ -83,32 +83,32 @@ vrLen = 405; vrLoc = 2608; }; - 8B9D64EE1F7C8859007AB60F /* PBXTextBookmark */ = { + 8B792CD321F42407006E9731 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 8BA05A660720730100365D66 /* GuitarConditioner.cpp */; - name = "GuitarConditioner.cpp: 281"; + name = "GuitarConditioner.cpp: 274"; rLen = 0; - rLoc = 11852; + rLoc = 11616; rType = 0; - vrLen = 523; - vrLoc = 10536; + vrLen = 476; + vrLoc = 10604; }; - 8B9D74491F7F9ACF007AB60F /* PBXTextBookmark */ = { + 8B792CD921F42423006E9731 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 8BA05A660720730100365D66 /* GuitarConditioner.cpp */; - name = "GuitarConditioner.cpp: 281"; + name = "GuitarConditioner.cpp: 271"; rLen = 0; - rLoc = 11852; + rLoc = 11616; rType = 0; - vrLen = 502; - vrLoc = 10557; + vrLen = 485; + vrLoc = 10548; }; 8BA05A660720730100365D66 /* GuitarConditioner.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {733, 3913}}"; - sepNavSelRange = "{11852, 0}"; - sepNavVisRange = "{10557, 502}"; - sepNavWindowFrame = "{{639, 40}, {801, 838}}"; + sepNavIntBoundsRect = "{{0, 0}, {733, 3744}}"; + sepNavSelRange = "{11616, 0}"; + sepNavVisRange = "{10548, 485}"; + sepNavWindowFrame = "{{377, 40}, {801, 838}}"; }; }; 8BA05A690720730100365D66 /* GuitarConditionerVersion.h */ = { @@ -133,10 +133,10 @@ }; 8BC6025B073B072D006C4272 /* GuitarConditioner.h */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {894, 1833}}"; - sepNavSelRange = "{5115, 167}"; - sepNavVisRange = "{3840, 1555}"; - sepNavWindowFrame = "{{684, 40}, {801, 838}}"; + sepNavIntBoundsRect = "{{0, 0}, {894, 1820}}"; + sepNavSelRange = "{5073, 0}"; + sepNavVisRange = "{3804, 1565}"; + sepNavWindowFrame = "{{458, 40}, {801, 838}}"; }; }; 8BD3CCB8148830B20062E48C /* Source Control */ = { diff --git a/plugins/MacAU/GuitarConditioner/GuitarConditioner.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacAU/GuitarConditioner/GuitarConditioner.xcodeproj/christopherjohnson.perspectivev3 index 9e238ca..1f67dae 100755 --- a/plugins/MacAU/GuitarConditioner/GuitarConditioner.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacAU/GuitarConditioner/GuitarConditioner.xcodeproj/christopherjohnson.perspectivev3 @@ -225,8 +225,8 @@ PerspectiveWidths - 810 - 810 + 841 + 841 Perspectives @@ -256,8 +256,6 @@ Layout - BecomeActive - ContentConfiguration PBXBottomSmartGroupGIDs @@ -325,7 +323,7 @@ 288 RubberWindowFrame - 598 208 841 654 0 0 1440 878 + 455 207 841 654 0 0 1440 878 Module PBXSmartGroupTreeModule @@ -353,13 +351,13 @@ _historyCapacity 0 bookmark - 8B9D74491F7F9ACF007AB60F + 8B792CD921F42423006E9731 history 8BC032BB1D6667CB0039F36E 8B3BE93A1D667DD60098F86C 8B3BE93B1D667DD60098F86C - 8B9D64EE1F7C8859007AB60F + 8B792CD321F42407006E9731 SplitCount @@ -373,18 +371,18 @@ GeometryConfiguration Frame - {{0, 0}, {531, 216}} + {{0, 0}, {531, 202}} RubberWindowFrame - 598 208 841 654 0 0 1440 878 + 455 207 841 654 0 0 1440 878 Module PBXNavigatorGroup Proportion - 216pt + 202pt Proportion - 392pt + 406pt Tabs @@ -398,9 +396,7 @@ GeometryConfiguration Frame - {{10, 27}, {531, 365}} - RubberWindowFrame - 598 208 841 654 0 0 1440 878 + {{10, 27}, {531, 379}} Module XCDetailModule @@ -454,7 +450,9 @@ GeometryConfiguration Frame - {{10, 31}, {603, 297}} + {{10, 27}, {531, 379}} + RubberWindowFrame + 455 207 841 654 0 0 1440 878 Module PBXBuildResultsModule @@ -482,11 +480,11 @@ TableOfContents - 8B9D744A1F7F9ACF007AB60F + 8B792CDA21F42423006E9731 1CA23ED40692098700951B8B - 8B9D744B1F7F9ACF007AB60F + 8B792CDB21F42423006E9731 8BD7274A1D46E5A5000176F0 - 8B9D744C1F7F9ACF007AB60F + 8B792CDC21F42423006E9731 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -659,7 +657,7 @@ StatusbarIsVisible TimeStamp - 528456399.548949 + 569648163.99752402 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -676,11 +674,11 @@ 5 WindowOrderList - 8B9D744D1F7F9ACF007AB60F + 8B792CDD21F42424006E9731 /Users/christopherjohnson/Desktop/MacAU/GuitarConditioner/GuitarConditioner.xcodeproj WindowString - 598 208 841 654 0 0 1440 878 + 455 207 841 654 0 0 1440 878 WindowToolsV3 -- cgit v1.2.3