diff options
author | Chris Johnson <jinx6568@sover.net> | 2019-02-19 08:35:31 -0500 |
---|---|---|
committer | Chris Johnson <jinx6568@sover.net> | 2019-02-19 08:35:31 -0500 |
commit | 83f022409ae017f4ac947430b4ec185f0196badc (patch) | |
tree | 0695ba5bdb872cd72356a62c280fbef490c5aac4 /plugins/MacVST/DitherFloat/source | |
parent | e5da517d26576cbae2f3bc64fc0b9733a5555815 (diff) | |
download | airwindows-lv2-port-83f022409ae017f4ac947430b4ec185f0196badc.tar.gz airwindows-lv2-port-83f022409ae017f4ac947430b4ec185f0196badc.tar.bz2 airwindows-lv2-port-83f022409ae017f4ac947430b4ec185f0196badc.zip |
DitherFloat update
Diffstat (limited to 'plugins/MacVST/DitherFloat/source')
-rwxr-xr-x | plugins/MacVST/DitherFloat/source/DitherFloat.cpp | 3 | ||||
-rwxr-xr-x | plugins/MacVST/DitherFloat/source/DitherFloat.h | 3 | ||||
-rwxr-xr-x | plugins/MacVST/DitherFloat/source/DitherFloatProc.cpp | 28 |
3 files changed, 15 insertions, 19 deletions
diff --git a/plugins/MacVST/DitherFloat/source/DitherFloat.cpp b/plugins/MacVST/DitherFloat/source/DitherFloat.cpp index ffd9e94..05213a6 100755 --- a/plugins/MacVST/DitherFloat/source/DitherFloat.cpp +++ b/plugins/MacVST/DitherFloat/source/DitherFloat.cpp @@ -14,8 +14,7 @@ DitherFloat::DitherFloat(audioMasterCallback audioMaster) : { A = 0.0; B = 1.0; - fpNShapeL = 0.0; - fpNShapeR = 0.0; + fpd = 17; //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/DitherFloat/source/DitherFloat.h b/plugins/MacVST/DitherFloat/source/DitherFloat.h index b8ddf51..08cce74 100755 --- a/plugins/MacVST/DitherFloat/source/DitherFloat.h +++ b/plugins/MacVST/DitherFloat/source/DitherFloat.h @@ -53,8 +53,7 @@ private: char _programName[kVstMaxProgNameLen + 1]; std::set< std::string > _canDo; - long double fpNShapeL; - long double fpNShapeR; + uint32_t fpd; //default stuff float A; diff --git a/plugins/MacVST/DitherFloat/source/DitherFloatProc.cpp b/plugins/MacVST/DitherFloat/source/DitherFloatProc.cpp index 3c76a1a..a7121e8 100755 --- a/plugins/MacVST/DitherFloat/source/DitherFloatProc.cpp +++ b/plugins/MacVST/DitherFloat/source/DitherFloatProc.cpp @@ -67,16 +67,15 @@ void DitherFloat::processReplacing(float **inputs, float **outputs, VstInt32 sam long double inputSampleR = *in2 + (gain-1); - - //stereo 32 bit dither, made small and tidy. + + //begin stereo 32 bit floating point dither int expon; frexpf((float)inputSampleL, &expon); - long double dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62) * blend; //remove 'blend' for real use, it's for the demo; - inputSampleL += (dither-fpNShapeL); fpNShapeL = dither; + fpd ^= fpd<<13; fpd ^= fpd>>17; fpd ^= fpd<<5; + inputSampleL += (fpd*3.4e-36l*pow(2,expon+62)* blend); //remove 'blend' for real use, it's for the demo; frexpf((float)inputSampleR, &expon); - dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62) * blend; //remove 'blend' for real use, it's for the demo; - inputSampleR += (dither-fpNShapeR); fpNShapeR = dither; - //end 32 bit dither - + fpd ^= fpd<<13; fpd ^= fpd>>17; fpd ^= fpd<<5; + inputSampleR += (fpd*3.4e-36l*pow(2,expon+62)* blend); //remove 'blend' for real use, it's for the demo; + //end stereo 32 bit floating point dither inputSampleL = (float)inputSampleL; //equivalent of 'floor' for 32 bit floating point @@ -154,15 +153,14 @@ void DitherFloat::processDoubleReplacing(double **inputs, double **outputs, VstI - //stereo 32 bit dither, made small and tidy. + //begin stereo 32 bit floating point dither int expon; frexpf((float)inputSampleL, &expon); - long double dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62) * blend; //remove 'blend' for real use, it's for the demo; - inputSampleL += (dither-fpNShapeL); fpNShapeL = dither; + fpd ^= fpd<<13; fpd ^= fpd>>17; fpd ^= fpd<<5; + inputSampleL += (fpd*3.4e-36l*pow(2,expon+62)* blend); //remove 'blend' for real use, it's for the demo; frexpf((float)inputSampleR, &expon); - dither = (rand()/(RAND_MAX*7.737125245533627e+25))*pow(2,expon+62) * blend; //remove 'blend' for real use, it's for the demo; - inputSampleR += (dither-fpNShapeR); fpNShapeR = dither; - //end 32 bit dither - + fpd ^= fpd<<13; fpd ^= fpd>>17; fpd ^= fpd<<5; + inputSampleR += (fpd*3.4e-36l*pow(2,expon+62)* blend); //remove 'blend' for real use, it's for the demo; + //end stereo 32 bit floating point dither inputSampleL = (float)inputSampleL; //equivalent of 'floor' for 32 bit floating point |