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 | 14 ++-- .../christopherjohnson.perspectivev3 | 19 ++--- .../PurestGain.xcodeproj/project.pbxproj | 4 +- .../project.xcworkspace/contents.xcworkspacedata | 0 .../UserInterfaceState.xcuserstate | Bin .../UserInterfaceState.xcuserstate | Bin .../PurestGain.xcodeproj/spiadmin.mode1v3 | 0 .../PurestGain.xcodeproj/spiadmin.pbxuser | 0 .../xcschemes/Gain.xcscheme | 0 .../xcschemes/xcschememanagement.plist | 0 .../xcschemes/xcschememanagement.plist | 0 .../\302\253PROJECTNAME\302\273.xcscheme" | 0 plugins/MacVST/PurestGain/source/PurestGain.cpp | 7 +- plugins/MacVST/PurestGain/source/PurestGain.h | 7 +- .../MacVST/PurestGain/source/PurestGainProc.cpp | 92 ++++----------------- 15 files changed, 40 insertions(+), 103 deletions(-) mode change 100644 => 100755 plugins/MacVST/PurestGain/PurestGain.xcodeproj/christopherjohnson.pbxuser mode change 100644 => 100755 plugins/MacVST/PurestGain/PurestGain.xcodeproj/christopherjohnson.perspectivev3 mode change 100644 => 100755 plugins/MacVST/PurestGain/PurestGain.xcodeproj/project.xcworkspace/contents.xcworkspacedata mode change 100644 => 100755 plugins/MacVST/PurestGain/PurestGain.xcodeproj/project.xcworkspace/xcuserdata/christopherjohnson.xcuserdatad/UserInterfaceState.xcuserstate mode change 100644 => 100755 plugins/MacVST/PurestGain/PurestGain.xcodeproj/project.xcworkspace/xcuserdata/spiadmin.xcuserdatad/UserInterfaceState.xcuserstate mode change 100644 => 100755 plugins/MacVST/PurestGain/PurestGain.xcodeproj/spiadmin.mode1v3 mode change 100644 => 100755 plugins/MacVST/PurestGain/PurestGain.xcodeproj/spiadmin.pbxuser mode change 100644 => 100755 plugins/MacVST/PurestGain/PurestGain.xcodeproj/xcuserdata/christopherjohnson.xcuserdatad/xcschemes/Gain.xcscheme mode change 100644 => 100755 plugins/MacVST/PurestGain/PurestGain.xcodeproj/xcuserdata/christopherjohnson.xcuserdatad/xcschemes/xcschememanagement.plist mode change 100644 => 100755 plugins/MacVST/PurestGain/PurestGain.xcodeproj/xcuserdata/spiadmin.xcuserdatad/xcschemes/xcschememanagement.plist mode change 100644 => 100755 "plugins/MacVST/PurestGain/PurestGain.xcodeproj/xcuserdata/spiadmin.xcuserdatad/xcschemes/\302\253PROJECTNAME\302\273.xcscheme" (limited to 'plugins/MacVST/PurestGain') diff --git a/plugins/MacVST/PurestGain/PurestGain.xcodeproj/christopherjohnson.pbxuser b/plugins/MacVST/PurestGain/PurestGain.xcodeproj/christopherjohnson.pbxuser old mode 100644 new mode 100755 index 11a21ab..60f46c3 --- a/plugins/MacVST/PurestGain/PurestGain.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacVST/PurestGain/PurestGain.xcodeproj/christopherjohnson.pbxuser @@ -2,7 +2,7 @@ { 089C1669FE841209C02AAC07 /* Project object */ = { activeBuildConfigurationName = Release; - activeTarget = 8D01CCC60486CAD60068D4B7 /* PurestGain */; + activeTarget = 8D01CCC60486CAD60068D4B7 /* AudioUnit */; codeSenseManager = 8B02375F1D42B1C400E1E8C8 /* Code sense */; perUserDictionary = { PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = { @@ -49,8 +49,8 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 530661522; - PBXWorkspaceStateSaveDate = 530661522; + PBXPerProjectTemplateStateSaveDate = 569771364; + PBXWorkspaceStateSaveDate = 569771364; }; sourceControlManager = 8B02375E1D42B1C400E1E8C8 /* Source Control */; userBuildSettings = { @@ -82,9 +82,9 @@ }; 24D8286F09A914000093AEF8 /* PurestGainProc.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {848, 4095}}"; - sepNavSelRange = "{8041, 1892}"; - sepNavVisRange = "{2228, 2390}"; + sepNavIntBoundsRect = "{{0, 0}, {848, 3484}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRange = "{7696, 2006}"; sepNavWindowFrame = "{{488, 47}, {895, 831}}"; }; }; @@ -102,7 +102,7 @@ isa = PBXCodeSenseManager; indexTemplatePath = ""; }; - 8D01CCC60486CAD60068D4B7 /* PurestGain */ = { + 8D01CCC60486CAD60068D4B7 /* AudioUnit */ = { activeExec = 0; }; } diff --git a/plugins/MacVST/PurestGain/PurestGain.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacVST/PurestGain/PurestGain.xcodeproj/christopherjohnson.perspectivev3 old mode 100644 new mode 100755 index f4f1de3..3986363 --- a/plugins/MacVST/PurestGain/PurestGain.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacVST/PurestGain/PurestGain.xcodeproj/christopherjohnson.perspectivev3 @@ -300,7 +300,7 @@ PBXSmartGroupTreeModuleOutlineStateSelectionKey - 5 + 6 4 0 @@ -323,7 +323,7 @@ 185 RubberWindowFrame - 711 333 810 487 0 0 1440 878 + 630 333 810 487 0 0 1440 878 Module PBXSmartGroupTreeModule @@ -362,7 +362,7 @@ Frame {{0, 0}, {603, 0}} RubberWindowFrame - 711 333 810 487 0 0 1440 878 + 630 333 810 487 0 0 1440 878 Module PBXNavigatorGroup @@ -387,7 +387,7 @@ Frame {{10, 27}, {603, 414}} RubberWindowFrame - 711 333 810 487 0 0 1440 878 + 630 333 810 487 0 0 1440 878 Module XCDetailModule @@ -469,11 +469,11 @@ TableOfContents - 8BA972EE1FA145A50032B992 + 8B793EDC21F6057A006E9731 1CA23ED40692098700951B8B - 8BA972EF1FA145A50032B992 + 8B793EDD21F6057A006E9731 8B0237581D42B1C400E1E8C8 - 8BA972F01FA145A50032B992 + 8B793EDE21F6057A006E9731 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -626,7 +626,7 @@ StatusbarIsVisible TimeStamp - 530662821.72906101 + 569771386.05235398 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -643,11 +643,10 @@ 5 WindowOrderList - 8BA972F11FA145A50032B992 /Users/christopherjohnson/Desktop/MacVST/PurestGain/PurestGain.xcodeproj WindowString - 711 333 810 487 0 0 1440 878 + 630 333 810 487 0 0 1440 878 WindowToolsV3 diff --git a/plugins/MacVST/PurestGain/PurestGain.xcodeproj/project.pbxproj b/plugins/MacVST/PurestGain/PurestGain.xcodeproj/project.pbxproj index b89fc20..511f09f 100755 --- a/plugins/MacVST/PurestGain/PurestGain.xcodeproj/project.pbxproj +++ b/plugins/MacVST/PurestGain/PurestGain.xcodeproj/project.pbxproj @@ -1894,7 +1894,7 @@ /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ - 8D01CCC60486CAD60068D4B7 /* PurestGain */ = { + 8D01CCC60486CAD60068D4B7 /* AudioUnit */ = { isa = PBXNativeTarget; buildConfigurationList = 24BEAAED08919AE700E695F9 /* Build configuration list for PBXNativeTarget "PurestGain" */; buildPhases = ( @@ -1947,7 +1947,7 @@ ); projectRoot = ""; targets = ( - 8D01CCC60486CAD60068D4B7 /* PurestGain */, + 8D01CCC60486CAD60068D4B7 /* AudioUnit */, ); }; /* End PBXProject section */ diff --git a/plugins/MacVST/PurestGain/PurestGain.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/plugins/MacVST/PurestGain/PurestGain.xcodeproj/project.xcworkspace/contents.xcworkspacedata old mode 100644 new mode 100755 diff --git a/plugins/MacVST/PurestGain/PurestGain.xcodeproj/project.xcworkspace/xcuserdata/christopherjohnson.xcuserdatad/UserInterfaceState.xcuserstate b/plugins/MacVST/PurestGain/PurestGain.xcodeproj/project.xcworkspace/xcuserdata/christopherjohnson.xcuserdatad/UserInterfaceState.xcuserstate old mode 100644 new mode 100755 diff --git a/plugins/MacVST/PurestGain/PurestGain.xcodeproj/project.xcworkspace/xcuserdata/spiadmin.xcuserdatad/UserInterfaceState.xcuserstate b/plugins/MacVST/PurestGain/PurestGain.xcodeproj/project.xcworkspace/xcuserdata/spiadmin.xcuserdatad/UserInterfaceState.xcuserstate old mode 100644 new mode 100755 diff --git a/plugins/MacVST/PurestGain/PurestGain.xcodeproj/spiadmin.mode1v3 b/plugins/MacVST/PurestGain/PurestGain.xcodeproj/spiadmin.mode1v3 old mode 100644 new mode 100755 diff --git a/plugins/MacVST/PurestGain/PurestGain.xcodeproj/spiadmin.pbxuser b/plugins/MacVST/PurestGain/PurestGain.xcodeproj/spiadmin.pbxuser old mode 100644 new mode 100755 diff --git a/plugins/MacVST/PurestGain/PurestGain.xcodeproj/xcuserdata/christopherjohnson.xcuserdatad/xcschemes/Gain.xcscheme b/plugins/MacVST/PurestGain/PurestGain.xcodeproj/xcuserdata/christopherjohnson.xcuserdatad/xcschemes/Gain.xcscheme old mode 100644 new mode 100755 diff --git a/plugins/MacVST/PurestGain/PurestGain.xcodeproj/xcuserdata/christopherjohnson.xcuserdatad/xcschemes/xcschememanagement.plist b/plugins/MacVST/PurestGain/PurestGain.xcodeproj/xcuserdata/christopherjohnson.xcuserdatad/xcschemes/xcschememanagement.plist old mode 100644 new mode 100755 diff --git a/plugins/MacVST/PurestGain/PurestGain.xcodeproj/xcuserdata/spiadmin.xcuserdatad/xcschemes/xcschememanagement.plist b/plugins/MacVST/PurestGain/PurestGain.xcodeproj/xcuserdata/spiadmin.xcuserdatad/xcschemes/xcschememanagement.plist old mode 100644 new mode 100755 diff --git "a/plugins/MacVST/PurestGain/PurestGain.xcodeproj/xcuserdata/spiadmin.xcuserdatad/xcschemes/\302\253PROJECTNAME\302\273.xcscheme" "b/plugins/MacVST/PurestGain/PurestGain.xcodeproj/xcuserdata/spiadmin.xcuserdatad/xcschemes/\302\253PROJECTNAME\302\273.xcscheme" old mode 100644 new mode 100755 diff --git a/plugins/MacVST/PurestGain/source/PurestGain.cpp b/plugins/MacVST/PurestGain/source/PurestGain.cpp index 3091a12..b1b77fe 100755 --- a/plugins/MacVST/PurestGain/source/PurestGain.cpp +++ b/plugins/MacVST/PurestGain/source/PurestGain.cpp @@ -18,11 +18,8 @@ PurestGain::PurestGain(audioMasterCallback audioMaster) : settingchase = -90.0; gainBchase = -90.0; chasespeed = 350.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/PurestGain/source/PurestGain.h b/plugins/MacVST/PurestGain/source/PurestGain.h index 7869425..9e2baea 100755 --- a/plugins/MacVST/PurestGain/source/PurestGain.h +++ b/plugins/MacVST/PurestGain/source/PurestGain.h @@ -53,11 +53,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 gainchase; double settingchase; diff --git a/plugins/MacVST/PurestGain/source/PurestGainProc.cpp b/plugins/MacVST/PurestGain/source/PurestGainProc.cpp index 38f2849..4aa6d96 100755 --- a/plugins/MacVST/PurestGain/source/PurestGainProc.cpp +++ b/plugins/MacVST/PurestGain/source/PurestGainProc.cpp @@ -43,9 +43,6 @@ void PurestGain::processReplacing(float **inputs, float **outputs, VstInt32 samp //done with slow fade controller double outputgain; - float fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; long double inputSampleL; long double inputSampleR; @@ -118,45 +115,19 @@ void PurestGain::processReplacing(float **inputs, float **outputs, VstInt32 samp if (1.0 == outputgain) { - 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 *out1 = *in1; *out2 = *in2; } else { inputSampleL *= outputgain; inputSampleR *= outputgain; - 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; } @@ -204,9 +175,6 @@ void PurestGain::processDoubleReplacing(double **inputs, double **outputs, VstIn //done with slow fade controller double outputgain; - double fpTemp; //this is different from singlereplacing - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; long double inputSampleL; long double inputSampleR; @@ -273,45 +241,21 @@ void PurestGain::processDoubleReplacing(double **inputs, double **outputs, VstIn if (1.0 == outputgain) { - 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 *out1 = *in1; *out2 = *in2; } else { inputSampleL *= outputgain; inputSampleR *= outputgain; - 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 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