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 --- .../Air/Air.xcodeproj/christopherjohnson.pbxuser | 8 +-- .../Air.xcodeproj/christopherjohnson.perspectivev3 | 23 ++++---- plugins/MacVST/Air/Air.xcodeproj/project.pbxproj | 4 +- plugins/MacVST/Air/source/Air.cpp | 7 +-- plugins/MacVST/Air/source/Air.h | 7 +-- plugins/MacVST/Air/source/AirProc.cpp | 62 +++++++--------------- 6 files changed, 38 insertions(+), 73 deletions(-) (limited to 'plugins/MacVST/Air') diff --git a/plugins/MacVST/Air/Air.xcodeproj/christopherjohnson.pbxuser b/plugins/MacVST/Air/Air.xcodeproj/christopherjohnson.pbxuser index f47bee4..1d6d131 100755 --- a/plugins/MacVST/Air/Air.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacVST/Air/Air.xcodeproj/christopherjohnson.pbxuser @@ -2,7 +2,7 @@ { 089C1669FE841209C02AAC07 /* Project object */ = { activeBuildConfigurationName = Release; - activeTarget = 8D01CCC60486CAD60068D4B7 /* Air */; + activeTarget = 8D01CCC60486CAD60068D4B7 /* AudioUnit */; codeSenseManager = 8B02375F1D42B1C400E1E8C8 /* Code sense */; perUserDictionary = { PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = { @@ -49,8 +49,8 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 528459012; - PBXWorkspaceStateSaveDate = 528459012; + PBXPerProjectTemplateStateSaveDate = 569707718; + PBXWorkspaceStateSaveDate = 569707718; }; sourceControlManager = 8B02375E1D42B1C400E1E8C8 /* Source Control */; userBuildSettings = { @@ -102,7 +102,7 @@ isa = PBXCodeSenseManager; indexTemplatePath = ""; }; - 8D01CCC60486CAD60068D4B7 /* Air */ = { + 8D01CCC60486CAD60068D4B7 /* AudioUnit */ = { activeExec = 0; }; } diff --git a/plugins/MacVST/Air/Air.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacVST/Air/Air.xcodeproj/christopherjohnson.perspectivev3 index 51c8a58..fc2db00 100755 --- a/plugins/MacVST/Air/Air.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacVST/Air/Air.xcodeproj/christopherjohnson.perspectivev3 @@ -256,8 +256,6 @@ Layout - BecomeActive - ContentConfiguration PBXBottomSmartGroupGIDs @@ -323,7 +321,7 @@ 185 RubberWindowFrame - 630 108 810 487 0 0 1440 878 + 172 221 810 487 0 0 1440 878 Module PBXSmartGroupTreeModule @@ -362,7 +360,7 @@ Frame {{0, 0}, {603, 0}} RubberWindowFrame - 630 108 810 487 0 0 1440 878 + 172 221 810 487 0 0 1440 878 Module PBXNavigatorGroup @@ -386,8 +384,6 @@ Frame {{10, 27}, {603, 414}} - RubberWindowFrame - 630 108 810 487 0 0 1440 878 Module XCDetailModule @@ -441,7 +437,9 @@ GeometryConfiguration Frame - {{10, 27}, {603, 282}} + {{10, 27}, {603, 414}} + RubberWindowFrame + 172 221 810 487 0 0 1440 878 Module PBXBuildResultsModule @@ -469,11 +467,11 @@ TableOfContents - 8B9D77391F7FA524007AB60F + 8B79336521F50CD1006E9731 1CA23ED40692098700951B8B - 8B9D773A1F7FA524007AB60F + 8B79336621F50CD1006E9731 8B0237581D42B1C400E1E8C8 - 8B9D773B1F7FA524007AB60F + 8B79336721F50CD1006E9731 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -626,7 +624,7 @@ StatusbarIsVisible TimeStamp - 528459044.96789801 + 569707729.79363501 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -643,11 +641,10 @@ 5 WindowOrderList - 8B9D773C1F7FA524007AB60F /Users/christopherjohnson/Desktop/MacVST/Air/Air.xcodeproj WindowString - 630 108 810 487 0 0 1440 878 + 172 221 810 487 0 0 1440 878 WindowToolsV3 diff --git a/plugins/MacVST/Air/Air.xcodeproj/project.pbxproj b/plugins/MacVST/Air/Air.xcodeproj/project.pbxproj index 014f5ac..6f03014 100755 --- a/plugins/MacVST/Air/Air.xcodeproj/project.pbxproj +++ b/plugins/MacVST/Air/Air.xcodeproj/project.pbxproj @@ -1894,7 +1894,7 @@ /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ - 8D01CCC60486CAD60068D4B7 /* Air */ = { + 8D01CCC60486CAD60068D4B7 /* AudioUnit */ = { isa = PBXNativeTarget; buildConfigurationList = 24BEAAED08919AE700E695F9 /* Build configuration list for PBXNativeTarget "Air" */; buildPhases = ( @@ -1947,7 +1947,7 @@ ); projectRoot = ""; targets = ( - 8D01CCC60486CAD60068D4B7 /* Air */, + 8D01CCC60486CAD60068D4B7 /* AudioUnit */, ); }; /* End PBXProject section */ diff --git a/plugins/MacVST/Air/source/Air.cpp b/plugins/MacVST/Air/source/Air.cpp index ebe8adc..ea52c26 100755 --- a/plugins/MacVST/Air/source/Air.cpp +++ b/plugins/MacVST/Air/source/Air.cpp @@ -61,11 +61,8 @@ Air::Air(audioMasterCallback audioMaster) : D = 0.0; E = 1.0; F = 1.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/Air/source/Air.h b/plugins/MacVST/Air/source/Air.h index 00c0b76..a713cf2 100755 --- a/plugins/MacVST/Air/source/Air.h +++ b/plugins/MacVST/Air/source/Air.h @@ -100,11 +100,8 @@ private: bool flop; int count; - long double fpNShapeLA; - long double fpNShapeLB; - long double fpNShapeRA; - long double fpNShapeRB; - bool fpFlip; + long double fpNShapeL; + long double fpNShapeR; //default stuff float A; diff --git a/plugins/MacVST/Air/source/AirProc.cpp b/plugins/MacVST/Air/source/AirProc.cpp index f73e7d8..f5eb39f 100755 --- a/plugins/MacVST/Air/source/AirProc.cpp +++ b/plugins/MacVST/Air/source/AirProc.cpp @@ -22,9 +22,6 @@ void Air::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrame double wet = F; double dry = 1.0-wet; - float fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; long double inputSampleL; long double inputSampleR; @@ -260,25 +257,14 @@ void Air::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrame //nice little output stage template: if we have another scale of floating point //number, we really don't want to meaninglessly multiply that by 1.0. - //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; @@ -305,9 +291,6 @@ void Air::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sam double wet = F; double dry = 1.0-wet; - 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; @@ -543,25 +526,16 @@ void Air::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sam //nice little output stage template: if we have another scale of floating point //number, we really don't want to meaninglessly multiply that by 1.0. - //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