diff options
author | Chris Johnson <jinx6568@sover.net> | 2020-06-14 21:15:05 -0400 |
---|---|---|
committer | Chris Johnson <jinx6568@sover.net> | 2020-06-14 21:15:05 -0400 |
commit | 6e0febe954289baac253c2b432d1dc4dec403c30 (patch) | |
tree | d8780d64a2a3f4abeeacc780014e4ac8f1d132b7 /plugins/MacAU/Dark/Dark.cpp | |
parent | 169631d08c44b5a46391e5ab90284ef07de46853 (diff) | |
download | airwindows-lv2-port-6e0febe954289baac253c2b432d1dc4dec403c30.tar.gz airwindows-lv2-port-6e0febe954289baac253c2b432d1dc4dec403c30.tar.bz2 airwindows-lv2-port-6e0febe954289baac253c2b432d1dc4dec403c30.zip |
Dark Redux
Diffstat (limited to 'plugins/MacAU/Dark/Dark.cpp')
-rwxr-xr-x | plugins/MacAU/Dark/Dark.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/plugins/MacAU/Dark/Dark.cpp b/plugins/MacAU/Dark/Dark.cpp index 11380b4..5f24cd4 100755 --- a/plugins/MacAU/Dark/Dark.cpp +++ b/plugins/MacAU/Dark/Dark.cpp @@ -60,6 +60,7 @@ Dark::Dark(AudioUnit component) CreateElements(); Globals()->UseIndexedParameters(kNumberOfParameters); SetParameter(kParam_One, kDefaultValue_ParamOne ); + SetParameter(kParam_Two, kDefaultValue_ParamTwo ); #if AU_DEBUG_DISPATCHER mDebugDispatcher = new AUDebugDispatcher (this); @@ -118,6 +119,13 @@ ComponentResult Dark::GetParameterInfo(AudioUnitScope inScope, outParameterInfo.maxValue = kHD; outParameterInfo.defaultValue = kDefaultValue_ParamOne; break; + case kParam_Two: + AUBase::FillInParameterName (outParameterInfo, kParameterTwoName, false); + outParameterInfo.unit = kAudioUnitParameterUnit_Generic; + outParameterInfo.minValue = 0.0; + outParameterInfo.maxValue = 1.0; + outParameterInfo.defaultValue = kDefaultValue_ParamTwo; + break; default: result = kAudioUnitErr_InvalidParameter; break; @@ -197,14 +205,19 @@ void Dark::DarkKernel::Process( const Float32 *inSourceP, if (depth > 98) depth = 98; bool highres = false; if (GetParameter( kParam_One ) == 1) highres = true; + Float32 scaleFactor; + if (highres) scaleFactor = 8388608.0; + else scaleFactor = 32768.0; + Float32 derez = GetParameter( kParam_Two ); + if (derez > 0.0) scaleFactor *= pow(1.0-derez,6); + if (scaleFactor < 1.0) scaleFactor = 1.0; while (nSampleFrames-- > 0) { Float32 inputSample = *sourceP; if (fabs(inputSample)<1.18e-37) inputSample = fpd * 1.18e-37; fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5; - if (highres) inputSample *= 8388608.0; - else inputSample *= 32768.0; + inputSample *= scaleFactor; //0-1 is now one bit, now we dither int quantA = floor(inputSample); @@ -221,8 +234,8 @@ void Dark::DarkKernel::Process( const Float32 *inSourceP, //we are doing that to voice the thing down into the upper mids a bit //it mustn't just soften the brightest treble, it must smooth high mids too - float testA = fabs((lastSample[0] - quantA) - expectedSlew); - float testB = fabs((lastSample[0] - quantB) - expectedSlew); + Float32 testA = fabs((lastSample[0] - quantA) - expectedSlew); + Float32 testB = fabs((lastSample[0] - quantB) - expectedSlew); if (testA < testB) inputSample = quantA; else inputSample = quantB; @@ -235,8 +248,7 @@ void Dark::DarkKernel::Process( const Float32 *inSourceP, } lastSample[0] = inputSample; - if (highres) inputSample /= 8388608.0; - else inputSample /= 32768.0; + inputSample /= scaleFactor; *destP = inputSample; |