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 --- .../christopherjohnson.pbxuser | 26 +++++++++++----------- .../christopherjohnson.perspectivev3 | 24 +++++++++++--------- plugins/MacVST/BitGlitter/source/BitGlitter.cpp | 3 +++ plugins/MacVST/BitGlitter/source/BitGlitter.h | 3 +++ .../MacVST/BitGlitter/source/BitGlitterProc.cpp | 19 ++++++++++++++++ 5 files changed, 51 insertions(+), 24 deletions(-) (limited to 'plugins/MacVST/BitGlitter') diff --git a/plugins/MacVST/BitGlitter/BitGlitter.xcodeproj/christopherjohnson.pbxuser b/plugins/MacVST/BitGlitter/BitGlitter.xcodeproj/christopherjohnson.pbxuser index 04c5006..eadf6da 100755 --- a/plugins/MacVST/BitGlitter/BitGlitter.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacVST/BitGlitter/BitGlitter.xcodeproj/christopherjohnson.pbxuser @@ -51,8 +51,8 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 553994307; - PBXWorkspaceStateSaveDate = 553994307; + PBXPerProjectTemplateStateSaveDate = 569718310; + PBXWorkspaceStateSaveDate = 569718310; }; sourceControlManager = 8B02375E1D42B1C400E1E8C8 /* Source Control */; userBuildSettings = { @@ -60,17 +60,17 @@ }; 2407DEB6089929BA00EB68BF /* BitGlitter.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {848, 2249}}"; - sepNavSelRange = "{842, 0}"; - sepNavVisRange = "{1388, 1919}"; - sepNavWindowFrame = "{{891, 27}, {895, 831}}"; + sepNavIntBoundsRect = "{{0, 0}, {848, 2158}}"; + sepNavSelRange = "{533, 0}"; + sepNavVisRange = "{0, 1600}"; + sepNavWindowFrame = "{{333, 47}, {895, 831}}"; }; }; 245463B80991757100464AD3 /* BitGlitter.h */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {866, 1118}}"; - sepNavSelRange = "{2943, 0}"; - sepNavVisRange = "{652, 2357}"; + sepNavIntBoundsRect = "{{0, 0}, {866, 1157}}"; + sepNavSelRange = "{2511, 0}"; + sepNavVisRange = "{652, 2399}"; sepNavWindowFrame = "{{20, 47}, {895, 831}}"; }; }; @@ -84,10 +84,10 @@ }; 24D8286F09A914000093AEF8 /* BitGlitterProc.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {848, 5200}}"; - sepNavSelRange = "{7162, 0}"; - sepNavVisRange = "{6302, 1605}"; - sepNavWindowFrame = "{{37, 33}, {895, 831}}"; + sepNavIntBoundsRect = "{{0, 0}, {848, 5902}}"; + sepNavSelRange = "{13421, 0}"; + sepNavVisRange = "{11871, 1722}"; + sepNavWindowFrame = "{{169, 47}, {895, 831}}"; }; }; 8B02375E1D42B1C400E1E8C8 /* Source Control */ = { diff --git a/plugins/MacVST/BitGlitter/BitGlitter.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacVST/BitGlitter/BitGlitter.xcodeproj/christopherjohnson.perspectivev3 index 9b744d3..b2c5d8c 100755 --- a/plugins/MacVST/BitGlitter/BitGlitter.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacVST/BitGlitter/BitGlitter.xcodeproj/christopherjohnson.perspectivev3 @@ -256,6 +256,8 @@ Layout + BecomeActive + ContentConfiguration PBXBottomSmartGroupGIDs @@ -298,7 +300,7 @@ PBXSmartGroupTreeModuleOutlineStateSelectionKey - 5 + 6 4 0 @@ -321,7 +323,7 @@ 185 RubberWindowFrame - 129 148 810 487 0 0 1440 878 + 144 271 810 487 0 0 1440 878 Module PBXSmartGroupTreeModule @@ -360,7 +362,7 @@ Frame {{0, 0}, {603, 0}} RubberWindowFrame - 129 148 810 487 0 0 1440 878 + 144 271 810 487 0 0 1440 878 Module PBXNavigatorGroup @@ -384,6 +386,8 @@ Frame {{10, 27}, {603, 414}} + RubberWindowFrame + 144 271 810 487 0 0 1440 878 Module XCDetailModule @@ -438,8 +442,6 @@ Frame {{10, 27}, {603, 414}} - RubberWindowFrame - 129 148 810 487 0 0 1440 878 Module PBXBuildResultsModule @@ -467,11 +469,11 @@ TableOfContents - 8BBD19152105484B0015A233 + 8B79347521F5371F006E9731 1CA23ED40692098700951B8B - 8BBD19162105484B0015A233 + 8B79347621F5371F006E9731 8B0237581D42B1C400E1E8C8 - 8BBD19172105484B0015A233 + 8B79347721F5371F006E9731 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -644,7 +646,7 @@ StatusbarIsVisible TimeStamp - 553998201.254879 + 569718559.741974 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -661,10 +663,10 @@ 5 WindowOrderList - /Users/christopherjohnson/Desktop/BitGlitter/BitGlitter.xcodeproj + /Users/christopherjohnson/Desktop/MacVST/BitGlitter/BitGlitter.xcodeproj WindowString - 129 148 810 487 0 0 1440 878 + 144 271 810 487 0 0 1440 878 WindowToolsV3 diff --git a/plugins/MacVST/BitGlitter/source/BitGlitter.cpp b/plugins/MacVST/BitGlitter/source/BitGlitter.cpp index 7e9cfdb..a1e1a9b 100755 --- a/plugins/MacVST/BitGlitter/source/BitGlitter.cpp +++ b/plugins/MacVST/BitGlitter/source/BitGlitter.cpp @@ -17,6 +17,9 @@ BitGlitter::BitGlitter(audioMasterCallback audioMaster) : C = 0.5; D = 1.0; + fpNShapeL = 0.0; + fpNShapeR = 0.0; + ataLastSampleL = 0.0; ataHalfwaySampleL = 0.0; lastSampleL = 0.0; diff --git a/plugins/MacVST/BitGlitter/source/BitGlitter.h b/plugins/MacVST/BitGlitter/source/BitGlitter.h index d87e277..4f108cd 100755 --- a/plugins/MacVST/BitGlitter/source/BitGlitter.h +++ b/plugins/MacVST/BitGlitter/source/BitGlitter.h @@ -55,6 +55,9 @@ private: char _programName[kVstMaxProgNameLen + 1]; std::set< std::string > _canDo; + long double fpNShapeL; + long double fpNShapeR; + double ataLastSampleL; double ataHalfwaySampleL; double ataDrySampleL; diff --git a/plugins/MacVST/BitGlitter/source/BitGlitterProc.cpp b/plugins/MacVST/BitGlitter/source/BitGlitterProc.cpp index 321d0b6..ff2968c 100755 --- a/plugins/MacVST/BitGlitter/source/BitGlitterProc.cpp +++ b/plugins/MacVST/BitGlitter/source/BitGlitterProc.cpp @@ -202,6 +202,14 @@ void BitGlitter::processReplacing(float **inputs, float **outputs, VstInt32 samp outputSampleL = (drySampleL * (1.0-wet)) + (outputSampleL * wet); outputSampleR = (drySampleR * (1.0-wet)) + (outputSampleR * wet); } + //stereo 32 bit dither, made small and tidy. + int expon; frexpf((float)outputSampleL, &expon); + long double dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62); + outputSampleL += (dither-fpNShapeL); fpNShapeL = dither; + frexpf((float)outputSampleR, &expon); + dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62); + outputSampleR += (dither-fpNShapeR); fpNShapeR = dither; + //end 32 bit dither *out1 = outputSampleL; *out2 = outputSampleR; @@ -408,6 +416,17 @@ void BitGlitter::processDoubleReplacing(double **inputs, double **outputs, VstIn outputSampleR = (drySampleR * (1.0-wet)) + (outputSampleR * wet); } + //stereo 64 bit dither, made small and tidy. + int expon; frexp((double)outputSampleL, &expon); + long double dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62); + dither /= 536870912.0; //needs this to scale to 64 bit zone + outputSampleL += (dither-fpNShapeL); fpNShapeL = dither; + frexp((double)outputSampleR, &expon); + dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62); + dither /= 536870912.0; //needs this to scale to 64 bit zone + outputSampleR += (dither-fpNShapeR); fpNShapeR = dither; + //end 64 bit dither + *out1 = outputSampleL; *out2 = outputSampleR; -- cgit v1.2.3