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 | 27 +++++----- .../christopherjohnson.perspectivev3 | 28 +++++----- plugins/MacVST/HardVacuum/source/HardVacuum.cpp | 7 +-- plugins/MacVST/HardVacuum/source/HardVacuum.h | 7 +-- .../MacVST/HardVacuum/source/HardVacuumProc.cpp | 62 +++++++--------------- 5 files changed, 51 insertions(+), 80 deletions(-) (limited to 'plugins/MacVST/HardVacuum') diff --git a/plugins/MacVST/HardVacuum/HardVacuum.xcodeproj/christopherjohnson.pbxuser b/plugins/MacVST/HardVacuum/HardVacuum.xcodeproj/christopherjohnson.pbxuser index c302fa1..2dae48f 100755 --- a/plugins/MacVST/HardVacuum/HardVacuum.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacVST/HardVacuum/HardVacuum.xcodeproj/christopherjohnson.pbxuser @@ -49,12 +49,12 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 541823415; - PBXWorkspaceStateSaveDate = 541823415; + PBXPerProjectTemplateStateSaveDate = 569767859; + PBXWorkspaceStateSaveDate = 569767859; }; perUserProjectItems = { - 8B181A1A204B984700516BEE /* XCBuildMessageTextBookmark */ = 8B181A1A204B984700516BEE /* XCBuildMessageTextBookmark */; 8B181A1B204B984700516BEE /* PBXTextBookmark */ = 8B181A1B204B984700516BEE /* PBXTextBookmark */; + 8B793B5521F5F802006E9731 /* PBXTextBookmark */ = 8B793B5521F5F802006E9731 /* 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 = ""; }; - 8B181A1A204B984700516BEE /* XCBuildMessageTextBookmark */ = { + 8B181A1B204B984700516BEE /* 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; }; - 8B181A1B204B984700516BEE /* PBXTextBookmark */ = { + 8B793B5521F5F802006E9731 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 24A2FFDB0F90D1DD003BB5A7 /* audioeffectx.cpp */; name = "audioeffectx.cpp: 307"; rLen = 0; rLoc = 10616; rType = 0; - vrLen = 399; + vrLen = 280; vrLoc = 10459; }; 8D01CCC60486CAD60068D4B7 /* HardVacuum */ = { diff --git a/plugins/MacVST/HardVacuum/HardVacuum.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacVST/HardVacuum/HardVacuum.xcodeproj/christopherjohnson.perspectivev3 index eda5e23..b731835 100755 --- a/plugins/MacVST/HardVacuum/HardVacuum.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacVST/HardVacuum/HardVacuum.xcodeproj/christopherjohnson.perspectivev3 @@ -256,6 +256,8 @@ Layout + BecomeActive + ContentConfiguration PBXBottomSmartGroupGIDs @@ -349,10 +351,10 @@ _historyCapacity 0 bookmark - 8B181A1B204B984700516BEE + 8B793B5521F5F802006E9731 history - 8B181A1A204B984700516BEE + 8B181A1B204B984700516BEE SplitCount @@ -366,18 +368,18 @@ GeometryConfiguration Frame - {{0, 0}, {603, 132}} + {{0, 0}, {603, 117}} RubberWindowFrame 23 367 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 + 23 367 810 487 0 0 1440 878 Module XCDetailModule @@ -446,8 +450,6 @@ Frame {{10, 27}, {603, 282}} - RubberWindowFrame - 23 367 810 487 0 0 1440 878 Module PBXBuildResultsModule @@ -475,11 +477,11 @@ TableOfContents - 8B1819D9204B91BA00516BEE + 8B793B5621F5F802006E9731 1CA23ED40692098700951B8B - 8B1819DA204B91BA00516BEE + 8B793B5721F5F802006E9731 8B0237581D42B1C400E1E8C8 - 8B1819DB204B91BA00516BEE + 8B793B5821F5F802006E9731 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -632,7 +634,7 @@ StatusbarIsVisible TimeStamp - 541825095.83224404 + 569767938.33907902 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -649,7 +651,7 @@ 5 WindowOrderList - /Users/christopherjohnson/Desktop/HardVacuum/HardVacuum.xcodeproj + /Users/christopherjohnson/Desktop/MacVST/HardVacuum/HardVacuum.xcodeproj WindowString 23 367 810 487 0 0 1440 878 diff --git a/plugins/MacVST/HardVacuum/source/HardVacuum.cpp b/plugins/MacVST/HardVacuum/source/HardVacuum.cpp index 2ad1a4a..9c14f89 100755 --- a/plugins/MacVST/HardVacuum/source/HardVacuum.cpp +++ b/plugins/MacVST/HardVacuum/source/HardVacuum.cpp @@ -19,11 +19,8 @@ HardVacuum::HardVacuum(audioMasterCallback audioMaster) : E = 1.0; lastSampleL = 0.0; lastSampleR = 0.0; - fpNShapeLA = 0.0; - fpNShapeLB = 0.0; - fpNShapeRA = 0.0; - fpNShapeRB = 0.0; - fpFlip = true; + fpNShapeL = 0.0; + fpNShapeR = 0.0; //this is reset: values being initialized only once. Startup values, whatever they are. _canDo.insert("plugAsChannelInsert"); // plug-in can be used as a channel insert effect. diff --git a/plugins/MacVST/HardVacuum/source/HardVacuum.h b/plugins/MacVST/HardVacuum/source/HardVacuum.h index 6321df6..7f4c098 100755 --- a/plugins/MacVST/HardVacuum/source/HardVacuum.h +++ b/plugins/MacVST/HardVacuum/source/HardVacuum.h @@ -56,11 +56,8 @@ private: char _programName[kVstMaxProgNameLen + 1]; std::set< std::string > _canDo; - long double fpNShapeLA; - long double fpNShapeLB; - long double fpNShapeRA; - long double fpNShapeRB; - bool fpFlip; + long double fpNShapeL; + long double fpNShapeR; //default stuff double lastSampleL; diff --git a/plugins/MacVST/HardVacuum/source/HardVacuumProc.cpp b/plugins/MacVST/HardVacuum/source/HardVacuumProc.cpp index f8fe4fd..e0e07e2 100755 --- a/plugins/MacVST/HardVacuum/source/HardVacuumProc.cpp +++ b/plugins/MacVST/HardVacuum/source/HardVacuumProc.cpp @@ -33,9 +33,6 @@ void HardVacuum::processReplacing(float **inputs, float **outputs, VstInt32 samp double skewL; double skewR; - float fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; double drySampleL; double drySampleR; @@ -176,25 +173,14 @@ void HardVacuum::processReplacing(float **inputs, float **outputs, VstInt32 samp inputSampleR = (inputSampleR * wet) + (drySampleR * dry); } - //noise shaping to 32-bit floating point - if (fpFlip) { - fpTemp = inputSampleL; - fpNShapeLA = (fpNShapeLA*fpOld)+((inputSampleL-fpTemp)*fpNew); - inputSampleL += fpNShapeLA; - fpTemp = inputSampleR; - fpNShapeRA = (fpNShapeRA*fpOld)+((inputSampleR-fpTemp)*fpNew); - inputSampleR += fpNShapeRA; - } - else { - fpTemp = inputSampleL; - fpNShapeLB = (fpNShapeLB*fpOld)+((inputSampleL-fpTemp)*fpNew); - inputSampleL += fpNShapeLB; - fpTemp = inputSampleR; - fpNShapeRB = (fpNShapeRB*fpOld)+((inputSampleR-fpTemp)*fpNew); - inputSampleR += fpNShapeRB; - } - fpFlip = !fpFlip; - //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; @@ -232,9 +218,6 @@ void HardVacuum::processDoubleReplacing(double **inputs, double **outputs, VstIn double skewL; double skewR; - double fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; double drySampleL; double drySampleR; @@ -376,25 +359,16 @@ void HardVacuum::processDoubleReplacing(double **inputs, double **outputs, VstIn inputSampleR = (inputSampleR * wet) + (drySampleR * dry); } - //noise shaping to 64-bit floating point - if (fpFlip) { - fpTemp = inputSampleL; - fpNShapeLA = (fpNShapeLA*fpOld)+((inputSampleL-fpTemp)*fpNew); - inputSampleL += fpNShapeLA; - fpTemp = inputSampleR; - fpNShapeRA = (fpNShapeRA*fpOld)+((inputSampleR-fpTemp)*fpNew); - inputSampleR += fpNShapeRA; - } - else { - fpTemp = inputSampleL; - fpNShapeLB = (fpNShapeLB*fpOld)+((inputSampleL-fpTemp)*fpNew); - inputSampleL += fpNShapeLB; - fpTemp = inputSampleR; - fpNShapeRB = (fpNShapeRB*fpOld)+((inputSampleR-fpTemp)*fpNew); - inputSampleR += fpNShapeRB; - } - fpFlip = !fpFlip; - //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; -- cgit v1.2.3