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/IronOxide5/IronOxide5.cpp | 30 +++++---------------- plugins/MacAU/IronOxide5/IronOxide5.h | 7 +---- .../christopherjohnson.pbxuser | 28 +++++++++---------- .../christopherjohnson.perspectivev3 | 31 ++++++++++------------ 4 files changed, 36 insertions(+), 60 deletions(-) (limited to 'plugins/MacAU/IronOxide5') diff --git a/plugins/MacAU/IronOxide5/IronOxide5.cpp b/plugins/MacAU/IronOxide5/IronOxide5.cpp index f0c27dd..c64d19a 100755 --- a/plugins/MacAU/IronOxide5/IronOxide5.cpp +++ b/plugins/MacAU/IronOxide5/IronOxide5.cpp @@ -224,9 +224,7 @@ void IronOxide5::IronOxide5Kernel::Reset() sweep = 0.0; rateof = 0.5; nextmax = 0.5; - fpNShapeA = 0.0; - fpNShapeB = 0.0; - fpFlip = true; + fpNShape = 0.0; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -288,11 +286,6 @@ void IronOxide5::IronOxide5Kernel::Process( const Float32 *inSourceP, Float64 dry = 1.0; if (invdrywet > 0.0) dry -= invdrywet; - Float32 fpTemp; - Float64 fpOld = 0.618033988749894848204586; //golden ratio! - Float64 fpNew = 1.0 - fpOld; - - while (nSampleFrames-- > 0) { inputSample = *sourceP; if (inputSample<1.2e-38 && -inputSample<1.2e-38) { @@ -475,7 +468,7 @@ void IronOxide5::IronOxide5Kernel::Process( const Float32 *inSourceP, inputSample += (prevInputSample*randy); prevInputSample = drySample; - flip = not flip; + flip = !flip; //begin invdrywet block with outputgain if (outputgain != 1.0) inputSample *= outputgain; @@ -484,23 +477,14 @@ void IronOxide5::IronOxide5Kernel::Process( const Float32 *inSourceP, if (fabs(drySample) > 0.0) inputSample += drySample; //end invdrywet block with outputgain - //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 + //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; - sourceP += inNumChannels; destP += inNumChannels; } } diff --git a/plugins/MacAU/IronOxide5/IronOxide5.h b/plugins/MacAU/IronOxide5/IronOxide5.h index 2b0b16e..2b3c655 100755 --- a/plugins/MacAU/IronOxide5/IronOxide5.h +++ b/plugins/MacAU/IronOxide5/IronOxide5.h @@ -167,13 +167,8 @@ public: Float64 rateof; Float64 sweep; Float64 nextmax; - - long double fpNShapeA; - long double fpNShapeB; - bool fpFlip; - + long double fpNShape; bool flip; - int demotimer; }; }; diff --git a/plugins/MacAU/IronOxide5/IronOxide5.xcodeproj/christopherjohnson.pbxuser b/plugins/MacAU/IronOxide5/IronOxide5.xcodeproj/christopherjohnson.pbxuser index 0cb3aa0..8cbc973 100755 --- a/plugins/MacAU/IronOxide5/IronOxide5.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacAU/IronOxide5/IronOxide5.xcodeproj/christopherjohnson.pbxuser @@ -49,18 +49,18 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 528456633; - PBXWorkspaceStateSaveDate = 528456633; + PBXPerProjectTemplateStateSaveDate = 569649559; + PBXWorkspaceStateSaveDate = 569649559; }; perUserProjectItems = { - 8B9D65541F7C89D7007AB60F /* PlistBookmark */ = 8B9D65541F7C89D7007AB60F /* PlistBookmark */; + 8B792D9121F42A46006E9731 /* PlistBookmark */ = 8B792D9121F42A46006E9731 /* PlistBookmark */; 8B9D74A51F7F9BC2007AB60F /* PlistBookmark */ = 8B9D74A51F7F9BC2007AB60F /* PlistBookmark */; }; sourceControlManager = 8BD3CCB8148830B20062E48C /* Source Control */; userBuildSettings = { }; }; - 8B9D65541F7C89D7007AB60F /* PlistBookmark */ = { + 8B792D9121F42A46006E9731 /* PlistBookmark */ = { isa = PlistBookmark; fRef = 8D01CCD10486CAD60068D4B7 /* Info.plist */; fallbackIsa = PBXBookmark; @@ -70,7 +70,7 @@ ); name = /Users/christopherjohnson/Desktop/MacAU/IronOxide5/Info.plist; rLen = 0; - rLoc = 9223372036854775808; + rLoc = 9223372036854775807; }; 8B9D74A51F7F9BC2007AB60F /* PlistBookmark */ = { isa = PlistBookmark; @@ -82,14 +82,14 @@ ); name = /Users/christopherjohnson/Desktop/MacAU/IronOxide5/Info.plist; rLen = 0; - rLoc = 9223372036854775807; + rLoc = 9223372036854775808; }; 8BA05A660720730100365D66 /* IronOxide5.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {1006, 6552}}"; - sepNavSelRange = "{13026, 0}"; - sepNavVisRange = "{12449, 2393}"; - sepNavWindowFrame = "{{387, 39}, {1053, 839}}"; + sepNavIntBoundsRect = "{{0, 0}, {1006, 7072}}"; + sepNavSelRange = "{19392, 0}"; + sepNavVisRange = "{17695, 1759}"; + sepNavWindowFrame = "{{237, 39}, {1053, 839}}"; }; }; 8BA05A690720730100365D66 /* IronOxide5Version.h */ = { @@ -102,10 +102,10 @@ }; 8BC6025B073B072D006C4272 /* IronOxide5.h */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {1006, 2327}}"; - sepNavSelRange = "{3959, 0}"; - sepNavVisRange = "{4993, 1457}"; - sepNavWindowFrame = "{{387, 39}, {1053, 839}}"; + sepNavIntBoundsRect = "{{0, 0}, {1006, 2535}}"; + sepNavSelRange = "{6418, 0}"; + sepNavVisRange = "{5321, 1207}"; + sepNavWindowFrame = "{{130, 39}, {1053, 839}}"; }; }; 8BD3CCB8148830B20062E48C /* Source Control */ = { diff --git a/plugins/MacAU/IronOxide5/IronOxide5.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacAU/IronOxide5/IronOxide5.xcodeproj/christopherjohnson.perspectivev3 index e2992e0..fd0036a 100755 --- a/plugins/MacAU/IronOxide5/IronOxide5.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacAU/IronOxide5/IronOxide5.xcodeproj/christopherjohnson.perspectivev3 @@ -225,8 +225,8 @@ PerspectiveWidths - 841 - 841 + 826 + 826 Perspectives @@ -256,8 +256,6 @@ Layout - BecomeActive - ContentConfiguration PBXBottomSmartGroupGIDs @@ -325,7 +323,7 @@ 288 RubberWindowFrame - 607 110 826 502 0 0 1440 878 + 386 241 826 502 0 0 1440 878 Module PBXSmartGroupTreeModule @@ -353,10 +351,10 @@ _historyCapacity 0 bookmark - 8B9D74A51F7F9BC2007AB60F + 8B792D9121F42A46006E9731 history - 8B9D65541F7C89D7007AB60F + 8B9D74A51F7F9BC2007AB60F SplitCount @@ -372,7 +370,7 @@ Frame {{0, 0}, {516, 0}} RubberWindowFrame - 607 110 826 502 0 0 1440 878 + 386 241 826 502 0 0 1440 878 Module PBXNavigatorGroup @@ -396,8 +394,6 @@ Frame {{10, 27}, {516, 429}} - RubberWindowFrame - 607 110 826 502 0 0 1440 878 Module XCDetailModule @@ -451,7 +447,9 @@ GeometryConfiguration Frame - {{10, 27}, {531, 315}} + {{10, 27}, {516, 429}} + RubberWindowFrame + 386 241 826 502 0 0 1440 878 Module PBXBuildResultsModule @@ -479,11 +477,11 @@ TableOfContents - 8B9D74A61F7F9BC2007AB60F + 8B792D9221F42A46006E9731 1CA23ED40692098700951B8B - 8B9D74A71F7F9BC2007AB60F + 8B792D9321F42A46006E9731 8BD7274A1D46E5A5000176F0 - 8B9D74A81F7F9BC2007AB60F + 8B792D9421F42A46006E9731 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -656,7 +654,7 @@ StatusbarIsVisible TimeStamp - 528456642.85610998 + 569649734.80982804 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -673,11 +671,10 @@ 5 WindowOrderList - 8B9D74A91F7F9BC2007AB60F /Users/christopherjohnson/Desktop/MacAU/IronOxide5/IronOxide5.xcodeproj WindowString - 607 110 826 502 0 0 1440 878 + 386 241 826 502 0 0 1440 878 WindowToolsV3 -- cgit v1.2.3