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 --- .../Spiral2.xcodeproj/christopherjohnson.pbxuser | 43 +++++++++-------- .../christopherjohnson.perspectivev3 | 38 +++++++-------- plugins/MacVST/Spiral2/source/Spiral2Proc.cpp | 54 ++++++++-------------- 3 files changed, 63 insertions(+), 72 deletions(-) (limited to 'plugins/MacVST/Spiral2') diff --git a/plugins/MacVST/Spiral2/Spiral2.xcodeproj/christopherjohnson.pbxuser b/plugins/MacVST/Spiral2/Spiral2.xcodeproj/christopherjohnson.pbxuser index 998d404..73c6829 100755 --- a/plugins/MacVST/Spiral2/Spiral2.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacVST/Spiral2/Spiral2.xcodeproj/christopherjohnson.pbxuser @@ -49,12 +49,12 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 553978416; - PBXWorkspaceStateSaveDate = 553978416; + PBXPerProjectTemplateStateSaveDate = 569772566; + PBXWorkspaceStateSaveDate = 569772566; }; perUserProjectItems = { - 8BBD182B21050DB30015A233 /* PBXBookmark */ = 8BBD182B21050DB30015A233 /* PBXBookmark */; - 8BBD1834210525AC0015A233 /* XCBuildMessageTextBookmark */ = 8BBD1834210525AC0015A233 /* XCBuildMessageTextBookmark */; + 8B79404021F60A24006E9731 /* PBXTextBookmark */ = 8B79404021F60A24006E9731 /* PBXTextBookmark */; + 8B79404421F60A24006E9731 /* PBXTextBookmark */ = 8B79404421F60A24006E9731 /* PBXTextBookmark */; 8BBD1835210525AC0015A233 /* PBXTextBookmark */ = 8BBD1835210525AC0015A233 /* PBXTextBookmark */; 8BBD1838210525AC0015A233 /* PBXTextBookmark */ = 8BBD1838210525AC0015A233 /* PBXTextBookmark */; }; @@ -80,17 +80,17 @@ }; 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}}"; }; }; 24D8286F09A914000093AEF8 /* Spiral2Proc.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {866, 3913}}"; + sepNavIntBoundsRect = "{{0, 0}, {866, 3497}}"; sepNavSelRange = "{8913, 0}"; - sepNavVisRange = "{6147, 2094}"; + sepNavVisRange = "{3322, 1681}"; sepNavWindowFrame = "{{18, 47}, {895, 831}}"; }; }; @@ -108,18 +108,25 @@ isa = PBXCodeSenseManager; indexTemplatePath = ""; }; - 8BBD182B21050DB30015A233 /* PBXBookmark */ = { - isa = PBXBookmark; - fRef = 24D8286F09A914000093AEF8 /* Spiral2Proc.cpp */; - }; - 8BBD1834210525AC0015A233 /* XCBuildMessageTextBookmark */ = { + 8B79404021F60A24006E9731 /* 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 = 280; + vrLoc = 10459; + }; + 8B79404421F60A24006E9731 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 24D8286F09A914000093AEF8 /* Spiral2Proc.cpp */; + name = "Spiral2Proc.cpp: 260"; + rLen = 0; + rLoc = 8913; + rType = 0; + vrLen = 1681; + vrLoc = 3322; }; 8BBD1835210525AC0015A233 /* PBXTextBookmark */ = { isa = PBXTextBookmark; diff --git a/plugins/MacVST/Spiral2/Spiral2.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacVST/Spiral2/Spiral2.xcodeproj/christopherjohnson.perspectivev3 index 376de96..08c20ea 100755 --- a/plugins/MacVST/Spiral2/Spiral2.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacVST/Spiral2/Spiral2.xcodeproj/christopherjohnson.perspectivev3 @@ -241,10 +241,10 @@ _historyCapacity 0 bookmark - 8BBD1838210525AC0015A233 + 8B79404421F60A24006E9731 history - 8BBD182B21050DB30015A233 + 8BBD1838210525AC0015A233 SplitCount @@ -297,6 +297,8 @@ Layout + BecomeActive + ContentConfiguration PBXBottomSmartGroupGIDs @@ -362,7 +364,7 @@ 185 RubberWindowFrame - 5 340 810 487 0 0 1440 878 + 432 361 810 487 0 0 1440 878 Module PBXSmartGroupTreeModule @@ -390,10 +392,10 @@ _historyCapacity 0 bookmark - 8BBD1835210525AC0015A233 + 8B79404021F60A24006E9731 history - 8BBD1834210525AC0015A233 + 8BBD1835210525AC0015A233 SplitCount @@ -407,18 +409,18 @@ GeometryConfiguration Frame - {{0, 0}, {603, 132}} + {{0, 0}, {603, 117}} RubberWindowFrame - 5 340 810 487 0 0 1440 878 + 432 361 810 487 0 0 1440 878 Module PBXNavigatorGroup Proportion - 132pt + 117pt Proportion - 309pt + 324pt Tabs @@ -432,7 +434,9 @@ GeometryConfiguration Frame - {{10, 27}, {603, 414}} + {{10, 27}, {603, 297}} + RubberWindowFrame + 432 361 810 487 0 0 1440 878 Module XCDetailModule @@ -487,8 +491,6 @@ Frame {{10, 27}, {603, 282}} - RubberWindowFrame - 5 340 810 487 0 0 1440 878 Module PBXBuildResultsModule @@ -516,11 +518,11 @@ TableOfContents - 8BBD181021050A370015A233 + 8B79404121F60A24006E9731 1CA23ED40692098700951B8B - 8BBD181121050A370015A233 + 8B79404221F60A24006E9731 8B0237581D42B1C400E1E8C8 - 8BBD181221050A370015A233 + 8B79404321F60A24006E9731 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -673,7 +675,7 @@ StatusbarIsVisible TimeStamp - 553985452.30988598 + 569772580.33098996 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -691,10 +693,10 @@ WindowOrderList 8BBD1836210525AC0015A233 - /Users/christopherjohnson/Desktop/Spiral2/Spiral2.xcodeproj + /Users/christopherjohnson/Desktop/MacVST/Spiral2/Spiral2.xcodeproj WindowString - 5 340 810 487 0 0 1440 878 + 432 361 810 487 0 0 1440 878 WindowToolsV3 diff --git a/plugins/MacVST/Spiral2/source/Spiral2Proc.cpp b/plugins/MacVST/Spiral2/source/Spiral2Proc.cpp index d309448..a8669c5 100755 --- a/plugins/MacVST/Spiral2/source/Spiral2Proc.cpp +++ b/plugins/MacVST/Spiral2/source/Spiral2Proc.cpp @@ -118,18 +118,14 @@ void Spiral2::processReplacing(float **inputs, float **outputs, VstInt32 sampleF prevSampleR = drySampleR; 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; @@ -139,12 +135,6 @@ void Spiral2::processReplacing(float **inputs, float **outputs, VstInt32 sampleF *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 Spiral2::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames) @@ -259,18 +249,16 @@ void Spiral2::processDoubleReplacing(double **inputs, double **outputs, VstInt32 prevSampleR = drySampleR; 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; @@ -280,10 +268,4 @@ void Spiral2::processDoubleReplacing(double **inputs, double **outputs, VstInt32 *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