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 --- .../UnBox.xcodeproj/christopherjohnson.pbxuser | 27 +++++------ .../christopherjohnson.perspectivev3 | 28 +++++------ plugins/MacVST/UnBox/source/UnBoxProc.cpp | 54 ++++++++-------------- 3 files changed, 47 insertions(+), 62 deletions(-) (limited to 'plugins/MacVST/UnBox') diff --git a/plugins/MacVST/UnBox/UnBox.xcodeproj/christopherjohnson.pbxuser b/plugins/MacVST/UnBox/UnBox.xcodeproj/christopherjohnson.pbxuser index d840507..0fc18df 100755 --- a/plugins/MacVST/UnBox/UnBox.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacVST/UnBox/UnBox.xcodeproj/christopherjohnson.pbxuser @@ -49,12 +49,12 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 557535066; - PBXWorkspaceStateSaveDate = 557535066; + PBXPerProjectTemplateStateSaveDate = 569773466; + PBXWorkspaceStateSaveDate = 569773466; }; perUserProjectItems = { - 8B6DBA77213B59C900E44739 /* XCBuildMessageTextBookmark */ = 8B6DBA77213B59C900E44739 /* XCBuildMessageTextBookmark */; 8B6DBA78213B59C900E44739 /* PBXTextBookmark */ = 8B6DBA78213B59C900E44739 /* PBXTextBookmark */; + 8B7942AD21F60DA4006E9731 /* PBXTextBookmark */ = 8B7942AD21F60DA4006E9731 /* PBXTextBookmark */; }; sourceControlManager = 8B02375E1D42B1C400E1E8C8 /* Source Control */; userBuildSettings = { @@ -78,9 +78,9 @@ }; 24A2FFDB0F90D1DD003BB5A7 /* audioeffectx.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {838, 19747}}"; + sepNavIntBoundsRect = "{{0, 0}, {838, 19877}}"; sepNavSelRange = "{10616, 0}"; - sepNavVisRange = "{10459, 399}"; + sepNavVisRange = "{10459, 280}"; sepNavWindowFrame = "{{15, 42}, {895, 831}}"; }; }; @@ -106,23 +106,24 @@ isa = PBXCodeSenseManager; indexTemplatePath = ""; }; - 8B6DBA77213B59C900E44739 /* XCBuildMessageTextBookmark */ = { + 8B6DBA78213B59C900E44739 /* PBXTextBookmark */ = { isa = PBXTextBookmark; - comments = "Deprecated conversion from string constant to 'char*'"; fRef = 24A2FFDB0F90D1DD003BB5A7 /* audioeffectx.cpp */; - fallbackIsa = XCBuildMessageTextBookmark; - rLen = 1; - rLoc = 306; - rType = 1; + name = "audioeffectx.cpp: 307"; + rLen = 0; + rLoc = 10616; + rType = 0; + vrLen = 399; + vrLoc = 10459; }; - 8B6DBA78213B59C900E44739 /* PBXTextBookmark */ = { + 8B7942AD21F60DA4006E9731 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 24A2FFDB0F90D1DD003BB5A7 /* audioeffectx.cpp */; name = "audioeffectx.cpp: 307"; rLen = 0; rLoc = 10616; rType = 0; - vrLen = 399; + vrLen = 280; vrLoc = 10459; }; 8D01CCC60486CAD60068D4B7 /* UnBox */ = { diff --git a/plugins/MacVST/UnBox/UnBox.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacVST/UnBox/UnBox.xcodeproj/christopherjohnson.perspectivev3 index 6a3b9e1..d995ead 100755 --- a/plugins/MacVST/UnBox/UnBox.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacVST/UnBox/UnBox.xcodeproj/christopherjohnson.perspectivev3 @@ -256,6 +256,8 @@ Layout + BecomeActive + ContentConfiguration PBXBottomSmartGroupGIDs @@ -349,10 +351,10 @@ _historyCapacity 0 bookmark - 8B6DBA78213B59C900E44739 + 8B7942AD21F60DA4006E9731 history - 8B6DBA77213B59C900E44739 + 8B6DBA78213B59C900E44739 SplitCount @@ -366,18 +368,18 @@ GeometryConfiguration Frame - {{0, 0}, {603, 132}} + {{0, 0}, {603, 117}} RubberWindowFrame 64 284 810 487 0 0 1440 878 Module PBXNavigatorGroup Proportion - 132pt + 117pt Proportion - 309pt + 324pt Tabs @@ -391,7 +393,9 @@ GeometryConfiguration Frame - {{10, 27}, {603, 414}} + {{10, 27}, {603, 297}} + RubberWindowFrame + 64 284 810 487 0 0 1440 878 Module XCDetailModule @@ -446,8 +450,6 @@ Frame {{10, 27}, {603, 282}} - RubberWindowFrame - 64 284 810 487 0 0 1440 878 Module PBXBuildResultsModule @@ -475,11 +477,11 @@ TableOfContents - 8B6DBA79213B59C900E44739 + 8B7942AE21F60DA4006E9731 1CA23ED40692098700951B8B - 8B6DBA7A213B59C900E44739 + 8B7942AF21F60DA4006E9731 8B0237581D42B1C400E1E8C8 - 8B6DBA7B213B59C900E44739 + 8B7942B021F60DA4006E9731 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -632,7 +634,7 @@ StatusbarIsVisible TimeStamp - 557537737.84302604 + 569773476.89428103 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -649,7 +651,7 @@ 5 WindowOrderList - /Users/christopherjohnson/Desktop/UnBox/UnBox.xcodeproj + /Users/christopherjohnson/Desktop/MacVST/UnBox/UnBox.xcodeproj WindowString 64 284 810 487 0 0 1440 878 diff --git a/plugins/MacVST/UnBox/source/UnBoxProc.cpp b/plugins/MacVST/UnBox/source/UnBoxProc.cpp index 12133dc..3cb3aab 100755 --- a/plugins/MacVST/UnBox/source/UnBoxProc.cpp +++ b/plugins/MacVST/UnBox/source/UnBoxProc.cpp @@ -218,18 +218,14 @@ void UnBox::processReplacing(float **inputs, float **outputs, VstInt32 sampleFra if (output != 1.0) {inputSampleL *= output; inputSampleR *= output;} - //noise shaping to 32-bit floating point - float fpTemp = inputSampleL; - fpNShapeL += (inputSampleL-fpTemp); - inputSampleL += fpNShapeL; - //if this confuses you look at the wordlength for fpTemp :) - fpTemp = inputSampleR; - fpNShapeR += (inputSampleR-fpTemp); - inputSampleR += fpNShapeR; - //for deeper space and warmth, we try a non-oscillating noise shaping - //that is kind of ruthless: it will forever retain the rounding errors - //except we'll dial it back a hair at the end of every buffer processed - //end noise shaping on 32 bit output + //stereo 32 bit dither, made small and tidy. + int expon; frexpf((float)inputSampleL, &expon); + long double dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62); + inputSampleL += (dither-fpNShapeL); fpNShapeL = dither; + frexpf((float)inputSampleR, &expon); + dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62); + inputSampleR += (dither-fpNShapeR); fpNShapeR = dither; + //end 32 bit dither *out1 = inputSampleL; *out2 = inputSampleR; @@ -239,12 +235,6 @@ void UnBox::processReplacing(float **inputs, float **outputs, VstInt32 sampleFra *out1++; *out2++; } - fpNShapeL *= 0.999999; - fpNShapeR *= 0.999999; - //we will just delicately dial back the FP noise shaping, not even every sample - //this is a good place to put subtle 'no runaway' calculations, though bear in mind - //that it will be called more often when you use shorter sample buffers in the DAW. - //So, very low latency operation will call these calculations more often. } void UnBox::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames) @@ -458,18 +448,16 @@ void UnBox::processDoubleReplacing(double **inputs, double **outputs, VstInt32 s if (output != 1.0) {inputSampleL *= output; inputSampleR *= output;} - //noise shaping to 64-bit floating point - double fpTemp = inputSampleL; - fpNShapeL += (inputSampleL-fpTemp); - inputSampleL += fpNShapeL; - //if this confuses you look at the wordlength for fpTemp :) - fpTemp = inputSampleR; - fpNShapeR += (inputSampleR-fpTemp); - inputSampleR += fpNShapeR; - //for deeper space and warmth, we try a non-oscillating noise shaping - //that is kind of ruthless: it will forever retain the rounding errors - //except we'll dial it back a hair at the end of every buffer processed - //end noise shaping on 64 bit output + //stereo 64 bit dither, made small and tidy. + int expon; frexp((double)inputSampleL, &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 + inputSampleL += (dither-fpNShapeL); fpNShapeL = dither; + frexp((double)inputSampleR, &expon); + dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62); + dither /= 536870912.0; //needs this to scale to 64 bit zone + inputSampleR += (dither-fpNShapeR); fpNShapeR = dither; + //end 64 bit dither *out1 = inputSampleL; *out2 = inputSampleR; @@ -479,10 +467,4 @@ void UnBox::processDoubleReplacing(double **inputs, double **outputs, VstInt32 s *out1++; *out2++; } - fpNShapeL *= 0.999999; - fpNShapeR *= 0.999999; - //we will just delicately dial back the FP noise shaping, not even every sample - //this is a good place to put subtle 'no runaway' calculations, though bear in mind - //that it will be called more often when you use shorter sample buffers in the DAW. - //So, very low latency operation will call these calculations more often. } -- cgit v1.2.3