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 | 42 ++++++++--------- .../christopherjohnson.perspectivev3 | 26 +++++------ .../MacVST/ButterComp2/source/ButterComp2Proc.cpp | 54 ++++++++-------------- 3 files changed, 52 insertions(+), 70 deletions(-) (limited to 'plugins/MacVST/ButterComp2') diff --git a/plugins/MacVST/ButterComp2/ButterComp2.xcodeproj/christopherjohnson.pbxuser b/plugins/MacVST/ButterComp2/ButterComp2.xcodeproj/christopherjohnson.pbxuser index e8a1ebf..26154bb 100755 --- a/plugins/MacVST/ButterComp2/ButterComp2.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacVST/ButterComp2/ButterComp2.xcodeproj/christopherjohnson.pbxuser @@ -49,14 +49,14 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 559961907; - PBXWorkspaceStateSaveDate = 559961907; + PBXPerProjectTemplateStateSaveDate = 569718749; + PBXWorkspaceStateSaveDate = 569718749; }; perUserProjectItems = { - 8B42FDBF216057860092969A /* PBXTextBookmark */ = 8B42FDBF216057860092969A /* PBXTextBookmark */; 8B42FDC0216057860092969A /* PBXTextBookmark */ = 8B42FDC0216057860092969A /* PBXTextBookmark */; - 8B42FDC4216057860092969A /* PBXTextBookmark */ = 8B42FDC4216057860092969A /* PBXTextBookmark */; 8B42FDC5216057860092969A /* PBXTextBookmark */ = 8B42FDC5216057860092969A /* PBXTextBookmark */; + 8B7934F221F537F3006E9731 /* PBXTextBookmark */ = 8B7934F221F537F3006E9731 /* PBXTextBookmark */; + 8B7934F621F537F3006E9731 /* PBXTextBookmark */ = 8B7934F621F537F3006E9731 /* PBXTextBookmark */; }; sourceControlManager = 8B02375E1D42B1C400E1E8C8 /* Source Control */; userBuildSettings = { @@ -88,9 +88,9 @@ }; 24D8286F09A914000093AEF8 /* ButterComp2Proc.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {848, 6643}}"; + sepNavIntBoundsRect = "{{0, 0}, {848, 6292}}"; sepNavSelRange = "{7880, 0}"; - sepNavVisRange = "{7074, 1753}"; + sepNavVisRange = "{7052, 1652}"; sepNavWindowFrame = "{{394, 47}, {895, 831}}"; }; }; @@ -108,7 +108,7 @@ isa = PBXCodeSenseManager; indexTemplatePath = ""; }; - 8B42FDBF216057860092969A /* PBXTextBookmark */ = { + 8B42FDC0216057860092969A /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 24D8286F09A914000093AEF8 /* ButterComp2Proc.cpp */; name = "ButterComp2Proc.cpp: 382"; @@ -116,37 +116,37 @@ rLoc = 11279; rType = 0; vrLen = 322; - vrLoc = 11165; + vrLoc = 11177; }; - 8B42FDC0216057860092969A /* PBXTextBookmark */ = { + 8B42FDC5216057860092969A /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 24D8286F09A914000093AEF8 /* ButterComp2Proc.cpp */; - name = "ButterComp2Proc.cpp: 382"; + name = "ButterComp2Proc.cpp: 268"; rLen = 0; - rLoc = 11279; + rLoc = 7880; rType = 0; - vrLen = 322; - vrLoc = 11177; + vrLen = 1753; + vrLoc = 7074; }; - 8B42FDC4216057860092969A /* PBXTextBookmark */ = { + 8B7934F221F537F3006E9731 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 24D8286F09A914000093AEF8 /* ButterComp2Proc.cpp */; - name = "ButterComp2Proc.cpp: 382"; + name = "ButterComp2Proc.cpp: 387"; rLen = 0; rLoc = 11279; rType = 0; - vrLen = 1480; - vrLoc = 10666; + vrLen = 365; + vrLoc = 6402; }; - 8B42FDC5216057860092969A /* PBXTextBookmark */ = { + 8B7934F621F537F3006E9731 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 24D8286F09A914000093AEF8 /* ButterComp2Proc.cpp */; - name = "ButterComp2Proc.cpp: 268"; + name = "ButterComp2Proc.cpp: 278"; rLen = 0; rLoc = 7880; rType = 0; - vrLen = 1753; - vrLoc = 7074; + vrLen = 1652; + vrLoc = 7052; }; 8D01CCC60486CAD60068D4B7 /* ButterComp2 */ = { activeExec = 0; diff --git a/plugins/MacVST/ButterComp2/ButterComp2.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacVST/ButterComp2/ButterComp2.xcodeproj/christopherjohnson.perspectivev3 index 67bfac5..4fb4fe4 100755 --- a/plugins/MacVST/ButterComp2/ButterComp2.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacVST/ButterComp2/ButterComp2.xcodeproj/christopherjohnson.perspectivev3 @@ -241,10 +241,10 @@ _historyCapacity 0 bookmark - 8B42FDC5216057860092969A + 8B7934F621F537F3006E9731 history - 8B42FDC4216057860092969A + 8B42FDC5216057860092969A SplitCount @@ -392,10 +392,10 @@ _historyCapacity 0 bookmark - 8B42FDC0216057860092969A + 8B7934F221F537F3006E9731 history - 8B42FDBF216057860092969A + 8B42FDC0216057860092969A SplitCount @@ -409,18 +409,18 @@ GeometryConfiguration Frame - {{0, 0}, {603, 132}} + {{0, 0}, {603, 117}} RubberWindowFrame 138 241 810 487 0 0 1440 878 Module PBXNavigatorGroup Proportion - 132pt + 117pt Proportion - 309pt + 324pt Tabs @@ -434,7 +434,7 @@ GeometryConfiguration Frame - {{10, 27}, {603, 282}} + {{10, 27}, {603, 297}} RubberWindowFrame 138 241 810 487 0 0 1440 878 @@ -518,11 +518,11 @@ TableOfContents - 8B42FDC1216057860092969A + 8B7934F321F537F3006E9731 1CA23ED40692098700951B8B - 8B42FDC2216057860092969A + 8B7934F421F537F3006E9731 8B0237581D42B1C400E1E8C8 - 8B42FDC3216057860092969A + 8B7934F521F537F3006E9731 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -675,7 +675,7 @@ StatusbarIsVisible TimeStamp - 559961990.80278695 + 569718771.40327895 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -693,7 +693,7 @@ WindowOrderList 8B42FD99216056C30092969A - /Users/christopherjohnson/Desktop/ButterComp2/ButterComp2.xcodeproj + /Users/christopherjohnson/Desktop/MacVST/ButterComp2/ButterComp2.xcodeproj WindowString 138 241 810 487 0 0 1440 878 diff --git a/plugins/MacVST/ButterComp2/source/ButterComp2Proc.cpp b/plugins/MacVST/ButterComp2/source/ButterComp2Proc.cpp index 55ce488..67a6367 100755 --- a/plugins/MacVST/ButterComp2/source/ButterComp2Proc.cpp +++ b/plugins/MacVST/ButterComp2/source/ButterComp2Proc.cpp @@ -223,18 +223,14 @@ void ButterComp2::processReplacing(float **inputs, float **outputs, VstInt32 sam flip = !flip; - //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; @@ -244,12 +240,6 @@ void ButterComp2::processReplacing(float **inputs, float **outputs, VstInt32 sam *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 ButterComp2::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames) @@ -468,18 +458,16 @@ void ButterComp2::processDoubleReplacing(double **inputs, double **outputs, VstI flip = !flip; - //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; @@ -489,10 +477,4 @@ void ButterComp2::processDoubleReplacing(double **inputs, double **outputs, VstI *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