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/LinuxVST/src/Dark/DarkProc.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/LinuxVST/src/Dark/DarkProc.cpp')
-rwxr-xr-x | plugins/LinuxVST/src/Dark/DarkProc.cpp | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/plugins/LinuxVST/src/Dark/DarkProc.cpp b/plugins/LinuxVST/src/Dark/DarkProc.cpp index 672d8e0..2aa85c4 100755 --- a/plugins/LinuxVST/src/Dark/DarkProc.cpp +++ b/plugins/LinuxVST/src/Dark/DarkProc.cpp @@ -22,6 +22,12 @@ void Dark::processReplacing(float **inputs, float **outputs, VstInt32 sampleFram if (depth > 98) depth = 98; bool highres = false; if (processing == 1) highres = true; + float scaleFactor; + if (highres) scaleFactor = 8388608.0; + else scaleFactor = 32768.0; + float derez = B; + if (derez > 0.0) scaleFactor *= pow(1.0-derez,6); + if (scaleFactor < 0.0001) scaleFactor = 0.0001; while (--sampleFrames >= 0) { @@ -32,14 +38,10 @@ void Dark::processReplacing(float **inputs, float **outputs, VstInt32 sampleFram if (fabs(inputSampleR)<1.18e-37) inputSampleR = fpd * 1.18e-37; fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5; - if (highres) { - inputSampleL *= 8388608.0; - inputSampleR *= 8388608.0; - } else { - inputSampleL *= 32768.0; - inputSampleR *= 32768.0; - } + inputSampleL *= scaleFactor; + inputSampleR *= scaleFactor; //0-1 is now one bit, now we dither + //We are doing it first Left, then Right, because the loops may run faster if //they aren't too jammed full of variables. This means re-running code. @@ -103,13 +105,8 @@ void Dark::processReplacing(float **inputs, float **outputs, VstInt32 sampleFram lastSampleR[0] = inputSampleR; //end right - if (highres) { - inputSampleL /= 8388608.0; - inputSampleR /= 8388608.0; - } else { - inputSampleL /= 32768.0; - inputSampleR /= 32768.0; - } + inputSampleL /= scaleFactor; + inputSampleR /= scaleFactor; *out1 = inputSampleL; *out2 = inputSampleR; @@ -137,6 +134,12 @@ void Dark::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sa if (depth > 98) depth = 98; bool highres = false; if (processing == 1) highres = true; + float scaleFactor; + if (highres) scaleFactor = 8388608.0; + else scaleFactor = 32768.0; + float derez = B; + if (derez > 0.0) scaleFactor *= pow(1.0-derez,6); + if (scaleFactor < 1.0) scaleFactor = 1.0; while (--sampleFrames >= 0) { @@ -147,14 +150,10 @@ void Dark::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sa if (fabs(inputSampleR)<1.18e-43) inputSampleR = fpd * 1.18e-43; fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5; - if (highres) { - inputSampleL *= 8388608.0; - inputSampleR *= 8388608.0; - } else { - inputSampleL *= 32768.0; - inputSampleR *= 32768.0; - } + inputSampleL *= scaleFactor; + inputSampleR *= scaleFactor; //0-1 is now one bit, now we dither + //We are doing it first Left, then Right, because the loops may run faster if //they aren't too jammed full of variables. This means re-running code. @@ -218,13 +217,8 @@ void Dark::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sa lastSampleR[0] = inputSampleR; //end right - if (highres) { - inputSampleL /= 8388608.0; - inputSampleR /= 8388608.0; - } else { - inputSampleL /= 32768.0; - inputSampleR /= 32768.0; - } + inputSampleL /= scaleFactor; + inputSampleR /= scaleFactor; *out1 = inputSampleL; *out2 = inputSampleR; |