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 --- .../Golem.xcodeproj/christopherjohnson.pbxuser | 40 +++++++------- .../christopherjohnson.perspectivev3 | 32 +++++------ plugins/MacVST/Golem/source/Golem.cpp | 6 +-- plugins/MacVST/Golem/source/Golem.h | 6 +-- plugins/MacVST/Golem/source/GolemProc.cpp | 62 +++++++--------------- 5 files changed, 58 insertions(+), 88 deletions(-) (limited to 'plugins/MacVST/Golem') diff --git a/plugins/MacVST/Golem/Golem.xcodeproj/christopherjohnson.pbxuser b/plugins/MacVST/Golem/Golem.xcodeproj/christopherjohnson.pbxuser index 795dec3..92a9864 100755 --- a/plugins/MacVST/Golem/Golem.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacVST/Golem/Golem.xcodeproj/christopherjohnson.pbxuser @@ -49,12 +49,12 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 546574396; - PBXWorkspaceStateSaveDate = 546574396; + PBXPerProjectTemplateStateSaveDate = 569735514; + PBXWorkspaceStateSaveDate = 569735514; }; perUserProjectItems = { - 8BC5D0B1209410C30058B257 /* PBXTextBookmark */ = 8BC5D0B1209410C30058B257 /* PBXTextBookmark */; - 8BC5D0B2209410C30058B257 /* PBXTextBookmark */ = 8BC5D0B2209410C30058B257 /* PBXTextBookmark */; + 8B793AE021F57961006E9731 /* PBXTextBookmark */ = 8B793AE021F57961006E9731 /* PBXTextBookmark */; + 8B793AF221F579C4006E9731 /* PBXTextBookmark */ = 8B793AF221F579C4006E9731 /* PBXTextBookmark */; }; sourceControlManager = 8B02375E1D42B1C400E1E8C8 /* Source Control */; userBuildSettings = { @@ -62,17 +62,17 @@ }; 2407DEB6089929BA00EB68BF /* Golem.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {848, 1963}}"; - sepNavSelRange = "{3822, 11}"; - sepNavVisRange = "{2936, 2411}"; + sepNavIntBoundsRect = "{{0, 0}, {848, 1989}}"; + sepNavSelRange = "{558, 0}"; + sepNavVisRange = "{0, 1950}"; sepNavWindowFrame = "{{12, 47}, {895, 831}}"; }; }; 245463B80991757100464AD3 /* Golem.h */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {866, 897}}"; - sepNavSelRange = "{2496, 0}"; - sepNavVisRange = "{2414, 147}"; + sepNavIntBoundsRect = "{{0, 0}, {817, 923}}"; + sepNavSelRange = "{2444, 0}"; + sepNavVisRange = "{2413, 96}"; sepNavWindowFrame = "{{20, 47}, {895, 831}}"; }; }; @@ -86,9 +86,9 @@ }; 24D8286F09A914000093AEF8 /* GolemProc.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {848, 3653}}"; + sepNavIntBoundsRect = "{{0, 0}, {848, 3354}}"; sepNavSelRange = "{5207, 0}"; - sepNavVisRange = "{4697, 1871}"; + sepNavVisRange = "{6969, 1540}"; sepNavWindowFrame = "{{54, 47}, {895, 831}}"; }; }; @@ -106,25 +106,25 @@ isa = PBXCodeSenseManager; indexTemplatePath = ""; }; - 8BC5D0B1209410C30058B257 /* PBXTextBookmark */ = { + 8B793AE021F57961006E9731 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 245463B80991757100464AD3 /* Golem.h */; name = "Golem.h: 61"; rLen = 0; - rLoc = 2496; + rLoc = 2444; rType = 0; - vrLen = 147; + vrLen = 133; vrLoc = 2414; }; - 8BC5D0B2209410C30058B257 /* PBXTextBookmark */ = { + 8B793AF221F579C4006E9731 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 245463B80991757100464AD3 /* Golem.h */; - name = "Golem.h: 61"; + name = "Golem.h: 59"; rLen = 0; - rLoc = 2496; + rLoc = 2444; rType = 0; - vrLen = 147; - vrLoc = 2414; + vrLen = 96; + vrLoc = 2413; }; 8D01CCC60486CAD60068D4B7 /* Golem */ = { activeExec = 0; diff --git a/plugins/MacVST/Golem/Golem.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacVST/Golem/Golem.xcodeproj/christopherjohnson.perspectivev3 index 62ce38b..0726bc5 100755 --- a/plugins/MacVST/Golem/Golem.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacVST/Golem/Golem.xcodeproj/christopherjohnson.perspectivev3 @@ -323,7 +323,7 @@ 185 RubberWindowFrame - 23 322 810 487 0 0 1440 878 + 504 266 810 487 0 0 1440 878 Module PBXSmartGroupTreeModule @@ -351,10 +351,10 @@ _historyCapacity 0 bookmark - 8BC5D0B2209410C30058B257 + 8B793AF221F579C4006E9731 history - 8BC5D0B1209410C30058B257 + 8B793AE021F57961006E9731 SplitCount @@ -368,18 +368,18 @@ GeometryConfiguration Frame - {{0, 0}, {603, 132}} + {{0, 0}, {603, 117}} RubberWindowFrame - 23 322 810 487 0 0 1440 878 + 504 266 810 487 0 0 1440 878 Module PBXNavigatorGroup Proportion - 132pt + 117pt Proportion - 309pt + 324pt Tabs @@ -393,9 +393,7 @@ GeometryConfiguration Frame - {{10, 27}, {603, 282}} - RubberWindowFrame - 23 322 810 487 0 0 1440 878 + {{10, 27}, {603, 297}} Module XCDetailModule @@ -449,7 +447,9 @@ GeometryConfiguration Frame - {{10, 27}, {603, 414}} + {{10, 27}, {603, 297}} + RubberWindowFrame + 504 266 810 487 0 0 1440 878 Module PBXBuildResultsModule @@ -477,11 +477,11 @@ TableOfContents - 8BC5D0B3209410C30058B257 + 8B793AF321F579C4006E9731 1CA23ED40692098700951B8B - 8BC5D0B4209410C30058B257 + 8B793AF421F579C4006E9731 8B0237581D42B1C400E1E8C8 - 8BC5D0B5209410C30058B257 + 8B793AF521F579C4006E9731 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -634,7 +634,7 @@ StatusbarIsVisible TimeStamp - 546574531.81958306 + 569735620.885432 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -654,7 +654,7 @@ /Users/christopherjohnson/Desktop/MacVST/Golem/Golem.xcodeproj WindowString - 23 322 810 487 0 0 1440 878 + 504 266 810 487 0 0 1440 878 WindowToolsV3 diff --git a/plugins/MacVST/Golem/source/Golem.cpp b/plugins/MacVST/Golem/source/Golem.cpp index 8f63b48..c99c5cd 100755 --- a/plugins/MacVST/Golem/source/Golem.cpp +++ b/plugins/MacVST/Golem/source/Golem.cpp @@ -17,10 +17,8 @@ Golem::Golem(audioMasterCallback audioMaster) : C = 0.0; for(count = 0; count < 4098; count++) {p[count] = 0.0;} count = 0; - fpNShapeLA = 0.0; - fpNShapeLB = 0.0; - fpNShapeRA = 0.0; - fpNShapeRB = 0.0; + fpNShapeL = 0.0; + fpNShapeR = 0.0; flip = true; //this is reset: values being initialized only once. Startup values, whatever they are. diff --git a/plugins/MacVST/Golem/source/Golem.h b/plugins/MacVST/Golem/source/Golem.h index 8bb81d8..e02ab78 100755 --- a/plugins/MacVST/Golem/source/Golem.h +++ b/plugins/MacVST/Golem/source/Golem.h @@ -54,10 +54,8 @@ private: char _programName[kVstMaxProgNameLen + 1]; std::set< std::string > _canDo; - long double fpNShapeLA; - long double fpNShapeLB; - long double fpNShapeRA; - long double fpNShapeRB; + long double fpNShapeL; + long double fpNShapeR; bool flip; //default stuff double p[4099]; diff --git a/plugins/MacVST/Golem/source/GolemProc.cpp b/plugins/MacVST/Golem/source/GolemProc.cpp index 9235869..1d7e9f5 100755 --- a/plugins/MacVST/Golem/source/GolemProc.cpp +++ b/plugins/MacVST/Golem/source/GolemProc.cpp @@ -14,9 +14,6 @@ void Golem::processReplacing(float **inputs, float **outputs, VstInt32 sampleFra float* out1 = outputs[0]; float* out2 = outputs[1]; - float fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; int phase = (int)((C * 5.999)+1); double balance = ((A*2.0)-1.0) / 2.0; double gainL = 0.5 - balance; @@ -115,25 +112,14 @@ void Golem::processReplacing(float **inputs, float **outputs, VstInt32 sampleFra inputSampleR = inputSampleL; //the output is totally mono - //noise shaping to 32-bit floating point - if (flip) { - 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; - } - flip = !flip; - //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; @@ -152,9 +138,6 @@ void Golem::processDoubleReplacing(double **inputs, double **outputs, VstInt32 s double* out1 = outputs[0]; double* out2 = outputs[1]; - double fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; int phase = (int)((C * 5.999)+1); double balance = ((A*2.0)-1.0) / 2.0; double gainL = 0.5 - balance; @@ -253,25 +236,16 @@ void Golem::processDoubleReplacing(double **inputs, double **outputs, VstInt32 s inputSampleR = inputSampleL; //the output is totally mono - //noise shaping to 64-bit floating point - if (flip) { - 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; - } - flip = !flip; - //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