From 81f46a860d0431d5de84ea579e080cfdf399fc45 Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Mon, 2 Sep 2019 01:25:03 -0400 Subject: PeaksOnly --- plugins/LinuxVST/CMakeLists.txt | 1 + plugins/LinuxVST/src/PeaksOnly/PeaksOnly.cpp | 70 ++++++ plugins/LinuxVST/src/PeaksOnly/PeaksOnly.h | 69 ++++++ plugins/LinuxVST/src/PeaksOnly/PeaksOnlyProc.cpp | 286 +++++++++++++++++++++++ 4 files changed, 426 insertions(+) create mode 100755 plugins/LinuxVST/src/PeaksOnly/PeaksOnly.cpp create mode 100755 plugins/LinuxVST/src/PeaksOnly/PeaksOnly.h create mode 100755 plugins/LinuxVST/src/PeaksOnly/PeaksOnlyProc.cpp (limited to 'plugins/LinuxVST') diff --git a/plugins/LinuxVST/CMakeLists.txt b/plugins/LinuxVST/CMakeLists.txt index ffd1fd0..42c0c49 100755 --- a/plugins/LinuxVST/CMakeLists.txt +++ b/plugins/LinuxVST/CMakeLists.txt @@ -116,6 +116,7 @@ add_airwindows_plugin(NotJustAnotherDither) add_airwindows_plugin(OneCornerClip) add_airwindows_plugin(Pafnuty) add_airwindows_plugin(PaulDither) +add_airwindows_plugin(PeaksOnly) add_airwindows_plugin(PDBuss) add_airwindows_plugin(PDChannel) add_airwindows_plugin(PhaseNudge) diff --git a/plugins/LinuxVST/src/PeaksOnly/PeaksOnly.cpp b/plugins/LinuxVST/src/PeaksOnly/PeaksOnly.cpp new file mode 100755 index 0000000..db59ae9 --- /dev/null +++ b/plugins/LinuxVST/src/PeaksOnly/PeaksOnly.cpp @@ -0,0 +1,70 @@ +/* ======================================== + * PeaksOnly - PeaksOnly.h + * Copyright (c) 2016 airwindows, All rights reserved + * ======================================== */ + +#ifndef __PeaksOnly_H +#include "PeaksOnly.h" +#endif + +AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new PeaksOnly(audioMaster);} + +PeaksOnly::PeaksOnly(audioMasterCallback audioMaster) : + AudioEffectX(audioMaster, kNumPrograms, kNumParameters) +{ + for(int count = 0; count < 1502; count++) {aL[count] = 0.0; bL[count] = 0.0; cL[count] = 0.0; dL[count] = 0.0;aR[count] = 0.0; bR[count] = 0.0; cR[count] = 0.0; dR[count] = 0.0;} + ax = 1; bx = 1; cx = 1; dx = 1; + 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 +} + +PeaksOnly::~PeaksOnly() {} +VstInt32 PeaksOnly::getVendorVersion () {return 1000;} +void PeaksOnly::setProgramName(char *name) {vst_strncpy (_programName, name, kVstMaxProgNameLen);} +void PeaksOnly::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! + +void PeaksOnly::setParameter(VstInt32 index, float value) { +} + +float PeaksOnly::getParameter(VstInt32 index) { + return 0.0; //we only need to update the relevant name, this is simple to manage +} + +void PeaksOnly::getParameterName(VstInt32 index, char *text) { +} + +void PeaksOnly::getParameterDisplay(VstInt32 index, char *text) { +} + +void PeaksOnly::getParameterLabel(VstInt32 index, char *text) { +} + +VstInt32 PeaksOnly::canDo(char *text) +{ return (_canDo.find(text) == _canDo.end()) ? -1: 1; } // 1 = yes, -1 = no, 0 = don't know + +bool PeaksOnly::getEffectName(char* name) { + vst_strncpy(name, "PeaksOnly", kVstMaxProductStrLen); return true; +} + +VstPlugCategory PeaksOnly::getPlugCategory() {return kPlugCategEffect;} + +bool PeaksOnly::getProductString(char* text) { + vst_strncpy (text, "airwindows PeaksOnly", kVstMaxProductStrLen); return true; +} + +bool PeaksOnly::getVendorString(char* text) { + vst_strncpy (text, "airwindows", kVstMaxVendorStrLen); return true; +} diff --git a/plugins/LinuxVST/src/PeaksOnly/PeaksOnly.h b/plugins/LinuxVST/src/PeaksOnly/PeaksOnly.h new file mode 100755 index 0000000..f7b0ece --- /dev/null +++ b/plugins/LinuxVST/src/PeaksOnly/PeaksOnly.h @@ -0,0 +1,69 @@ +/* ======================================== + * PeaksOnly - PeaksOnly.h + * Created 8/12/11 by SPIAdmin + * Copyright (c) 2011 __MyCompanyName__, All rights reserved + * ======================================== */ + +#ifndef __PeaksOnly_H +#define __PeaksOnly_H + +#ifndef __audioeffect__ +#include "audioeffectx.h" +#endif + +#include +#include +#include + +enum { + kNumParameters = 0 +}; // + +const int kNumPrograms = 0; +const int kNumInputs = 2; +const int kNumOutputs = 2; +const unsigned long kUniqueId = 'peko'; //Change this to what the AU identity is! + +class PeaksOnly : + public AudioEffectX +{ +public: + PeaksOnly(audioMasterCallback audioMaster); + ~PeaksOnly(); + 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 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 + + double aL[1503]; + double bL[1503]; + double cL[1503]; + double dL[1503]; + + double aR[1503]; + double bR[1503]; + double cR[1503]; + double dR[1503]; + + int ax, bx, cx, dx; + +}; + +#endif diff --git a/plugins/LinuxVST/src/PeaksOnly/PeaksOnlyProc.cpp b/plugins/LinuxVST/src/PeaksOnly/PeaksOnlyProc.cpp new file mode 100755 index 0000000..89aa62f --- /dev/null +++ b/plugins/LinuxVST/src/PeaksOnly/PeaksOnlyProc.cpp @@ -0,0 +1,286 @@ +/* ======================================== + * PeaksOnly - PeaksOnly.h + * Copyright (c) 2016 airwindows, All rights reserved + * ======================================== */ + +#ifndef __PeaksOnly_H +#include "PeaksOnly.h" +#endif + +void PeaksOnly::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames) +{ + float* in1 = inputs[0]; + float* in2 = inputs[1]; + float* out1 = outputs[0]; + float* out2 = outputs[1]; + + double overallscale = 1.0; + overallscale /= 44100.0; + overallscale *= getSampleRate(); + + int am = (int)149.0 * overallscale; + int bm = (int)179.0 * overallscale; + int cm = (int)191.0 * overallscale; + int dm = (int)223.0 * overallscale; //these are 'good' primes, spacing out the allpasses + int allpasstemp = 0; + + 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; + + if (inputSampleL > 1.0) inputSampleL = 1.0; + if (inputSampleL < -1.0) inputSampleL = -1.0; + if (inputSampleR > 1.0) inputSampleR = 1.0; + if (inputSampleR < -1.0) inputSampleR = -1.0; + //without this, you can get a NaN condition where it spits out DC offset at full blast! + inputSampleL = asin(inputSampleL); + inputSampleR = asin(inputSampleR); + //amplitude aspect + + allpasstemp = ax - 1; if (allpasstemp < 0 || allpasstemp > am) allpasstemp = am; + inputSampleL -= aL[allpasstemp]*0.5; + inputSampleR -= aR[allpasstemp]*0.5; + aL[ax] = inputSampleL; + aR[ax] = inputSampleR; + inputSampleL *= 0.5; + inputSampleR *= 0.5; + ax--; if (ax < 0 || ax > am) {ax = am;} + inputSampleL += (aL[ax]); + inputSampleR += (aR[ax]); + //a single Midiverb-style allpass + + if (inputSampleL > 1.0) inputSampleL = 1.0; + if (inputSampleL < -1.0) inputSampleL = -1.0; + if (inputSampleR > 1.0) inputSampleR = 1.0; + if (inputSampleR < -1.0) inputSampleR = -1.0; + //without this, you can get a NaN condition where it spits out DC offset at full blast! + inputSampleL = asin(inputSampleL); + inputSampleR = asin(inputSampleR); + //amplitude aspect + + allpasstemp = bx - 1; if (allpasstemp < 0 || allpasstemp > bm) allpasstemp = bm; + inputSampleL -= bL[allpasstemp]*0.5; + inputSampleR -= bR[allpasstemp]*0.5; + bL[bx] = inputSampleL; + bR[bx] = inputSampleR; + inputSampleL *= 0.5; + inputSampleR *= 0.5; + bx--; if (bx < 0 || bx > bm) {bx = bm;} + inputSampleL += (bL[bx]); + inputSampleR += (bR[bx]); + //a single Midiverb-style allpass + + if (inputSampleL > 1.0) inputSampleL = 1.0; + if (inputSampleL < -1.0) inputSampleL = -1.0; + if (inputSampleR > 1.0) inputSampleR = 1.0; + if (inputSampleR < -1.0) inputSampleR = -1.0; + //without this, you can get a NaN condition where it spits out DC offset at full blast! + inputSampleL = asin(inputSampleL); + inputSampleR = asin(inputSampleR); + //amplitude aspect + + allpasstemp = cx - 1; if (allpasstemp < 0 || allpasstemp > cm) allpasstemp = cm; + inputSampleL -= cL[allpasstemp]*0.5; + inputSampleR -= cR[allpasstemp]*0.5; + cL[cx] = inputSampleL; + cR[cx] = inputSampleR; + inputSampleL *= 0.5; + inputSampleR *= 0.5; + cx--; if (cx < 0 || cx > cm) {cx = cm;} + inputSampleL += (cL[cx]); + inputSampleR += (cR[cx]); + //a single Midiverb-style allpass + + if (inputSampleL > 1.0) inputSampleL = 1.0; + if (inputSampleL < -1.0) inputSampleL = -1.0; + if (inputSampleR > 1.0) inputSampleR = 1.0; + if (inputSampleR < -1.0) inputSampleR = -1.0; + //without this, you can get a NaN condition where it spits out DC offset at full blast! + inputSampleL = asin(inputSampleL); + inputSampleR = asin(inputSampleR); + //amplitude aspect + + allpasstemp = dx - 1; if (allpasstemp < 0 || allpasstemp > dm) allpasstemp = dm; + inputSampleL -= dL[allpasstemp]*0.5; + inputSampleR -= dR[allpasstemp]*0.5; + dL[dx] = inputSampleL; + dR[dx] = inputSampleR; + inputSampleL *= 0.5; + inputSampleR *= 0.5; + dx--; if (dx < 0 || dx > dm) {dx = dm;} + inputSampleL += (dL[dx]); + inputSampleR += (dR[dx]); + //a single Midiverb-style allpass + + if (inputSampleL > 1.0) inputSampleL = 1.0; + if (inputSampleL < -1.0) inputSampleL = -1.0; + if (inputSampleR > 1.0) inputSampleR = 1.0; + if (inputSampleR < -1.0) inputSampleR = -1.0; + //without this, you can get a NaN condition where it spits out DC offset at full blast! + inputSampleL = asin(inputSampleL); + inputSampleR = asin(inputSampleR); + //amplitude aspect + + inputSampleL *= 0.63679; //scale it to 0dB output at full blast + inputSampleR *= 0.63679; //scale it to 0dB output at full blast + + //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 PeaksOnly::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames) +{ + double* in1 = inputs[0]; + double* in2 = inputs[1]; + double* out1 = outputs[0]; + double* out2 = outputs[1]; + + double overallscale = 1.0; + overallscale /= 44100.0; + overallscale *= getSampleRate(); + + int am = (int)149.0 * overallscale; + int bm = (int)179.0 * overallscale; + int cm = (int)191.0 * overallscale; + int dm = (int)223.0 * overallscale; //these are 'good' primes, spacing out the allpasses + int allpasstemp = 0; + + 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; + + if (inputSampleL > 1.0) inputSampleL = 1.0; + if (inputSampleL < -1.0) inputSampleL = -1.0; + if (inputSampleR > 1.0) inputSampleR = 1.0; + if (inputSampleR < -1.0) inputSampleR = -1.0; + //without this, you can get a NaN condition where it spits out DC offset at full blast! + inputSampleL = asin(inputSampleL); + inputSampleR = asin(inputSampleR); + //amplitude aspect + + allpasstemp = ax - 1; if (allpasstemp < 0 || allpasstemp > am) allpasstemp = am; + inputSampleL -= aL[allpasstemp]*0.5; + inputSampleR -= aR[allpasstemp]*0.5; + aL[ax] = inputSampleL; + aR[ax] = inputSampleR; + inputSampleL *= 0.5; + inputSampleR *= 0.5; + ax--; if (ax < 0 || ax > am) {ax = am;} + inputSampleL += (aL[ax]); + inputSampleR += (aR[ax]); + //a single Midiverb-style allpass + + if (inputSampleL > 1.0) inputSampleL = 1.0; + if (inputSampleL < -1.0) inputSampleL = -1.0; + if (inputSampleR > 1.0) inputSampleR = 1.0; + if (inputSampleR < -1.0) inputSampleR = -1.0; + //without this, you can get a NaN condition where it spits out DC offset at full blast! + inputSampleL = asin(inputSampleL); + inputSampleR = asin(inputSampleR); + //amplitude aspect + + allpasstemp = bx - 1; if (allpasstemp < 0 || allpasstemp > bm) allpasstemp = bm; + inputSampleL -= bL[allpasstemp]*0.5; + inputSampleR -= bR[allpasstemp]*0.5; + bL[bx] = inputSampleL; + bR[bx] = inputSampleR; + inputSampleL *= 0.5; + inputSampleR *= 0.5; + bx--; if (bx < 0 || bx > bm) {bx = bm;} + inputSampleL += (bL[bx]); + inputSampleR += (bR[bx]); + //a single Midiverb-style allpass + + if (inputSampleL > 1.0) inputSampleL = 1.0; + if (inputSampleL < -1.0) inputSampleL = -1.0; + if (inputSampleR > 1.0) inputSampleR = 1.0; + if (inputSampleR < -1.0) inputSampleR = -1.0; + //without this, you can get a NaN condition where it spits out DC offset at full blast! + inputSampleL = asin(inputSampleL); + inputSampleR = asin(inputSampleR); + //amplitude aspect + + allpasstemp = cx - 1; if (allpasstemp < 0 || allpasstemp > cm) allpasstemp = cm; + inputSampleL -= cL[allpasstemp]*0.5; + inputSampleR -= cR[allpasstemp]*0.5; + cL[cx] = inputSampleL; + cR[cx] = inputSampleR; + inputSampleL *= 0.5; + inputSampleR *= 0.5; + cx--; if (cx < 0 || cx > cm) {cx = cm;} + inputSampleL += (cL[cx]); + inputSampleR += (cR[cx]); + //a single Midiverb-style allpass + + if (inputSampleL > 1.0) inputSampleL = 1.0; + if (inputSampleL < -1.0) inputSampleL = -1.0; + if (inputSampleR > 1.0) inputSampleR = 1.0; + if (inputSampleR < -1.0) inputSampleR = -1.0; + //without this, you can get a NaN condition where it spits out DC offset at full blast! + inputSampleL = asin(inputSampleL); + inputSampleR = asin(inputSampleR); + //amplitude aspect + + allpasstemp = dx - 1; if (allpasstemp < 0 || allpasstemp > dm) allpasstemp = dm; + inputSampleL -= dL[allpasstemp]*0.5; + inputSampleR -= dR[allpasstemp]*0.5; + dL[dx] = inputSampleL; + dR[dx] = inputSampleR; + inputSampleL *= 0.5; + inputSampleR *= 0.5; + dx--; if (dx < 0 || dx > dm) {dx = dm;} + inputSampleL += (dL[dx]); + inputSampleR += (dR[dx]); + //a single Midiverb-style allpass + + if (inputSampleL > 1.0) inputSampleL = 1.0; + if (inputSampleL < -1.0) inputSampleL = -1.0; + if (inputSampleR > 1.0) inputSampleR = 1.0; + if (inputSampleR < -1.0) inputSampleR = -1.0; + //without this, you can get a NaN condition where it spits out DC offset at full blast! + inputSampleL = asin(inputSampleL); + inputSampleR = asin(inputSampleR); + //amplitude aspect + + inputSampleL *= 0.63679; //scale it to 0dB output at full blast + inputSampleR *= 0.63679; //scale it to 0dB output at full blast + + //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++; + } +} -- cgit v1.2.3