aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/MacVST/VinylDither/source
diff options
context:
space:
mode:
authorChris Johnson <jinx6568@sover.net>2018-09-02 22:35:13 -0400
committerChris Johnson <jinx6568@sover.net>2018-09-02 22:35:13 -0400
commitb4f55328448d087a68e6f658638fb3d38d86be12 (patch)
tree217a6d4c9ecc1c34e15e3f9e3774cc9858e39bfa /plugins/MacVST/VinylDither/source
parentdea49efc0e05cdd55c00ce701aecef2bd742fc8c (diff)
downloadairwindows-lv2-port-b4f55328448d087a68e6f658638fb3d38d86be12.tar.gz
airwindows-lv2-port-b4f55328448d087a68e6f658638fb3d38d86be12.tar.bz2
airwindows-lv2-port-b4f55328448d087a68e6f658638fb3d38d86be12.zip
Ditherbox… and individual dithers
Diffstat (limited to 'plugins/MacVST/VinylDither/source')
-rwxr-xr-xplugins/MacVST/VinylDither/source/VinylDither.cpp113
-rwxr-xr-xplugins/MacVST/VinylDither/source/VinylDither.h63
-rwxr-xr-xplugins/MacVST/VinylDither/source/VinylDitherProc.cpp340
3 files changed, 516 insertions, 0 deletions
diff --git a/plugins/MacVST/VinylDither/source/VinylDither.cpp b/plugins/MacVST/VinylDither/source/VinylDither.cpp
new file mode 100755
index 0000000..3b197b5
--- /dev/null
+++ b/plugins/MacVST/VinylDither/source/VinylDither.cpp
@@ -0,0 +1,113 @@
+/* ========================================
+ * VinylDither - VinylDither.h
+ * Copyright (c) 2016 airwindows, All rights reserved
+ * ======================================== */
+
+#ifndef __VinylDither_H
+#include "VinylDither.h"
+#endif
+
+AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new VinylDither(audioMaster);}
+
+VinylDither::VinylDither(audioMasterCallback audioMaster) :
+ AudioEffectX(audioMaster, kNumPrograms, kNumParameters)
+{
+ NSOddL = 0.0;
+ prevL = 0.0;
+ nsL[0] = 0;
+ nsL[1] = 0;
+ nsL[2] = 0;
+ nsL[3] = 0;
+ nsL[4] = 0;
+ nsL[5] = 0;
+ nsL[6] = 0;
+ nsL[7] = 0;
+ nsL[8] = 0;
+ nsL[9] = 0;
+ nsL[10] = 0;
+ nsL[11] = 0;
+ nsL[12] = 0;
+ nsL[13] = 0;
+ nsL[14] = 0;
+ nsL[15] = 0;
+ NSOddR = 0.0;
+ prevR = 0.0;
+ nsR[0] = 0;
+ nsR[1] = 0;
+ nsR[2] = 0;
+ nsR[3] = 0;
+ nsR[4] = 0;
+ nsR[5] = 0;
+ nsR[6] = 0;
+ nsR[7] = 0;
+ nsR[8] = 0;
+ nsR[9] = 0;
+ nsR[10] = 0;
+ nsR[11] = 0;
+ nsR[12] = 0;
+ nsR[13] = 0;
+ nsR[14] = 0;
+ nsR[15] = 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.
+ _canDo.insert("plugAsSend"); // plug-in can be used as a send effect.
+ _canDo.insert("x2in2out");
+ setNumInputs(kNumInputs);
+ setNumOutputs(kNumOutputs);
+ setUniqueID(kUniqueId);
+ canProcessReplacing(); // supports output replacing
+ canDoubleReplacing(); // supports double precision processing
+ programsAreChunks(true);
+ vst_strncpy (_programName, "Default", kVstMaxProgNameLen); // default program name
+}
+
+VinylDither::~VinylDither() {}
+VstInt32 VinylDither::getVendorVersion () {return 1000;}
+void VinylDither::setProgramName(char *name) {vst_strncpy (_programName, name, kVstMaxProgNameLen);}
+void VinylDither::getProgramName(char *name) {vst_strncpy (name, _programName, kVstMaxProgNameLen);}
+//airwindows likes to ignore this stuff. Make your own programs, and make a different plugin rather than
+//trying to do versioning and preventing people from using older versions. Maybe they like the old one!
+
+VstInt32 VinylDither::getChunk (void** data, bool isPreset)
+{
+ return kNumParameters * sizeof(float);
+}
+
+VstInt32 VinylDither::setChunk (void* data, VstInt32 byteSize, bool isPreset)
+{
+ return 0;
+}
+
+void VinylDither::setParameter(VstInt32 index, float value) {
+}
+
+float VinylDither::getParameter(VstInt32 index) {
+ return 0.0; //we only need to update the relevant name, this is simple to manage
+}
+
+void VinylDither::getParameterName(VstInt32 index, char *text) {
+}
+
+void VinylDither::getParameterDisplay(VstInt32 index, char *text) {
+}
+
+void VinylDither::getParameterLabel(VstInt32 index, char *text) {
+}
+
+VstInt32 VinylDither::canDo(char *text)
+{ return (_canDo.find(text) == _canDo.end()) ? -1: 1; } // 1 = yes, -1 = no, 0 = don't know
+
+bool VinylDither::getEffectName(char* name) {
+ vst_strncpy(name, "VinylDither", kVstMaxProductStrLen); return true;
+}
+
+VstPlugCategory VinylDither::getPlugCategory() {return kPlugCategEffect;}
+
+bool VinylDither::getProductString(char* text) {
+ vst_strncpy (text, "airwindows VinylDither", kVstMaxProductStrLen); return true;
+}
+
+bool VinylDither::getVendorString(char* text) {
+ vst_strncpy (text, "airwindows", kVstMaxVendorStrLen); return true;
+}
diff --git a/plugins/MacVST/VinylDither/source/VinylDither.h b/plugins/MacVST/VinylDither/source/VinylDither.h
new file mode 100755
index 0000000..6ffe619
--- /dev/null
+++ b/plugins/MacVST/VinylDither/source/VinylDither.h
@@ -0,0 +1,63 @@
+/* ========================================
+ * VinylDither - VinylDither.h
+ * Created 8/12/11 by SPIAdmin
+ * Copyright (c) 2011 __MyCompanyName__, All rights reserved
+ * ======================================== */
+
+#ifndef __VinylDither_H
+#define __VinylDither_H
+
+#ifndef __audioeffect__
+#include "audioeffectx.h"
+#endif
+
+#include <set>
+#include <string>
+#include <math.h>
+
+enum {
+ kNumParameters = 0
+}; //
+
+const int kNumPrograms = 0;
+const int kNumInputs = 2;
+const int kNumOutputs = 2;
+const unsigned long kUniqueId = 'vdth'; //Change this to what the AU identity is!
+
+class VinylDither :
+ public AudioEffectX
+{
+public:
+ VinylDither(audioMasterCallback audioMaster);
+ ~VinylDither();
+ virtual bool getEffectName(char* name); // The plug-in name
+ virtual VstPlugCategory getPlugCategory(); // The general category for the plug-in
+ virtual bool getProductString(char* text); // This is a unique plug-in string provided by Steinberg
+ virtual bool getVendorString(char* text); // Vendor info
+ virtual VstInt32 getVendorVersion(); // Version number
+ virtual void processReplacing (float** inputs, float** outputs, VstInt32 sampleFrames);
+ virtual void processDoubleReplacing (double** inputs, double** outputs, VstInt32 sampleFrames);
+ virtual void getProgramName(char *name); // read the name from the host
+ virtual void setProgramName(char *name); // changes the name of the preset displayed in the host
+ virtual VstInt32 getChunk (void** data, bool isPreset);
+ virtual VstInt32 setChunk (void* data, VstInt32 byteSize, bool isPreset);
+ virtual float getParameter(VstInt32 index); // get the parameter value at the specified index
+ virtual void setParameter(VstInt32 index, float value); // set the parameter at index to value
+ virtual void getParameterLabel(VstInt32 index, char *text); // label for the parameter (eg dB)
+ virtual void getParameterName(VstInt32 index, char *text); // name of the parameter
+ virtual void getParameterDisplay(VstInt32 index, char *text); // text description of the current value
+ virtual VstInt32 canDo(char *text);
+private:
+ char _programName[kVstMaxProgNameLen + 1];
+ std::set< std::string > _canDo;
+
+ double NSOddL;
+ double prevL;
+ double nsL[16];
+ double NSOddR;
+ double prevR;
+ double nsR[16];
+
+};
+
+#endif
diff --git a/plugins/MacVST/VinylDither/source/VinylDitherProc.cpp b/plugins/MacVST/VinylDither/source/VinylDitherProc.cpp
new file mode 100755
index 0000000..099560f
--- /dev/null
+++ b/plugins/MacVST/VinylDither/source/VinylDitherProc.cpp
@@ -0,0 +1,340 @@
+/* ========================================
+ * VinylDither - VinylDither.h
+ * Copyright (c) 2016 airwindows, All rights reserved
+ * ======================================== */
+
+#ifndef __VinylDither_H
+#include "VinylDither.h"
+#endif
+
+void VinylDither::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames)
+{
+ float* in1 = inputs[0];
+ float* in2 = inputs[1];
+ float* out1 = outputs[0];
+ float* out2 = outputs[1];
+
+ double absSample;
+
+ long double inputSampleL;
+ long double inputSampleR;
+
+ while (--sampleFrames >= 0)
+ {
+ inputSampleL = *in1;
+ inputSampleR = *in2;
+ if (inputSampleL<1.2e-38 && -inputSampleL<1.2e-38) {
+ 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;
+ }
+ if (inputSampleR<1.2e-38 && -inputSampleR<1.2e-38) {
+ 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.
+ }
+
+ inputSampleL *= 8388608.0;
+ inputSampleR *= 8388608.0;
+ //0-1 is now one bit, now we dither
+
+ absSample = ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[0] += absSample; nsL[0] /= 2; absSample -= nsL[0];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[1] += absSample; nsL[1] /= 2; absSample -= nsL[1];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[2] += absSample; nsL[2] /= 2; absSample -= nsL[2];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[3] += absSample; nsL[3] /= 2; absSample -= nsL[3];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[4] += absSample; nsL[4] /= 2; absSample -= nsL[4];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[5] += absSample; nsL[5] /= 2; absSample -= nsL[5];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[6] += absSample; nsL[6] /= 2; absSample -= nsL[6];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[7] += absSample; nsL[7] /= 2; absSample -= nsL[7];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[8] += absSample; nsL[8] /= 2; absSample -= nsL[8];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[9] += absSample; nsL[9] /= 2; absSample -= nsL[9];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[10] += absSample; nsL[10] /= 2; absSample -= nsL[10];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[11] += absSample; nsL[11] /= 2; absSample -= nsL[11];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[12] += absSample; nsL[12] /= 2; absSample -= nsL[12];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[13] += absSample; nsL[13] /= 2; absSample -= nsL[13];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[14] += absSample; nsL[14] /= 2; absSample -= nsL[14];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[15] += absSample; nsL[15] /= 2; absSample -= nsL[15];
+ //install noise and then shape it
+ absSample += inputSampleL;
+
+ if (NSOddL > 0) NSOddL -= 0.97;
+ if (NSOddL < 0) NSOddL += 0.97;
+
+ NSOddL -= (NSOddL * NSOddL * NSOddL * 0.475);
+
+ NSOddL += prevL;
+ absSample += (NSOddL*0.475);
+ prevL = floor(absSample) - inputSampleL;
+ inputSampleL = floor(absSample);
+ //TenNines dither L
+
+
+ absSample = ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[0] += absSample; nsR[0] /= 2; absSample -= nsR[0];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[1] += absSample; nsR[1] /= 2; absSample -= nsR[1];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[2] += absSample; nsR[2] /= 2; absSample -= nsR[2];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[3] += absSample; nsR[3] /= 2; absSample -= nsR[3];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[4] += absSample; nsR[4] /= 2; absSample -= nsR[4];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[5] += absSample; nsR[5] /= 2; absSample -= nsR[5];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[6] += absSample; nsR[6] /= 2; absSample -= nsR[6];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[7] += absSample; nsR[7] /= 2; absSample -= nsR[7];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[8] += absSample; nsR[8] /= 2; absSample -= nsR[8];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[9] += absSample; nsR[9] /= 2; absSample -= nsR[9];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[10] += absSample; nsR[10] /= 2; absSample -= nsR[10];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[11] += absSample; nsR[11] /= 2; absSample -= nsR[11];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[12] += absSample; nsR[12] /= 2; absSample -= nsR[12];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[13] += absSample; nsR[13] /= 2; absSample -= nsR[13];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[14] += absSample; nsR[14] /= 2; absSample -= nsR[14];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[15] += absSample; nsR[15] /= 2; absSample -= nsR[15];
+ //install noise and then shape it
+ absSample += inputSampleR;
+
+ if (NSOddR > 0) NSOddR -= 0.97;
+ if (NSOddR < 0) NSOddR += 0.97;
+
+ NSOddR -= (NSOddR * NSOddR * NSOddR * 0.475);
+
+ NSOddR += prevR;
+ absSample += (NSOddR*0.475);
+ prevR = floor(absSample) - inputSampleR;
+ inputSampleR = floor(absSample);
+ //TenNines dither R
+
+ inputSampleL /= 8388608.0;
+ inputSampleR /= 8388608.0;
+
+
+ *out1 = inputSampleL;
+ *out2 = inputSampleR;
+
+ *in1++;
+ *in2++;
+ *out1++;
+ *out2++;
+ }
+}
+
+void VinylDither::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames)
+{
+ double* in1 = inputs[0];
+ double* in2 = inputs[1];
+ double* out1 = outputs[0];
+ double* out2 = outputs[1];
+
+ double absSample;
+
+ long double inputSampleL;
+ long double inputSampleR;
+
+ while (--sampleFrames >= 0)
+ {
+ inputSampleL = *in1;
+ inputSampleR = *in2;
+ if (inputSampleL<1.2e-38 && -inputSampleL<1.2e-38) {
+ 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;
+ }
+ if (inputSampleR<1.2e-38 && -inputSampleR<1.2e-38) {
+ 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.
+ }
+
+ inputSampleL *= 8388608.0;
+ inputSampleR *= 8388608.0;
+ //0-1 is now one bit, now we dither
+
+ absSample = ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[0] += absSample; nsL[0] /= 2; absSample -= nsL[0];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[1] += absSample; nsL[1] /= 2; absSample -= nsL[1];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[2] += absSample; nsL[2] /= 2; absSample -= nsL[2];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[3] += absSample; nsL[3] /= 2; absSample -= nsL[3];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[4] += absSample; nsL[4] /= 2; absSample -= nsL[4];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[5] += absSample; nsL[5] /= 2; absSample -= nsL[5];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[6] += absSample; nsL[6] /= 2; absSample -= nsL[6];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[7] += absSample; nsL[7] /= 2; absSample -= nsL[7];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[8] += absSample; nsL[8] /= 2; absSample -= nsL[8];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[9] += absSample; nsL[9] /= 2; absSample -= nsL[9];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[10] += absSample; nsL[10] /= 2; absSample -= nsL[10];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[11] += absSample; nsL[11] /= 2; absSample -= nsL[11];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[12] += absSample; nsL[12] /= 2; absSample -= nsL[12];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[13] += absSample; nsL[13] /= 2; absSample -= nsL[13];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[14] += absSample; nsL[14] /= 2; absSample -= nsL[14];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsL[15] += absSample; nsL[15] /= 2; absSample -= nsL[15];
+ //install noise and then shape it
+ absSample += inputSampleL;
+
+ if (NSOddL > 0) NSOddL -= 0.97;
+ if (NSOddL < 0) NSOddL += 0.97;
+
+ NSOddL -= (NSOddL * NSOddL * NSOddL * 0.475);
+
+ NSOddL += prevL;
+ absSample += (NSOddL*0.475);
+ prevL = floor(absSample) - inputSampleL;
+ inputSampleL = floor(absSample);
+ //TenNines dither L
+
+
+ absSample = ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[0] += absSample; nsR[0] /= 2; absSample -= nsR[0];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[1] += absSample; nsR[1] /= 2; absSample -= nsR[1];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[2] += absSample; nsR[2] /= 2; absSample -= nsR[2];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[3] += absSample; nsR[3] /= 2; absSample -= nsR[3];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[4] += absSample; nsR[4] /= 2; absSample -= nsR[4];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[5] += absSample; nsR[5] /= 2; absSample -= nsR[5];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[6] += absSample; nsR[6] /= 2; absSample -= nsR[6];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[7] += absSample; nsR[7] /= 2; absSample -= nsR[7];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[8] += absSample; nsR[8] /= 2; absSample -= nsR[8];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[9] += absSample; nsR[9] /= 2; absSample -= nsR[9];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[10] += absSample; nsR[10] /= 2; absSample -= nsR[10];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[11] += absSample; nsR[11] /= 2; absSample -= nsR[11];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[12] += absSample; nsR[12] /= 2; absSample -= nsR[12];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[13] += absSample; nsR[13] /= 2; absSample -= nsR[13];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[14] += absSample; nsR[14] /= 2; absSample -= nsR[14];
+ absSample += ((rand()/(double)RAND_MAX) - 0.5);
+ nsR[15] += absSample; nsR[15] /= 2; absSample -= nsR[15];
+ //install noise and then shape it
+ absSample += inputSampleR;
+
+ if (NSOddR > 0) NSOddR -= 0.97;
+ if (NSOddR < 0) NSOddR += 0.97;
+
+ NSOddR -= (NSOddR * NSOddR * NSOddR * 0.475);
+
+ NSOddR += prevR;
+ absSample += (NSOddR*0.475);
+ prevR = floor(absSample) - inputSampleR;
+ inputSampleR = floor(absSample);
+ //TenNines dither R
+
+ inputSampleL /= 8388608.0;
+ inputSampleR /= 8388608.0;
+
+
+ *out1 = inputSampleL;
+ *out2 = inputSampleR;
+
+ *in1++;
+ *in2++;
+ *out1++;
+ *out2++;
+ }
+} \ No newline at end of file