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/Noise | |
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/Noise')
-rwxr-xr-x | plugins/MacVST/Noise/Noise.xcodeproj/christopherjohnson.pbxuser | 16 | ||||
-rwxr-xr-x | plugins/MacVST/Noise/Noise.xcodeproj/christopherjohnson.perspectivev3 | 20 | ||||
-rwxr-xr-x | plugins/MacVST/Noise/source/Noise.cpp | 7 | ||||
-rwxr-xr-x | plugins/MacVST/Noise/source/Noise.h | 7 | ||||
-rwxr-xr-x | plugins/MacVST/Noise/source/NoiseProc.cpp | 62 |
5 files changed, 40 insertions, 72 deletions
diff --git a/plugins/MacVST/Noise/Noise.xcodeproj/christopherjohnson.pbxuser b/plugins/MacVST/Noise/Noise.xcodeproj/christopherjohnson.pbxuser index bd35d43..6370236 100755 --- a/plugins/MacVST/Noise/Noise.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacVST/Noise/Noise.xcodeproj/christopherjohnson.pbxuser @@ -49,12 +49,12 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 538707186; - PBXWorkspaceStateSaveDate = 538707186; + PBXPerProjectTemplateStateSaveDate = 569770541; + PBXWorkspaceStateSaveDate = 569770541; }; perUserProjectItems = { 8B4E5870201C0C8B00B5DC2A /* PBXTextBookmark */ = 8B4E5870201C0C8B00B5DC2A /* PBXTextBookmark */; - 8B7ADC6220157443005F895F /* PBXTextBookmark */ = 8B7ADC6220157443005F895F /* PBXTextBookmark */; + 8B793D1A21F60235006E9731 /* PBXTextBookmark */ = 8B793D1A21F60235006E9731 /* PBXTextBookmark */; }; sourceControlManager = 8B02375E1D42B1C400E1E8C8 /* Source Control */; userBuildSettings = { @@ -70,7 +70,7 @@ }; 245463B80991757100464AD3 /* Noise.h */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {859, 1170}}"; + sepNavIntBoundsRect = "{{0, 0}, {523, 1300}}"; sepNavSelRange = "{2962, 0}"; sepNavVisRange = "{0, 0}"; sepNavWindowFrame = "{{895, 11}, {895, 831}}"; @@ -116,15 +116,15 @@ vrLen = 0; vrLoc = 0; }; - 8B7ADC6220157443005F895F /* PBXTextBookmark */ = { + 8B793D1A21F60235006E9731 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 245463B80991757100464AD3 /* Noise.h */; - name = "Noise.h: 95"; + name = "Noise.h: 93"; rLen = 0; rLoc = 2962; rType = 0; - vrLen = 638; - vrLoc = 1696; + vrLen = 0; + vrLoc = 0; }; 8D01CCC60486CAD60068D4B7 /* Noise */ = { activeExec = 0; diff --git a/plugins/MacVST/Noise/Noise.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacVST/Noise/Noise.xcodeproj/christopherjohnson.perspectivev3 index cddeac8..9dc310c 100755 --- a/plugins/MacVST/Noise/Noise.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacVST/Noise/Noise.xcodeproj/christopherjohnson.perspectivev3 @@ -351,10 +351,10 @@ <key>_historyCapacity</key> <integer>0</integer> <key>bookmark</key> - <string>8B4E5870201C0C8B00B5DC2A</string> + <string>8B793D1A21F60235006E9731</string> <key>history</key> <array> - <string>8B7ADC6220157443005F895F</string> + <string>8B4E5870201C0C8B00B5DC2A</string> </array> </dict> <key>SplitCount</key> @@ -368,18 +368,18 @@ <key>GeometryConfiguration</key> <dict> <key>Frame</key> - <string>{{0, 0}, {454, 9}}</string> + <string>{{0, 0}, {454, 0}}</string> <key>RubberWindowFrame</key> <string>26 91 661 394 0 0 1440 878 </string> </dict> <key>Module</key> <string>PBXNavigatorGroup</string> <key>Proportion</key> - <string>9pt</string> + <string>0pt</string> </dict> <dict> <key>Proportion</key> - <string>339pt</string> + <string>348pt</string> <key>Tabs</key> <array> <dict> @@ -393,7 +393,7 @@ <key>GeometryConfiguration</key> <dict> <key>Frame</key> - <string>{{10, 27}, {454, 312}}</string> + <string>{{10, 27}, {454, 321}}</string> <key>RubberWindowFrame</key> <string>26 91 661 394 0 0 1440 878 </string> </dict> @@ -477,11 +477,11 @@ </array> <key>TableOfContents</key> <array> - <string>8B4E5871201C0C8B00B5DC2A</string> + <string>8B793D1B21F60235006E9731</string> <string>1CA23ED40692098700951B8B</string> - <string>8B4E5872201C0C8B00B5DC2A</string> + <string>8B793D1C21F60235006E9731</string> <string>8B0237581D42B1C400E1E8C8</string> - <string>8B4E5873201C0C8B00B5DC2A</string> + <string>8B793D1D21F60235006E9731</string> <string>1CA23EDF0692099D00951B8B</string> <string>1CA23EE00692099D00951B8B</string> <string>1CA23EE10692099D00951B8B</string> @@ -634,7 +634,7 @@ <key>StatusbarIsVisible</key> <true/> <key>TimeStamp</key> - <real>538709131.54011202</real> + <real>569770549.64791</real> <key>ToolbarConfigUserDefaultsMinorVersion</key> <string>2</string> <key>ToolbarDisplayMode</key> diff --git a/plugins/MacVST/Noise/source/Noise.cpp b/plugins/MacVST/Noise/source/Noise.cpp index 76d00c8..d955a29 100755 --- a/plugins/MacVST/Noise/source/Noise.cpp +++ b/plugins/MacVST/Noise/source/Noise.cpp @@ -36,11 +36,8 @@ Noise::Noise(audioMasterCallback audioMaster) : flipR = false; filterflip = false; for(int count = 0; count < 11; count++) {bL[count] = 0.0; bR[count] = 0.0; f[count] = 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/Noise/source/Noise.h b/plugins/MacVST/Noise/source/Noise.h index 0ee4d76..67c32bc 100755 --- a/plugins/MacVST/Noise/source/Noise.h +++ b/plugins/MacVST/Noise/source/Noise.h @@ -81,11 +81,8 @@ private: double f[11]; - 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/Noise/source/NoiseProc.cpp b/plugins/MacVST/Noise/source/NoiseProc.cpp index e185120..31cba20 100755 --- a/plugins/MacVST/Noise/source/NoiseProc.cpp +++ b/plugins/MacVST/Noise/source/NoiseProc.cpp @@ -104,9 +104,6 @@ void Noise::processReplacing(float **inputs, float **outputs, VstInt32 sampleFra f[9] /= overallscale; //and now it's neatly scaled, too - float fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; @@ -299,25 +296,14 @@ void Noise::processReplacing(float **inputs, float **outputs, VstInt32 sampleFra //sometimes I'm really tired and can't do stuff, and I remember trying to simplify this //and breaking it somehow. So, there ya go, strange obtuse code. - //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; @@ -426,9 +412,6 @@ void Noise::processDoubleReplacing(double **inputs, double **outputs, VstInt32 s f[9] /= overallscale; //and now it's neatly scaled, too - double fpTemp; - long double fpOld = 0.618033988749894848204586; //golden ratio! - long double fpNew = 1.0 - fpOld; while (--sampleFrames >= 0) { @@ -619,25 +602,16 @@ void Noise::processDoubleReplacing(double **inputs, double **outputs, VstInt32 s //sometimes I'm really tired and can't do stuff, and I remember trying to simplify this //and breaking it somehow. So, there ya go, strange obtuse code. - //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; |