aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/LinuxVST/src
diff options
context:
space:
mode:
authorChris Johnson <jinx6568@sover.net>2019-09-29 17:55:45 -0400
committerChris Johnson <jinx6568@sover.net>2019-09-29 17:55:45 -0400
commitd07de3d60d34b95613cc523e40d307b8d8b60d1f (patch)
tree19f3deccd86e77800348c4fcbdb4e3d367b2585e /plugins/LinuxVST/src
parent8209ad4ceba452b470c1d6c347612701c4901dec (diff)
downloadairwindows-lv2-port-d07de3d60d34b95613cc523e40d307b8d8b60d1f.tar.gz
airwindows-lv2-port-d07de3d60d34b95613cc523e40d307b8d8b60d1f.tar.bz2
airwindows-lv2-port-d07de3d60d34b95613cc523e40d307b8d8b60d1f.zip
PurestAir
Diffstat (limited to 'plugins/LinuxVST/src')
-rwxr-xr-xplugins/LinuxVST/src/PurestAir/PurestAir.cpp144
-rwxr-xr-xplugins/LinuxVST/src/PurestAir/PurestAir.h86
-rwxr-xr-xplugins/LinuxVST/src/PurestAir/PurestAirProc.cpp218
3 files changed, 448 insertions, 0 deletions
diff --git a/plugins/LinuxVST/src/PurestAir/PurestAir.cpp b/plugins/LinuxVST/src/PurestAir/PurestAir.cpp
new file mode 100755
index 0000000..3314d21
--- /dev/null
+++ b/plugins/LinuxVST/src/PurestAir/PurestAir.cpp
@@ -0,0 +1,144 @@
+/* ========================================
+ * PurestAir - PurestAir.h
+ * Copyright (c) 2016 airwindows, All rights reserved
+ * ======================================== */
+
+#ifndef __PurestAir_H
+#include "PurestAir.h"
+#endif
+
+AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new PurestAir(audioMaster);}
+
+PurestAir::PurestAir(audioMasterCallback audioMaster) :
+ AudioEffectX(audioMaster, kNumPrograms, kNumParameters)
+{
+ A = 0.5;
+ B = 0.0;
+ C = 1.0;
+ last1SampleL = 0.0;
+ halfwaySampleL = halfDrySampleL = halfDiffSampleL = diffSampleL = 0.0;
+ lastSampleL = 0.0;
+ s1L = s2L = s3L = 0.0;
+ applyL = 0.0;
+ last1SampleR = 0.0;
+ halfwaySampleR = halfDrySampleR = halfDiffSampleR = diffSampleR = 0.0;
+ lastSampleR = 0.0;
+ s1R = s2R = s3R = 0.0;
+ applyR = 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.
+ _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
+}
+
+PurestAir::~PurestAir() {}
+VstInt32 PurestAir::getVendorVersion () {return 1000;}
+void PurestAir::setProgramName(char *name) {vst_strncpy (_programName, name, kVstMaxProgNameLen);}
+void PurestAir::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!
+
+static float pinParameter(float data)
+{
+ if (data < 0.0f) return 0.0f;
+ if (data > 1.0f) return 1.0f;
+ return data;
+}
+
+VstInt32 PurestAir::getChunk (void** data, bool isPreset)
+{
+ float *chunkData = (float *)calloc(kNumParameters, sizeof(float));
+ chunkData[0] = A;
+ chunkData[1] = B;
+ chunkData[2] = C;
+ /* Note: The way this is set up, it will break if you manage to save settings on an Intel
+ machine and load them on a PPC Mac. However, it's fine if you stick to the machine you
+ started with. */
+
+ *data = chunkData;
+ return kNumParameters * sizeof(float);
+}
+
+VstInt32 PurestAir::setChunk (void* data, VstInt32 byteSize, bool isPreset)
+{
+ float *chunkData = (float *)data;
+ A = pinParameter(chunkData[0]);
+ B = pinParameter(chunkData[1]);
+ C = pinParameter(chunkData[2]);
+ /* We're ignoring byteSize as we found it to be a filthy liar */
+
+ /* calculate any other fields you need here - you could copy in
+ code from setParameter() here. */
+ return 0;
+}
+
+void PurestAir::setParameter(VstInt32 index, float value) {
+ switch (index) {
+ case kParamA: A = value; break;
+ case kParamB: B = value; break;
+ case kParamC: C = value; break;
+ default: throw; // unknown parameter, shouldn't happen!
+ }
+}
+
+float PurestAir::getParameter(VstInt32 index) {
+ switch (index) {
+ case kParamA: return A; break;
+ case kParamB: return B; break;
+ case kParamC: return C; break;
+ default: break; // unknown parameter, shouldn't happen!
+ } return 0.0; //we only need to update the relevant name, this is simple to manage
+}
+
+void PurestAir::getParameterName(VstInt32 index, char *text) {
+ switch (index) {
+ case kParamA: vst_strncpy (text, "Boost", kVstMaxParamStrLen); break;
+ case kParamB: vst_strncpy (text, "Limit", kVstMaxParamStrLen); break;
+ case kParamC: vst_strncpy (text, "Dry/Wet", kVstMaxParamStrLen); break;
+ default: break; // unknown parameter, shouldn't happen!
+ } //this is our labels for displaying in the VST host
+}
+
+void PurestAir::getParameterDisplay(VstInt32 index, char *text) {
+ switch (index) {
+ case kParamA: float2string ((A*2.0)-1.0, text, kVstMaxParamStrLen); break;
+ case kParamB: float2string (B, text, kVstMaxParamStrLen); break;
+ case kParamC: float2string (C, text, kVstMaxParamStrLen); break;
+ default: break; // unknown parameter, shouldn't happen!
+ } //this displays the values and handles 'popups' where it's discrete choices
+}
+
+void PurestAir::getParameterLabel(VstInt32 index, char *text) {
+ switch (index) {
+ case kParamA: vst_strncpy (text, "", kVstMaxParamStrLen); break;
+ case kParamB: vst_strncpy (text, "", kVstMaxParamStrLen); break;
+ case kParamC: vst_strncpy (text, "", kVstMaxParamStrLen); break;
+ default: break; // unknown parameter, shouldn't happen!
+ }
+}
+
+VstInt32 PurestAir::canDo(char *text)
+{ return (_canDo.find(text) == _canDo.end()) ? -1: 1; } // 1 = yes, -1 = no, 0 = don't know
+
+bool PurestAir::getEffectName(char* name) {
+ vst_strncpy(name, "PurestAir", kVstMaxProductStrLen); return true;
+}
+
+VstPlugCategory PurestAir::getPlugCategory() {return kPlugCategEffect;}
+
+bool PurestAir::getProductString(char* text) {
+ vst_strncpy (text, "airwindows PurestAir", kVstMaxProductStrLen); return true;
+}
+
+bool PurestAir::getVendorString(char* text) {
+ vst_strncpy (text, "airwindows", kVstMaxVendorStrLen); return true;
+}
diff --git a/plugins/LinuxVST/src/PurestAir/PurestAir.h b/plugins/LinuxVST/src/PurestAir/PurestAir.h
new file mode 100755
index 0000000..5b592c3
--- /dev/null
+++ b/plugins/LinuxVST/src/PurestAir/PurestAir.h
@@ -0,0 +1,86 @@
+/* ========================================
+ * PurestAir - PurestAir.h
+ * Created 8/12/11 by SPIAdmin
+ * Copyright (c) 2011 __MyCompanyName__, All rights reserved
+ * ======================================== */
+
+#ifndef __PurestAir_H
+#define __PurestAir_H
+
+#ifndef __audioeffect__
+#include "audioeffectx.h"
+#endif
+
+#include <set>
+#include <string>
+#include <math.h>
+
+enum {
+ kParamA = 0,
+ kParamB = 1,
+ kParamC = 2,
+ kNumParameters = 3
+}; //
+
+const int kNumPrograms = 0;
+const int kNumInputs = 2;
+const int kNumOutputs = 2;
+const unsigned long kUniqueId = 'pair'; //Change this to what the AU identity is!
+
+class PurestAir :
+ public AudioEffectX
+{
+public:
+ PurestAir(audioMasterCallback audioMaster);
+ ~PurestAir();
+ 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;
+
+ uint32_t fpd;
+ //default stuff
+ long double last1SampleL;
+ long double halfwaySampleL;
+ long double halfDrySampleL;
+ long double halfDiffSampleL;
+ long double diffSampleL;
+ long double lastSampleL;
+ double s1L;
+ double s2L;
+ double s3L;
+ double applyL;
+
+ long double last1SampleR;
+ long double halfwaySampleR;
+ long double halfDrySampleR;
+ long double halfDiffSampleR;
+ long double diffSampleR;
+ long double lastSampleR;
+ double s1R;
+ double s2R;
+ double s3R;
+ double applyR;
+
+ float A;
+ float B;
+ float C;
+};
+
+#endif
diff --git a/plugins/LinuxVST/src/PurestAir/PurestAirProc.cpp b/plugins/LinuxVST/src/PurestAir/PurestAirProc.cpp
new file mode 100755
index 0000000..73939a7
--- /dev/null
+++ b/plugins/LinuxVST/src/PurestAir/PurestAirProc.cpp
@@ -0,0 +1,218 @@
+/* ========================================
+ * PurestAir - PurestAir.h
+ * Copyright (c) 2016 airwindows, All rights reserved
+ * ======================================== */
+
+#ifndef __PurestAir_H
+#include "PurestAir.h"
+#endif
+
+void PurestAir::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames)
+{
+ float* in1 = inputs[0];
+ float* in2 = inputs[1];
+ float* out1 = outputs[0];
+ float* out2 = outputs[1];
+
+ double applyTarget = (A*2.0)-1.0;
+ double threshold = pow((1-fabs(applyTarget)),3);
+ if (applyTarget > 0) applyTarget *= 3;
+
+ double intensity = pow(B,2)*5.0;
+ double wet = C;
+
+ while (--sampleFrames >= 0)
+ {
+ long double inputSampleL = *in1;
+ long double inputSampleR = *in2;
+ if (fabs(inputSampleL)<1.18e-37) inputSampleL = fpd * 1.18e-37;
+ if (fabs(inputSampleR)<1.18e-37) inputSampleR = fpd * 1.18e-37;
+ long double drySampleL = inputSampleL;
+ long double drySampleR = inputSampleR;
+
+ halfDrySampleL = halfwaySampleL = (inputSampleL + last1SampleL) / 2.0;
+ last1SampleL = inputSampleL;
+ s3L = s2L;
+ s2L = s1L;
+ s1L = inputSampleL;
+ double m1 = (s1L-s2L)*((s1L-s2L)/1.3);
+ double m2 = (s2L-s3L)*((s1L-s2L)/1.3);
+ double sense = fabs((m1-m2)*((m1-m2)/1.3))*intensity;
+ //this will be 0 for smooth, high for SSS
+ applyL += applyTarget - sense;
+ applyL *= 0.5;
+ if (applyL < -1.0) applyL = -1.0;
+
+ double clamp = halfwaySampleL - halfDrySampleL;
+ if (clamp > threshold) halfwaySampleL = lastSampleL + threshold;
+ if (-clamp > threshold) halfwaySampleL = lastSampleL - threshold;
+ lastSampleL = halfwaySampleL;
+
+ clamp = inputSampleL - lastSampleL;
+ if (clamp > threshold) inputSampleL = lastSampleL + threshold;
+ if (-clamp > threshold) inputSampleL = lastSampleL - threshold;
+ lastSampleL = inputSampleL;
+
+ diffSampleL = *in1 - inputSampleL;
+ halfDiffSampleL = halfDrySampleL - halfwaySampleL;
+
+ inputSampleL = *in1 + ((diffSampleL + halfDiffSampleL)*applyL);
+ //done with left channel
+
+ halfDrySampleR = halfwaySampleR = (inputSampleR + last1SampleR) / 2.0;
+ last1SampleR = inputSampleR;
+ s3R = s2R;
+ s2R = s1R;
+ s1R = inputSampleR;
+ m1 = (s1R-s2R)*((s1R-s2R)/1.3);
+ m2 = (s2R-s3R)*((s1R-s2R)/1.3);
+ sense = fabs((m1-m2)*((m1-m2)/1.3))*intensity;
+ //this will be 0 for smooth, high for SSS
+ applyR += applyTarget - sense;
+ applyR *= 0.5;
+ if (applyR < -1.0) applyR = -1.0;
+
+ clamp = halfwaySampleR - halfDrySampleR;
+ if (clamp > threshold) halfwaySampleR = lastSampleR + threshold;
+ if (-clamp > threshold) halfwaySampleR = lastSampleR - threshold;
+ lastSampleR = halfwaySampleR;
+
+ clamp = inputSampleR - lastSampleR;
+ if (clamp > threshold) inputSampleR = lastSampleR + threshold;
+ if (-clamp > threshold) inputSampleR = lastSampleR - threshold;
+ lastSampleR = inputSampleR;
+
+ diffSampleR = *in2 - inputSampleR;
+ halfDiffSampleR = halfDrySampleR - halfwaySampleR;
+
+ inputSampleR = *in2 + ((diffSampleR + halfDiffSampleR)*applyR);
+ //done with right channel
+
+ if (wet !=1.0) {
+ inputSampleL = (inputSampleL * wet) + (drySampleL * (1.0-wet));
+ inputSampleR = (inputSampleR * wet) + (drySampleR * (1.0-wet));
+ }
+
+ //begin 32 bit stereo floating point dither
+ int expon; frexpf((float)inputSampleL, &expon);
+ fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5;
+ inputSampleL += ((double(fpd)-uint32_t(0x7fffffff)) * 5.5e-36l * pow(2,expon+62));
+ frexpf((float)inputSampleR, &expon);
+ fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5;
+ inputSampleR += ((double(fpd)-uint32_t(0x7fffffff)) * 5.5e-36l * pow(2,expon+62));
+ //end 32 bit stereo floating point dither
+
+ *out1 = inputSampleL;
+ *out2 = inputSampleR;
+
+ *in1++;
+ *in2++;
+ *out1++;
+ *out2++;
+ }
+}
+
+void PurestAir::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames)
+{
+ double* in1 = inputs[0];
+ double* in2 = inputs[1];
+ double* out1 = outputs[0];
+ double* out2 = outputs[1];
+
+ double applyTarget = (A*2.0)-1.0;
+ double threshold = pow((1-fabs(applyTarget)),3);
+ if (applyTarget > 0) applyTarget *= 3;
+
+ double intensity = pow(B,2)*5.0;
+ double wet = C;
+
+ while (--sampleFrames >= 0)
+ {
+ long double inputSampleL = *in1;
+ long double inputSampleR = *in2;
+ if (fabs(inputSampleL)<1.18e-43) inputSampleL = fpd * 1.18e-43;
+ if (fabs(inputSampleR)<1.18e-43) inputSampleR = fpd * 1.18e-43;
+ long double drySampleL = inputSampleL;
+ long double drySampleR = inputSampleR;
+
+ halfDrySampleL = halfwaySampleL = (inputSampleL + last1SampleL) / 2.0;
+ last1SampleL = inputSampleL;
+ s3L = s2L;
+ s2L = s1L;
+ s1L = inputSampleL;
+ double m1 = (s1L-s2L)*((s1L-s2L)/1.3);
+ double m2 = (s2L-s3L)*((s1L-s2L)/1.3);
+ double sense = fabs((m1-m2)*((m1-m2)/1.3))*intensity;
+ //this will be 0 for smooth, high for SSS
+ applyL += applyTarget - sense;
+ applyL *= 0.5;
+ if (applyL < -1.0) applyL = -1.0;
+
+ double clamp = halfwaySampleL - halfDrySampleL;
+ if (clamp > threshold) halfwaySampleL = lastSampleL + threshold;
+ if (-clamp > threshold) halfwaySampleL = lastSampleL - threshold;
+ lastSampleL = halfwaySampleL;
+
+ clamp = inputSampleL - lastSampleL;
+ if (clamp > threshold) inputSampleL = lastSampleL + threshold;
+ if (-clamp > threshold) inputSampleL = lastSampleL - threshold;
+ lastSampleL = inputSampleL;
+
+ diffSampleL = *in1 - inputSampleL;
+ halfDiffSampleL = halfDrySampleL - halfwaySampleL;
+
+ inputSampleL = *in1 + ((diffSampleL + halfDiffSampleL)*applyL);
+ //done with left channel
+
+ halfDrySampleR = halfwaySampleR = (inputSampleR + last1SampleR) / 2.0;
+ last1SampleR = inputSampleR;
+ s3R = s2R;
+ s2R = s1R;
+ s1R = inputSampleR;
+ m1 = (s1R-s2R)*((s1R-s2R)/1.3);
+ m2 = (s2R-s3R)*((s1R-s2R)/1.3);
+ sense = fabs((m1-m2)*((m1-m2)/1.3))*intensity;
+ //this will be 0 for smooth, high for SSS
+ applyR += applyTarget - sense;
+ applyR *= 0.5;
+ if (applyR < -1.0) applyR = -1.0;
+
+ clamp = halfwaySampleR - halfDrySampleR;
+ if (clamp > threshold) halfwaySampleR = lastSampleR + threshold;
+ if (-clamp > threshold) halfwaySampleR = lastSampleR - threshold;
+ lastSampleR = halfwaySampleR;
+
+ clamp = inputSampleR - lastSampleR;
+ if (clamp > threshold) inputSampleR = lastSampleR + threshold;
+ if (-clamp > threshold) inputSampleR = lastSampleR - threshold;
+ lastSampleR = inputSampleR;
+
+ diffSampleR = *in2 - inputSampleR;
+ halfDiffSampleR = halfDrySampleR - halfwaySampleR;
+
+ inputSampleR = *in2 + ((diffSampleR + halfDiffSampleR)*applyR);
+ //done with right channel
+
+ if (wet !=1.0) {
+ inputSampleL = (inputSampleL * wet) + (drySampleL * (1.0-wet));
+ inputSampleR = (inputSampleR * wet) + (drySampleR * (1.0-wet));
+ }
+
+ //begin 64 bit stereo floating point dither
+ int expon; frexp((double)inputSampleL, &expon);
+ fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5;
+ inputSampleL += ((double(fpd)-uint32_t(0x7fffffff)) * 1.1e-44l * pow(2,expon+62));
+ frexp((double)inputSampleR, &expon);
+ fpd ^= fpd << 13; fpd ^= fpd >> 17; fpd ^= fpd << 5;
+ inputSampleR += ((double(fpd)-uint32_t(0x7fffffff)) * 1.1e-44l * pow(2,expon+62));
+ //end 64 bit stereo floating point dither
+
+ *out1 = inputSampleL;
+ *out2 = inputSampleR;
+
+ *in1++;
+ *in2++;
+ *out1++;
+ *out2++;
+ }
+}