diff options
author | Chris Johnson <jinx6568@sover.net> | 2019-04-08 07:08:18 -0400 |
---|---|---|
committer | Chris Johnson <jinx6568@sover.net> | 2019-04-08 07:08:18 -0400 |
commit | cc40b8f8ce6cf447317baf4c97a09a6e639854af (patch) | |
tree | 3f821bcd13497ea6e44af7ded504b37c15b75a46 /plugins/MacAU/BrassRider | |
parent | b18e5d0f3ffae1756be1935fa3cd10875f9193b1 (diff) | |
download | airwindows-lv2-port-cc40b8f8ce6cf447317baf4c97a09a6e639854af.tar.gz airwindows-lv2-port-cc40b8f8ce6cf447317baf4c97a09a6e639854af.tar.bz2 airwindows-lv2-port-cc40b8f8ce6cf447317baf4c97a09a6e639854af.zip |
BrassRider, Highpass2
Diffstat (limited to 'plugins/MacAU/BrassRider')
4 files changed, 143 insertions, 156 deletions
diff --git a/plugins/MacAU/BrassRider/BrassRider.cpp b/plugins/MacAU/BrassRider/BrassRider.cpp index 79a9baf..b11d7a6 100755 --- a/plugins/MacAU/BrassRider/BrassRider.cpp +++ b/plugins/MacAU/BrassRider/BrassRider.cpp @@ -194,8 +194,8 @@ ComponentResult BrassRider::Reset(AudioUnitScope inScope, AudioUnitElement inEl lastSampleR = 0.0; lastSlewR = 0.0; gcount = 0; - fpNShapeL = 0.0; - fpNShapeR = 0.0; + fpd = 17; + return noErr; } @@ -218,59 +218,51 @@ OSStatus BrassRider::ProcessBufferLists(AudioUnitRenderActionFlags & ioActionFl int offsetA = 13500; int offsetB = 16700; Float64 wet = GetParameter( kParam_Two ); - Float64 dry = 1.0-wet; - Float64 maxRide = wet*8; - Float64 inputSampleL; - Float64 drySampleL; - Float64 slewSampleL; - Float64 inputSampleR; - Float64 drySampleR; - Float64 slewSampleR; - Float64 ramp; - Float64 bridgerectifier; while (nSampleFrames-- > 0) { - inputSampleL = *inputL; - inputSampleR = *inputR; - - static int noisesourceL = 0; - static int noisesourceR = 850010; - int residue; - double applyresidue; - - noisesourceL = noisesourceL % 1700021; noisesourceL++; - residue = noisesourceL * noisesourceL; - residue = residue % 170003; residue *= residue; - residue = residue % 17011; residue *= residue; - residue = residue % 1709; residue *= residue; - residue = residue % 173; residue *= residue; - residue = residue % 17; - applyresidue = residue; - applyresidue *= 0.00000001; - applyresidue *= 0.00000001; - inputSampleL += applyresidue; + long double inputSampleL = *inputL; + long double inputSampleR = *inputR; + //assign working variables if (inputSampleL<1.2e-38 && -inputSampleL<1.2e-38) { - inputSampleL -= applyresidue; + static int noisesource = 0; + //this declares a variable before anything else is compiled. It won't keep assigning + //it to 0 for every sample, it's as if the declaration doesn't exist in this context, + //but it lets me add this denormalization fix in a single place rather than updating + //it in three different locations. The variable isn't thread-safe but this is only + //a random seed and we can share it with whatever. + noisesource = noisesource % 1700021; noisesource++; + int residue = noisesource * noisesource; + residue = residue % 170003; residue *= residue; + residue = residue % 17011; residue *= residue; + residue = residue % 1709; residue *= residue; + residue = residue % 173; residue *= residue; + residue = residue % 17; + double applyresidue = residue; + applyresidue *= 0.00000001; + applyresidue *= 0.00000001; + inputSampleL = applyresidue; } - - noisesourceR = noisesourceR % 1700021; noisesourceR++; - residue = noisesourceR * noisesourceR; - residue = residue % 170003; residue *= residue; - residue = residue % 17011; residue *= residue; - residue = residue % 1709; residue *= residue; - residue = residue % 173; residue *= residue; - residue = residue % 17; - applyresidue = residue; - applyresidue *= 0.00000001; - applyresidue *= 0.00000001; - inputSampleR += applyresidue; if (inputSampleR<1.2e-38 && -inputSampleR<1.2e-38) { - inputSampleR -= applyresidue; + static int noisesource = 0; + noisesource = noisesource % 1700021; noisesource++; + int residue = noisesource * noisesource; + residue = residue % 170003; residue *= residue; + residue = residue % 17011; residue *= residue; + residue = residue % 1709; residue *= residue; + residue = residue % 173; residue *= residue; + residue = residue % 17; + double applyresidue = residue; + applyresidue *= 0.00000001; + applyresidue *= 0.00000001; + inputSampleR = applyresidue; + //this denormalization routine produces a white noise at -300 dB which the noise + //shaping will interact with to produce a bipolar output, but the noise is actually + //all positive. That should stop any variables from going denormal, and the routine + //only kicks in if digital black is input. As a final touch, if you save to 24-bit + //the silence will return to being digital black again. } - //for live air, we always apply the dither noise. Then, if our result is - //effectively digital black, we'll subtract it again. We want a 'air' hiss - drySampleL = inputSampleL; - drySampleR = inputSampleR; + long double drySampleL = inputSampleL; + long double drySampleR = inputSampleR; inputSampleL *= limitOut; highIIRL = (highIIRL*0.5); @@ -279,7 +271,7 @@ OSStatus BrassRider::ProcessBufferLists(AudioUnitRenderActionFlags & ioActionFl highIIR2L = (highIIR2L*0.5); highIIR2L += (inputSampleL*0.5); inputSampleL -= highIIR2L; - slewSampleL = fabs(inputSampleL - lastSampleL); + long double slewSampleL = fabs(inputSampleL - lastSampleL); lastSampleL = inputSampleL; slewSampleL /= fabs(inputSampleL * lastSampleL)+0.2; slewIIRL = (slewIIRL*0.5); @@ -288,7 +280,7 @@ OSStatus BrassRider::ProcessBufferLists(AudioUnitRenderActionFlags & ioActionFl slewIIR2L = (slewIIR2L*0.5); slewIIR2L += (slewSampleL*0.5); slewSampleL = fabs(slewSampleL - slewIIR2L); - bridgerectifier = slewSampleL; + long double bridgerectifier = slewSampleL; //there's the left channel, now to feed it to overall clamp if (bridgerectifier > 3.1415) bridgerectifier = 0.0; @@ -297,11 +289,11 @@ OSStatus BrassRider::ProcessBufferLists(AudioUnitRenderActionFlags & ioActionFl d[gcount+40000] = d[gcount] = bridgerectifier; control += (d[gcount] / (offsetA+1)); control -= (d[gcount+offsetA] / offsetA); - ramp = (control*control) * 16.0; + Float64 ramp = (control*control) * 16.0; e[gcount+40000] = e[gcount] = ramp; clamp += (e[gcount] / (offsetB+1)); clamp -= (e[gcount+offsetB] / offsetB); - if (clamp > maxRide) clamp = maxRide; + if (clamp > wet*8) clamp = wet*8; gcount--; inputSampleR *= limitOut; @@ -311,7 +303,7 @@ OSStatus BrassRider::ProcessBufferLists(AudioUnitRenderActionFlags & ioActionFl highIIR2R = (highIIR2R*0.5); highIIR2R += (inputSampleR*0.5); inputSampleR -= highIIR2R; - slewSampleR = fabs(inputSampleR - lastSampleR); + long double slewSampleR = fabs(inputSampleR - lastSampleR); lastSampleR = inputSampleR; slewSampleR /= fabs(inputSampleR * lastSampleR)+0.2; slewIIRR = (slewIIRR*0.5); @@ -333,25 +325,20 @@ OSStatus BrassRider::ProcessBufferLists(AudioUnitRenderActionFlags & ioActionFl e[gcount+40000] = e[gcount] = ramp; clamp += (e[gcount] / (offsetB+1)); clamp -= (e[gcount+offsetB] / offsetB); - if (clamp > maxRide) clamp = maxRide; + if (clamp > wet*8) clamp = wet*8; gcount--; + inputSampleL = (drySampleL * (1.0-wet)) + (drySampleL * clamp * wet * 16.0); + inputSampleR = (drySampleR * (1.0-wet)) + (drySampleR * clamp * wet * 16.0); - inputSampleL = (drySampleL * dry) + (drySampleL * clamp * wet * 16.0); - inputSampleR = (drySampleR * dry) + (drySampleR * clamp * wet * 16.0); - - //noise shaping to 32-bit floating point - Float32 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 + //begin 32 bit stereo floating point dither + int expon; frexpf((float)inputSampleL, &expon); + fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5; + inputSampleL += static_cast<int32_t>(fpd) * 5.960464655174751e-36L * pow(2,expon+62); + frexpf((float)inputSampleR, &expon); + fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5; + inputSampleR += static_cast<int32_t>(fpd) * 5.960464655174751e-36L * pow(2,expon+62); + //end 32 bit stereo floating point dither *outputL = inputSampleL; *outputR = inputSampleR; @@ -360,13 +347,7 @@ OSStatus BrassRider::ProcessBufferLists(AudioUnitRenderActionFlags & ioActionFl inputR += 1; outputL += 1; outputR += 1; - } - 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. - return noErr; + } +return noErr; } diff --git a/plugins/MacAU/BrassRider/BrassRider.h b/plugins/MacAU/BrassRider/BrassRider.h index f0852d2..d199346 100755 --- a/plugins/MacAU/BrassRider/BrassRider.h +++ b/plugins/MacAU/BrassRider/BrassRider.h @@ -57,8 +57,8 @@ static const float kDefaultValue_ParamOne = 0.0; static const float kDefaultValue_ParamTwo = 0.0; -static CFStringRef kParameterOneName = CFSTR("Crash Threshold"); -static CFStringRef kParameterTwoName = CFSTR("Crash Intensity"); +static CFStringRef kParameterOneName = CFSTR("Threshold"); +static CFStringRef kParameterTwoName = CFSTR("Dry/Wet"); //Alter the name if desired, but using the plugin name is a start enum { @@ -112,27 +112,26 @@ public: virtual ComponentResult Version() { return kBrassRiderVersion; } - private: - - Float64 d[80002]; - Float64 e[80002]; - Float64 highIIRL; - Float64 slewIIRL; - Float64 highIIR2L; - Float64 slewIIR2L; - Float64 highIIRR; - Float64 slewIIRR; - Float64 highIIR2R; - Float64 slewIIR2R; - Float64 control; - Float64 clamp; - Float64 lastSampleL; - Float64 lastSlewL; - Float64 lastSampleR; - Float64 lastSlewR; - int gcount; - long double fpNShapeL; - long double fpNShapeR; + private: + + Float64 d[80002]; + Float64 e[80002]; + Float64 highIIRL; + Float64 slewIIRL; + Float64 highIIR2L; + Float64 slewIIR2L; + Float64 highIIRR; + Float64 slewIIRR; + Float64 highIIR2R; + Float64 slewIIR2R; + Float64 control; + Float64 clamp; + Float64 lastSampleL; + Float64 lastSlewL; + Float64 lastSampleR; + Float64 lastSlewR; + int gcount; + uint32_t fpd; }; diff --git a/plugins/MacAU/BrassRider/BrassRider.xcodeproj/christopherjohnson.pbxuser b/plugins/MacAU/BrassRider/BrassRider.xcodeproj/christopherjohnson.pbxuser index e8f8068..dde64e3 100755 --- a/plugins/MacAU/BrassRider/BrassRider.xcodeproj/christopherjohnson.pbxuser +++ b/plugins/MacAU/BrassRider/BrassRider.xcodeproj/christopherjohnson.pbxuser @@ -49,47 +49,72 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 559395636; - PBXWorkspaceStateSaveDate = 559395636; + PBXPerProjectTemplateStateSaveDate = 575135637; + PBXWorkspaceStateSaveDate = 575135637; }; perUserProjectItems = { - 8BE626432157B5CA00E4E476 /* PBXTextBookmark */ = 8BE626432157B5CA00E4E476 /* PBXTextBookmark */; - 8BE626492157B5E900E4E476 /* PBXTextBookmark */ = 8BE626492157B5E900E4E476 /* PBXTextBookmark */; + 8B6112492247E63A001915CF /* PBXTextBookmark */ = 8B6112492247E63A001915CF /* PBXTextBookmark */; + 8B61124A2247E63A001915CF /* PBXBookmark */ = 8B61124A2247E63A001915CF /* PBXBookmark */; + 8B61124B2247E63A001915CF /* PBXTextBookmark */ = 8B61124B2247E63A001915CF /* PBXTextBookmark */; }; sourceControlManager = 8BD3CCB8148830B20062E48C /* Source Control */; userBuildSettings = { }; }; + 8B6112492247E63A001915CF /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 8BA05A660720730100365D66 /* BrassRider.cpp */; + name = "BrassRider.cpp: 333"; + rLen = 0; + rLoc = 13879; + rType = 0; + vrLen = 316; + vrLoc = 13138; + }; + 8B61124A2247E63A001915CF /* PBXBookmark */ = { + isa = PBXBookmark; + fRef = 8BC6025B073B072D006C4272 /* BrassRider.h */; + }; + 8B61124B2247E63A001915CF /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 8BC6025B073B072D006C4272 /* BrassRider.h */; + name = "BrassRider.h: 113"; + rLen = 0; + rLoc = 4850; + rType = 0; + vrLen = 168; + vrLoc = 4783; + }; 8BA05A660720730100365D66 /* BrassRider.cpp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {843, 5122}}"; - sepNavSelRange = "{13648, 0}"; - sepNavVisRange = "{12665, 2003}"; - sepNavWindowFrame = "{{349, 68}, {890, 810}}"; + sepNavIntBoundsRect = "{{0, 0}, {854, 4901}}"; + sepNavSelRange = "{11528, 2511}"; + sepNavVisRange = "{10434, 2151}"; + sepNavWindowFrame = "{{527, 79}, {901, 799}}"; }; }; 8BA05A670720730100365D66 /* BrassRider.exp */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {843, 682}}"; + sepNavIntBoundsRect = "{{0, 0}, {854, 671}}"; sepNavSelRange = "{17, 0}"; sepNavVisRange = "{0, 17}"; - sepNavWindowFrame = "{{15, 63}, {890, 810}}"; + sepNavWindowFrame = "{{15, 74}, {901, 799}}"; }; }; 8BA05A690720730100365D66 /* BrassRiderVersion.h */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {843, 897}}"; + sepNavIntBoundsRect = "{{0, 0}, {854, 897}}"; sepNavSelRange = "{0, 0}"; - sepNavVisRange = "{444, 3042}"; - sepNavWindowFrame = "{{38, 42}, {890, 810}}"; + sepNavVisRange = "{444, 3041}"; + sepNavWindowFrame = "{{607, 79}, {901, 799}}"; }; }; 8BC6025B073B072D006C4272 /* BrassRider.h */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {803, 1872}}"; - sepNavSelRange = "{0, 0}"; - sepNavVisRange = "{0, 131}"; - sepNavWindowFrame = "{{341, 59}, {890, 810}}"; + sepNavIntBoundsRect = "{{0, 0}, {922, 2054}}"; + sepNavSelRange = "{4850, 0}"; + sepNavVisRange = "{4783, 168}"; + sepNavWindowFrame = "{{539, 79}, {901, 799}}"; }; }; 8BD3CCB8148830B20062E48C /* Source Control */ = { @@ -106,26 +131,6 @@ isa = PBXCodeSenseManager; indexTemplatePath = ""; }; - 8BE626432157B5CA00E4E476 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 8BC6025B073B072D006C4272 /* BrassRider.h */; - name = "BrassRider.h: 1"; - rLen = 0; - rLoc = 0; - rType = 0; - vrLen = 131; - vrLoc = 0; - }; - 8BE626492157B5E900E4E476 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 8BC6025B073B072D006C4272 /* BrassRider.h */; - name = "BrassRider.h: 1"; - rLen = 0; - rLoc = 0; - rType = 0; - vrLen = 131; - vrLoc = 0; - }; 8D01CCC60486CAD60068D4B7 /* BrassRider */ = { activeExec = 0; }; diff --git a/plugins/MacAU/BrassRider/BrassRider.xcodeproj/christopherjohnson.perspectivev3 b/plugins/MacAU/BrassRider/BrassRider.xcodeproj/christopherjohnson.perspectivev3 index 142f3cb..ca98252 100755 --- a/plugins/MacAU/BrassRider/BrassRider.xcodeproj/christopherjohnson.perspectivev3 +++ b/plugins/MacAU/BrassRider/BrassRider.xcodeproj/christopherjohnson.perspectivev3 @@ -178,7 +178,7 @@ <key>FavBarConfig</key> <dict> <key>PBXProjectModuleGUID</key> - <string>8BE6264D2157B5E900E4E476</string> + <string>8B610FDF2245A8ED001915CF</string> <key>XCBarModuleItemNames</key> <dict/> <key>XCBarModuleItems</key> @@ -256,6 +256,8 @@ <key>Layout</key> <array> <dict> + <key>BecomeActive</key> + <true/> <key>ContentConfiguration</key> <dict> <key>PBXBottomSmartGroupGIDs</key> @@ -322,7 +324,7 @@ <real>185</real> </array> <key>RubberWindowFrame</key> - <string>265 346 810 487 0 0 1440 878 </string> + <string>595 320 810 487 0 0 1440 878 </string> </dict> <key>Module</key> <string>PBXSmartGroupTreeModule</string> @@ -336,7 +338,7 @@ <key>ContentConfiguration</key> <dict> <key>PBXProjectModuleGUID</key> - <string>8BE626402157B5CA00E4E476</string> + <string>8B610FDA2245A8ED001915CF</string> <key>PBXProjectModuleLabel</key> <string>BrassRider.h</string> <key>PBXSplitModuleInNavigatorKey</key> @@ -344,16 +346,17 @@ <key>Split0</key> <dict> <key>PBXProjectModuleGUID</key> - <string>8BE626412157B5CA00E4E476</string> + <string>8B610FDB2245A8ED001915CF</string> <key>PBXProjectModuleLabel</key> <string>BrassRider.h</string> <key>_historyCapacity</key> <integer>0</integer> <key>bookmark</key> - <string>8BE626492157B5E900E4E476</string> + <string>8B61124B2247E63A001915CF</string> <key>history</key> <array> - <string>8BE626432157B5CA00E4E476</string> + <string>8B6112492247E63A001915CF</string> + <string>8B61124A2247E63A001915CF</string> </array> </dict> <key>SplitCount</key> @@ -369,7 +372,7 @@ <key>Frame</key> <string>{{0, 0}, {603, 132}}</string> <key>RubberWindowFrame</key> - <string>265 346 810 487 0 0 1440 878 </string> + <string>595 320 810 487 0 0 1440 878 </string> </dict> <key>Module</key> <string>PBXNavigatorGroup</string> @@ -393,6 +396,8 @@ <dict> <key>Frame</key> <string>{{10, 27}, {603, 282}}</string> + <key>RubberWindowFrame</key> + <string>595 320 810 487 0 0 1440 878 </string> </dict> <key>Module</key> <string>XCDetailModule</string> @@ -446,9 +451,7 @@ <key>GeometryConfiguration</key> <dict> <key>Frame</key> - <string>{{10, 27}, {603, 282}}</string> - <key>RubberWindowFrame</key> - <string>265 346 810 487 0 0 1440 878 </string> + <string>{{10, 27}, {603, 414}}</string> </dict> <key>Module</key> <string>PBXBuildResultsModule</string> @@ -476,11 +479,11 @@ </array> <key>TableOfContents</key> <array> - <string>8BE6264A2157B5E900E4E476</string> + <string>8B61124C2247E63A001915CF</string> <string>1CA23ED40692098700951B8B</string> - <string>8BE6264B2157B5E900E4E476</string> - <string>8BE626402157B5CA00E4E476</string> - <string>8BE6264C2157B5E900E4E476</string> + <string>8B61124D2247E63A001915CF</string> + <string>8B610FDA2245A8ED001915CF</string> + <string>8B61124E2247E63A001915CF</string> <string>1CA23EDF0692099D00951B8B</string> <string>1CA23EE00692099D00951B8B</string> <string>1CA23EE10692099D00951B8B</string> @@ -633,7 +636,7 @@ <key>StatusbarIsVisible</key> <true/> <key>TimeStamp</key> - <real>559396329.57150996</real> + <real>575137338.85792196</real> <key>ToolbarConfigUserDefaultsMinorVersion</key> <string>2</string> <key>ToolbarDisplayMode</key> @@ -650,11 +653,10 @@ <integer>5</integer> <key>WindowOrderList</key> <array> - <string>8BE6264E2157B5E900E4E476</string> - <string>/Users/christopherjohnson/Desktop/BrassRider/BrassRider.xcodeproj</string> + <string>/Users/christopherjohnson/Desktop/Plugins/MacAU/BrassRider/BrassRider.xcodeproj</string> </array> <key>WindowString</key> - <string>265 346 810 487 0 0 1440 878 </string> + <string>595 320 810 487 0 0 1440 878 </string> <key>WindowToolsV3</key> <array> <dict> |