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 --- .../VariMu.xcodeproj/christopherjohnson.pbxuser | 8 ++-- .../christopherjohnson.perspectivev3 | 16 +++---- plugins/MacVST/VariMu/source/VariMuProc.cpp | 54 ++++++++-------------- 3 files changed, 30 insertions(+), 48 deletions(-) (limited to 'plugins/MacVST/VariMu') diff --git a/plugins/MacVST/VariMu/VariMu.xcodeproj/christopherjohnson.pbxuser b/plugins/MacVST/VariMu/VariMu.xcodeproj/christopherjohnson.pbxuser index 817d97b..26171e9 100755 --- a/plugins/MacVST/VariMu/VariMu.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacVST/VariMu/VariMu.xcodeproj/christopherjohnson.pbxuser @@ -2,7 +2,7 @@ { 089C1669FE841209C02AAC07 /* Project object */ = { activeBuildConfigurationName = Release; - activeTarget = 8D01CCC60486CAD60068D4B7 /* VariMu */; + activeTarget = 8D01CCC60486CAD60068D4B7 /* AudioUnit */; codeSenseManager = 8B02375F1D42B1C400E1E8C8 /* Code sense */; perUserDictionary = { PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = { @@ -49,8 +49,8 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 553992948; - PBXWorkspaceStateSaveDate = 553992948; + PBXPerProjectTemplateStateSaveDate = 569773498; + PBXWorkspaceStateSaveDate = 569773498; }; sourceControlManager = 8B02375E1D42B1C400E1E8C8 /* Source Control */; userBuildSettings = { @@ -102,7 +102,7 @@ isa = PBXCodeSenseManager; indexTemplatePath = ""; }; - 8D01CCC60486CAD60068D4B7 /* VariMu */ = { + 8D01CCC60486CAD60068D4B7 /* AudioUnit */ = { activeExec = 0; }; } diff --git a/plugins/MacVST/VariMu/VariMu.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacVST/VariMu/VariMu.xcodeproj/christopherjohnson.perspectivev3 index 95718ee..1fd954d 100755 --- a/plugins/MacVST/VariMu/VariMu.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacVST/VariMu/VariMu.xcodeproj/christopherjohnson.perspectivev3 @@ -323,7 +323,7 @@ 185 RubberWindowFrame - 50 341 810 487 0 0 1440 878 + 398 267 810 487 0 0 1440 878 Module PBXSmartGroupTreeModule @@ -362,7 +362,7 @@ Frame {{0, 0}, {603, 0}} RubberWindowFrame - 50 341 810 487 0 0 1440 878 + 398 267 810 487 0 0 1440 878 Module PBXNavigatorGroup @@ -387,7 +387,7 @@ Frame {{10, 27}, {603, 414}} RubberWindowFrame - 50 341 810 487 0 0 1440 878 + 398 267 810 487 0 0 1440 878 Module XCDetailModule @@ -469,11 +469,11 @@ TableOfContents - 8BBD1887210542F70015A233 + 8B7942CD21F60DC2006E9731 1CA23ED40692098700951B8B - 8BBD1888210542F70015A233 + 8B7942CE21F60DC2006E9731 8B0237581D42B1C400E1E8C8 - 8BBD1889210542F70015A233 + 8B7942CF21F60DC2006E9731 1CA23EDF0692099D00951B8B 1CA23EE00692099D00951B8B 1CA23EE10692099D00951B8B @@ -626,7 +626,7 @@ StatusbarIsVisible TimeStamp - 553992991.79695594 + 569773506.89082396 ToolbarConfigUserDefaultsMinorVersion 2 ToolbarDisplayMode @@ -646,7 +646,7 @@ /Users/christopherjohnson/Desktop/MacVST/VariMu/VariMu.xcodeproj WindowString - 50 341 810 487 0 0 1440 878 + 398 267 810 487 0 0 1440 878 WindowToolsV3 diff --git a/plugins/MacVST/VariMu/source/VariMuProc.cpp b/plugins/MacVST/VariMu/source/VariMuProc.cpp index b966cd8..323b5e4 100755 --- a/plugins/MacVST/VariMu/source/VariMuProc.cpp +++ b/plugins/MacVST/VariMu/source/VariMuProc.cpp @@ -233,18 +233,14 @@ void VariMu::processReplacing(float **inputs, float **outputs, VstInt32 sampleFr //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 - float fpTemp = inputSampleL; - fpNShapeL += (inputSampleL-fpTemp); - inputSampleL += fpNShapeL; - //if this confuses you look at the wordlength for fpTemp :) - fpTemp = inputSampleR; - fpNShapeR += (inputSampleR-fpTemp); - inputSampleR += fpNShapeR; - //for deeper space and warmth, we try a non-oscillating noise shaping - //that is kind of ruthless: it will forever retain the rounding errors - //except we'll dial it back a hair at the end of every buffer processed - //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; @@ -254,12 +250,6 @@ void VariMu::processReplacing(float **inputs, float **outputs, VstInt32 sampleFr *out1++; *out2++; } - fpNShapeL *= 0.999999; - fpNShapeR *= 0.999999; - //we will just delicately dial back the FP noise shaping, not even every sample - //this is a good place to put subtle 'no runaway' calculations, though bear in mind - //that it will be called more often when you use shorter sample buffers in the DAW. - //So, very low latency operation will call these calculations more often. } void VariMu::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames) @@ -488,18 +478,16 @@ void VariMu::processDoubleReplacing(double **inputs, double **outputs, VstInt32 //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 - double fpTemp = inputSampleL; - fpNShapeL += (inputSampleL-fpTemp); - inputSampleL += fpNShapeL; - //if this confuses you look at the wordlength for fpTemp :) - fpTemp = inputSampleR; - fpNShapeR += (inputSampleR-fpTemp); - inputSampleR += fpNShapeR; - //for deeper space and warmth, we try a non-oscillating noise shaping - //that is kind of ruthless: it will forever retain the rounding errors - //except we'll dial it back a hair at the end of every buffer processed - //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; @@ -509,10 +497,4 @@ void VariMu::processDoubleReplacing(double **inputs, double **outputs, VstInt32 *out1++; *out2++; } - fpNShapeL *= 0.999999; - fpNShapeR *= 0.999999; - //we will just delicately dial back the FP noise shaping, not even every sample - //this is a good place to put subtle 'no runaway' calculations, though bear in mind - //that it will be called more often when you use shorter sample buffers in the DAW. - //So, very low latency operation will call these calculations more often. } -- cgit v1.2.3