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 | 8 +-- .../christopherjohnson.perspectivev3 | 18 +++---- .../OneCornerClip.xcodeproj/project.pbxproj | 4 +- .../MacVST/OneCornerClip/source/OneCornerClip.cpp | 7 +-- .../MacVST/OneCornerClip/source/OneCornerClip.h | 7 +-- .../OneCornerClip/source/OneCornerClipProc.cpp | 62 +++++++--------------- 6 files changed, 37 insertions(+), 69 deletions(-) (limited to 'plugins/MacVST/OneCornerClip') diff --git a/plugins/MacVST/OneCornerClip/OneCornerClip.xcodeproj/christopherjohnson.pbxuser b/plugins/MacVST/OneCornerClip/OneCornerClip.xcodeproj/christopherjohnson.pbxuser index a659ad8..1f3a7c9 100755 --- a/plugins/MacVST/OneCornerClip/OneCornerClip.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacVST/OneCornerClip/OneCornerClip.xcodeproj/christopherjohnson.pbxuser @@ -2,7 +2,7 @@ { 089C1669FE841209C02AAC07 /* Project object */ = { activeBuildConfigurationName = Release; - activeTarget = 8D01CCC60486CAD60068D4B7 /* OneCornerClip */; + activeTarget = 8D01CCC60486CAD60068D4B7 /* AudioUnit */; codeSenseManager = 8B02375F1D42B1C400E1E8C8 /* Code sense */; perUserDictionary = { PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = { @@ -49,8 +49,8 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 541882923; - PBXWorkspaceStateSaveDate = 541882923; + PBXPerProjectTemplateStateSaveDate = 569770606; + PBXWorkspaceStateSaveDate = 569770606; }; sourceControlManager = 8B02375E1D42B1C400E1E8C8 /* Source Control */; userBuildSettings = { @@ -102,7 +102,7 @@ isa = PBXCodeSenseManager; indexTemplatePath = ""; }; - 8D01CCC60486CAD60068D4B7 /* OneCornerClip */ = { + 8D01CCC60486CAD60068D4B7 /* AudioUnit */ = { activeExec = 0; }; } diff --git a/plugins/MacVST/OneCornerClip/OneCornerClip.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacVST/OneCornerClip/OneCornerClip.xcodeproj/christopherjohnson.perspectivev3 index 22f0aea..07b0810 100755 --- a/plugins/MacVST/OneCornerClip/OneCornerClip.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacVST/OneCornerClip/OneCornerClip.xcodeproj/christopherjohnson.perspectivev3 @@ -256,6 +256,8 @@ Layout + BecomeActive + ContentConfiguration PBXBottomSmartGroupGIDs @@ -384,6 +386,8 @@ Frame {{10, 27}, {603, 414}} + RubberWindowFrame + 19 372 810 487 0 0 1440 878 Module XCDetailModule @@ -438,8 +442,6 @@ Frame {{10, 27}, {603, 414}} - RubberWindowFrame - 19 372 810 487 0 0 1440 878 Module PBXBuildResultsModule @@ -467,11 +469,11 @@ TableOfContents - 8B181A2A204C7A3200516BEE + 8B793D5921F60278006E9731 1CA23ED40692098700951B8B - 8B181A2B204C7A3200516BEE + 8B793D5A21F60278006E9731 8B0237581D42B1C400E1E8C8 - 8B181A2C204C7A3200516BEE + 8B793D5B21F60278006E9731 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -624,7 +626,7 @@ StatusbarIsVisible TimeStamp - 541885613.92280805 + 569770616.13496995 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -641,9 +643,7 @@ 5 WindowOrderList - 8B181A59204C84AD00516BEE - 8B181A5A204C84AD00516BEE - /Users/christopherjohnson/Desktop/OneCornerClip/OneCornerClip.xcodeproj + /Users/christopherjohnson/Desktop/MacVST/OneCornerClip/OneCornerClip.xcodeproj WindowString 19 372 810 487 0 0 1440 878 diff --git a/plugins/MacVST/OneCornerClip/OneCornerClip.xcodeproj/project.pbxproj b/plugins/MacVST/OneCornerClip/OneCornerClip.xcodeproj/project.pbxproj index f6df3c9..8f62a88 100755 --- a/plugins/MacVST/OneCornerClip/OneCornerClip.xcodeproj/project.pbxproj +++ b/plugins/MacVST/OneCornerClip/OneCornerClip.xcodeproj/project.pbxproj @@ -1894,7 +1894,7 @@ /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ - 8D01CCC60486CAD60068D4B7 /* OneCornerClip */ = { + 8D01CCC60486CAD60068D4B7 /* AudioUnit */ = { isa = PBXNativeTarget; buildConfigurationList = 24BEAAED08919AE700E695F9 /* Build configuration list for PBXNativeTarget "OneCornerClip" */; buildPhases = ( @@ -1947,7 +1947,7 @@ ); projectRoot = ""; targets = ( - 8D01CCC60486CAD60068D4B7 /* OneCornerClip */, + 8D01CCC60486CAD60068D4B7 /* AudioUnit */, ); }; /* End PBXProject section */ diff --git a/plugins/MacVST/OneCornerClip/source/OneCornerClip.cpp b/plugins/MacVST/OneCornerClip/source/OneCornerClip.cpp index bf8828e..59e2824 100755 --- a/plugins/MacVST/OneCornerClip/source/OneCornerClip.cpp +++ b/plugins/MacVST/OneCornerClip/source/OneCornerClip.cpp @@ -25,11 +25,8 @@ OneCornerClip::OneCornerClip(audioMasterCallback audioMaster) : limitPosR = 0.0; limitNegR = 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/OneCornerClip/source/OneCornerClip.h b/plugins/MacVST/OneCornerClip/source/OneCornerClip.h index 07f480a..4f039fa 100755 --- a/plugins/MacVST/OneCornerClip/source/OneCornerClip.h +++ b/plugins/MacVST/OneCornerClip/source/OneCornerClip.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/OneCornerClip/source/OneCornerClipProc.cpp b/plugins/MacVST/OneCornerClip/source/OneCornerClipProc.cpp index 0398b60..c45c69b 100755 --- a/plugins/MacVST/OneCornerClip/source/OneCornerClipProc.cpp +++ b/plugins/MacVST/OneCornerClip/source/OneCornerClipProc.cpp @@ -17,9 +17,6 @@ void OneCornerClip::processReplacing(float **inputs, float **outputs, VstInt32 s double overallscale = 1.0; overallscale /= 44100.0; overallscale *= getSampleRate(); - float fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; double inputGain = pow(10.0,(((A*36.0)-12.0)/20.0)); double posThreshold = B; @@ -157,25 +154,14 @@ void OneCornerClip::processReplacing(float **inputs, float **outputs, VstInt32 s 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 if (clipEngage == false) { @@ -204,9 +190,6 @@ void OneCornerClip::processDoubleReplacing(double **inputs, double **outputs, Vs double overallscale = 1.0; overallscale /= 44100.0; overallscale *= getSampleRate(); - double fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; double inputGain = pow(10.0,(((A*36.0)-12.0)/20.0)); double posThreshold = B; @@ -345,25 +328,16 @@ void OneCornerClip::processDoubleReplacing(double **inputs, double **outputs, Vs 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 if (clipEngage == false) { -- cgit v1.2.3