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 --- .../StarChild.xcodeproj/christopherjohnson.pbxuser | 12 ++--- .../christopherjohnson.perspectivev3 | 21 ++++---- plugins/MacVST/StarChild/source/StarChild.cpp | 7 +-- plugins/MacVST/StarChild/source/StarChild.h | 7 +-- plugins/MacVST/StarChild/source/StarChildProc.cpp | 62 +++++++--------------- 5 files changed, 38 insertions(+), 71 deletions(-) (limited to 'plugins/MacVST/StarChild') diff --git a/plugins/MacVST/StarChild/StarChild.xcodeproj/christopherjohnson.pbxuser b/plugins/MacVST/StarChild/StarChild.xcodeproj/christopherjohnson.pbxuser index 82b4c8d..dd67748 100755 --- a/plugins/MacVST/StarChild/StarChild.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacVST/StarChild/StarChild.xcodeproj/christopherjohnson.pbxuser @@ -49,11 +49,11 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 528462002; - PBXWorkspaceStateSaveDate = 528462002; + PBXPerProjectTemplateStateSaveDate = 569772605; + PBXWorkspaceStateSaveDate = 569772605; }; perUserProjectItems = { - 8B9D70751F7EF81B007AB60F /* PBXTextBookmark */ = 8B9D70751F7EF81B007AB60F /* PBXTextBookmark */; + 8B79406121F60A46006E9731 /* PBXTextBookmark */ = 8B79406121F60A46006E9731 /* PBXTextBookmark */; 8B9D7E451F7FB0C9007AB60F /* PBXTextBookmark */ = 8B9D7E451F7FB0C9007AB60F /* PBXTextBookmark */; }; sourceControlManager = 8B02375E1D42B1C400E1E8C8 /* Source Control */; @@ -106,15 +106,15 @@ isa = PBXCodeSenseManager; indexTemplatePath = ""; }; - 8B9D70751F7EF81B007AB60F /* PBXTextBookmark */ = { + 8B79406121F60A46006E9731 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 24A2FFDB0F90D1DD003BB5A7 /* audioeffectx.cpp */; name = "audioeffectx.cpp: 307"; rLen = 0; rLoc = 10616; rType = 0; - vrLen = 123; - vrLoc = 10613; + vrLen = 0; + vrLoc = 0; }; 8B9D7E451F7FB0C9007AB60F /* PBXTextBookmark */ = { isa = PBXTextBookmark; diff --git a/plugins/MacVST/StarChild/StarChild.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacVST/StarChild/StarChild.xcodeproj/christopherjohnson.perspectivev3 index dbfa3aa..7a37b96 100755 --- a/plugins/MacVST/StarChild/StarChild.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacVST/StarChild/StarChild.xcodeproj/christopherjohnson.perspectivev3 @@ -351,10 +351,10 @@ _historyCapacity 0 bookmark - 8B9D7E451F7FB0C9007AB60F + 8B79406121F60A46006E9731 history - 8B9D70751F7EF81B007AB60F + 8B9D7E451F7FB0C9007AB60F SplitCount @@ -368,18 +368,18 @@ GeometryConfiguration Frame - {{0, 0}, {603, 32}} + {{0, 0}, {603, 13}} RubberWindowFrame 423 305 810 487 0 0 1440 878 Module PBXNavigatorGroup Proportion - 32pt + 13pt Proportion - 409pt + 428pt Tabs @@ -393,7 +393,7 @@ GeometryConfiguration Frame - {{10, 27}, {603, 382}} + {{10, 27}, {603, 401}} RubberWindowFrame 423 305 810 487 0 0 1440 878 @@ -477,11 +477,11 @@ TableOfContents - 8B9D7E461F7FB0C9007AB60F + 8B79406221F60A46006E9731 1CA23ED40692098700951B8B - 8B9D7E471F7FB0C9007AB60F + 8B79406321F60A46006E9731 8B0237581D42B1C400E1E8C8 - 8B9D7E481F7FB0C9007AB60F + 8B79406421F60A46006E9731 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -634,7 +634,7 @@ StatusbarIsVisible TimeStamp - 528462025.44259501 + 569772614.68796301 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -651,7 +651,6 @@ 5 WindowOrderList - 8B9D7E491F7FB0C9007AB60F /Users/christopherjohnson/Desktop/MacVST/StarChild/StarChild.xcodeproj WindowString diff --git a/plugins/MacVST/StarChild/source/StarChild.cpp b/plugins/MacVST/StarChild/source/StarChild.cpp index 84becbc..1b29d50 100755 --- a/plugins/MacVST/StarChild/source/StarChild.cpp +++ b/plugins/MacVST/StarChild/source/StarChild.cpp @@ -65,11 +65,8 @@ StarChild::StarChild(audioMasterCallback audioMaster) : increment = 1; dutyCycle = 1; - 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/StarChild/source/StarChild.h b/plugins/MacVST/StarChild/source/StarChild.h index 7ae986a..630be3c 100755 --- a/plugins/MacVST/StarChild/source/StarChild.h +++ b/plugins/MacVST/StarChild/source/StarChild.h @@ -54,11 +54,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 d[45102]; diff --git a/plugins/MacVST/StarChild/source/StarChildProc.cpp b/plugins/MacVST/StarChild/source/StarChildProc.cpp index 03c8e31..047948a 100755 --- a/plugins/MacVST/StarChild/source/StarChildProc.cpp +++ b/plugins/MacVST/StarChild/source/StarChildProc.cpp @@ -14,9 +14,6 @@ void StarChild::processReplacing(float **inputs, float **outputs, VstInt32 sampl float* out1 = outputs[0]; float* out2 = outputs[1]; - float fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; double drySampleL; double drySampleR; @@ -392,25 +389,14 @@ void StarChild::processReplacing(float **inputs, float **outputs, VstInt32 sampl inputSampleR += drySampleR; //here we combine the tanks with the dry signal - //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; @@ -429,9 +415,6 @@ void StarChild::processDoubleReplacing(double **inputs, double **outputs, VstInt double* out1 = outputs[0]; double* out2 = outputs[1]; - double fpTemp; //this is different from singlereplacing - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; double drySampleL; double drySampleR; @@ -807,25 +790,16 @@ void StarChild::processDoubleReplacing(double **inputs, double **outputs, VstInt inputSampleR += drySampleR; //here we combine the tanks with the dry signal - //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