diff options
author | Chris Johnson <jinx6568@sover.net> | 2019-01-27 21:13:54 -0500 |
---|---|---|
committer | Chris Johnson <jinx6568@sover.net> | 2019-01-27 21:13:54 -0500 |
commit | 966f2d253cd2ee6ce140ad68095a20a9d2b63052 (patch) | |
tree | b0400d95bd06512531ade6ddf55190a58b6a5623 /plugins/MacVST/Loud | |
parent | 0887543349dbbec0721a1fc8b1c7deba9afefa8b (diff) | |
download | airwindows-lv2-port-966f2d253cd2ee6ce140ad68095a20a9d2b63052.tar.gz airwindows-lv2-port-966f2d253cd2ee6ce140ad68095a20a9d2b63052.tar.bz2 airwindows-lv2-port-966f2d253cd2ee6ce140ad68095a20a9d2b63052.zip |
Floating Point Dither For All
Diffstat (limited to 'plugins/MacVST/Loud')
-rwxr-xr-x | plugins/MacVST/Loud/Loud.xcodeproj/christopherjohnson.pbxuser | 8 | ||||
-rwxr-xr-x | plugins/MacVST/Loud/Loud.xcodeproj/christopherjohnson.perspectivev3 | 13 | ||||
-rwxr-xr-x | plugins/MacVST/Loud/source/Loud.cpp | 7 | ||||
-rwxr-xr-x | plugins/MacVST/Loud/source/Loud.h | 7 | ||||
-rwxr-xr-x | plugins/MacVST/Loud/source/LoudProc.cpp | 62 |
5 files changed, 32 insertions, 65 deletions
diff --git a/plugins/MacVST/Loud/Loud.xcodeproj/christopherjohnson.pbxuser b/plugins/MacVST/Loud/Loud.xcodeproj/christopherjohnson.pbxuser index 6c66b21..0bed7c5 100755 --- a/plugins/MacVST/Loud/Loud.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacVST/Loud/Loud.xcodeproj/christopherjohnson.pbxuser @@ -49,11 +49,11 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 541203976; - PBXWorkspaceStateSaveDate = 541203976; + PBXPerProjectTemplateStateSaveDate = 569770045; + PBXWorkspaceStateSaveDate = 569770045; }; perUserProjectItems = { - 8B277E0D1FD86E330038EA07 /* PBXTextBookmark */ = 8B277E0D1FD86E330038EA07 /* PBXTextBookmark */; + 8B793C7221F60046006E9731 /* PBXTextBookmark */ = 8B793C7221F60046006E9731 /* PBXTextBookmark */; 8BCEFAAE2042230B002E8187 /* PBXTextBookmark */ = 8BCEFAAE2042230B002E8187 /* PBXTextBookmark */; }; sourceControlManager = 8B02375E1D42B1C400E1E8C8 /* Source Control */; @@ -106,7 +106,7 @@ isa = PBXCodeSenseManager; indexTemplatePath = ""; }; - 8B277E0D1FD86E330038EA07 /* PBXTextBookmark */ = { + 8B793C7221F60046006E9731 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 24A2FFDB0F90D1DD003BB5A7 /* audioeffectx.cpp */; name = "audioeffectx.cpp: 307"; diff --git a/plugins/MacVST/Loud/Loud.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacVST/Loud/Loud.xcodeproj/christopherjohnson.perspectivev3 index 7b79c6f..a60b90a 100755 --- a/plugins/MacVST/Loud/Loud.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacVST/Loud/Loud.xcodeproj/christopherjohnson.perspectivev3 @@ -351,10 +351,10 @@ <key>_historyCapacity</key> <integer>0</integer> <key>bookmark</key> - <string>8BCEFAAE2042230B002E8187</string> + <string>8B793C7221F60046006E9731</string> <key>history</key> <array> - <string>8B277E0D1FD86E330038EA07</string> + <string>8BCEFAAE2042230B002E8187</string> </array> </dict> <key>SplitCount</key> @@ -477,11 +477,11 @@ </array> <key>TableOfContents</key> <array> - <string>8BCEFAAF2042230B002E8187</string> + <string>8B793C7321F60046006E9731</string> <string>1CA23ED40692098700951B8B</string> - <string>8BCEFAB02042230B002E8187</string> + <string>8B793C7421F60046006E9731</string> <string>8B0237581D42B1C400E1E8C8</string> - <string>8BCEFAB12042230B002E8187</string> + <string>8B793C7521F60046006E9731</string> <string>1CA23EDF0692099D00951B8B</string> <string>1CA23EE00692099D00951B8B</string> <string>1CA23EE10692099D00951B8B</string> @@ -634,7 +634,7 @@ <key>StatusbarIsVisible</key> <true/> <key>TimeStamp</key> - <real>541205259.86103797</real> + <real>569770054.94940603</real> <key>ToolbarConfigUserDefaultsMinorVersion</key> <string>2</string> <key>ToolbarDisplayMode</key> @@ -651,7 +651,6 @@ <integer>5</integer> <key>WindowOrderList</key> <array> - <string>8BCEFAB22042230B002E8187</string> <string>/Users/christopherjohnson/Desktop/MacVST/Loud/Loud.xcodeproj</string> </array> <key>WindowString</key> diff --git a/plugins/MacVST/Loud/source/Loud.cpp b/plugins/MacVST/Loud/source/Loud.cpp index 43f7ffc..009124d 100755 --- a/plugins/MacVST/Loud/source/Loud.cpp +++ b/plugins/MacVST/Loud/source/Loud.cpp @@ -15,11 +15,8 @@ Loud::Loud(audioMasterCallback audioMaster) : A = 0.0; B = 1.0; C = 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/Loud/source/Loud.h b/plugins/MacVST/Loud/source/Loud.h index 85b66a2..17537c2 100755 --- a/plugins/MacVST/Loud/source/Loud.h +++ b/plugins/MacVST/Loud/source/Loud.h @@ -56,11 +56,8 @@ private: double lastSampleL; double lastSampleR; - 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/Loud/source/LoudProc.cpp b/plugins/MacVST/Loud/source/LoudProc.cpp index 8aedede..35ee29b 100755 --- a/plugins/MacVST/Loud/source/LoudProc.cpp +++ b/plugins/MacVST/Loud/source/LoudProc.cpp @@ -18,9 +18,6 @@ void Loud::processReplacing(float **inputs, float **outputs, VstInt32 sampleFram overallscale /= 44100.0; overallscale *= getSampleRate(); double boost = pow(A+1.0,5); - float fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; double output = B; double wet = C; double dry = 1.0-wet; @@ -143,25 +140,14 @@ void Loud::processReplacing(float **inputs, float **outputs, VstInt32 sampleFram //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; @@ -184,9 +170,6 @@ void Loud::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sa overallscale /= 44100.0; overallscale *= getSampleRate(); double boost = pow(A+1.0,5); - double fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; double output = B; double wet = C; double dry = 1.0-wet; @@ -308,25 +291,16 @@ void Loud::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sa //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; |