diff options
author | Chris Johnson <jinx6568@sover.net> | 2018-12-09 17:28:15 -0500 |
---|---|---|
committer | Chris Johnson <jinx6568@sover.net> | 2018-12-09 17:28:15 -0500 |
commit | b25674789c87a1564af673faff8a7ee3dfcbcaf2 (patch) | |
tree | ddbd8518aee90fcba943ac4f1368f133642db7be /plugins/MacVST/DitherMeDiskers/source | |
parent | 6d68aeb7d2a09a5d3515058d3fd98a4b4a908322 (diff) | |
download | airwindows-lv2-port-b25674789c87a1564af673faff8a7ee3dfcbcaf2.tar.gz airwindows-lv2-port-b25674789c87a1564af673faff8a7ee3dfcbcaf2.tar.bz2 airwindows-lv2-port-b25674789c87a1564af673faff8a7ee3dfcbcaf2.zip |
DitherMeTimbers
Diffstat (limited to 'plugins/MacVST/DitherMeDiskers/source')
3 files changed, 246 insertions, 0 deletions
diff --git a/plugins/MacVST/DitherMeDiskers/source/DitherMeDiskers.cpp b/plugins/MacVST/DitherMeDiskers/source/DitherMeDiskers.cpp new file mode 100755 index 0000000..528d547 --- /dev/null +++ b/plugins/MacVST/DitherMeDiskers/source/DitherMeDiskers.cpp @@ -0,0 +1,86 @@ +/* ======================================== + * DitherMeDiskers - DitherMeDiskers.h + * Copyright (c) 2016 airwindows, All rights reserved + * ======================================== */ + +#ifndef __DitherMeDiskers_H +#include "DitherMeDiskers.h" +#endif + +AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new DitherMeDiskers(audioMaster);} + +DitherMeDiskers::DitherMeDiskers(audioMasterCallback audioMaster) : + AudioEffectX(audioMaster, kNumPrograms, kNumParameters) +{ + noiseShapingL = 0.0; + noiseShapingR = 0.0; + lastSampleL = 0.0; + lastSample2L = 0.0; + lastSampleR = 0.0; + lastSample2R = 0.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 +} + +DitherMeDiskers::~DitherMeDiskers() {} +VstInt32 DitherMeDiskers::getVendorVersion () {return 1000;} +void DitherMeDiskers::setProgramName(char *name) {vst_strncpy (_programName, name, kVstMaxProgNameLen);} +void DitherMeDiskers::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 DitherMeDiskers::getChunk (void** data, bool isPreset) +{ + float *chunkData = (float *)calloc(kNumParameters, sizeof(float)); + *data = chunkData; + return kNumParameters * sizeof(float); +} + +VstInt32 DitherMeDiskers::setChunk (void* data, VstInt32 byteSize, bool isPreset) +{ + return 0; +} + +void DitherMeDiskers::setParameter(VstInt32 index, float value) { +} + +float DitherMeDiskers::getParameter(VstInt32 index) { + return 0.0; //we only need to update the relevant name, this is simple to manage +} + +void DitherMeDiskers::getParameterName(VstInt32 index, char *text) { +} + +void DitherMeDiskers::getParameterDisplay(VstInt32 index, char *text) { +} + +void DitherMeDiskers::getParameterLabel(VstInt32 index, char *text) { +} + +VstInt32 DitherMeDiskers::canDo(char *text) +{ return (_canDo.find(text) == _canDo.end()) ? -1: 1; } // 1 = yes, -1 = no, 0 = don't know + +bool DitherMeDiskers::getEffectName(char* name) { + vst_strncpy(name, "DitherMeDiskers", kVstMaxProductStrLen); return true; +} + +VstPlugCategory DitherMeDiskers::getPlugCategory() {return kPlugCategEffect;} + +bool DitherMeDiskers::getProductString(char* text) { + vst_strncpy (text, "airwindows DitherMeDiskers", kVstMaxProductStrLen); return true; +} + +bool DitherMeDiskers::getVendorString(char* text) { + vst_strncpy (text, "airwindows", kVstMaxVendorStrLen); return true; +} diff --git a/plugins/MacVST/DitherMeDiskers/source/DitherMeDiskers.h b/plugins/MacVST/DitherMeDiskers/source/DitherMeDiskers.h new file mode 100755 index 0000000..11f769e --- /dev/null +++ b/plugins/MacVST/DitherMeDiskers/source/DitherMeDiskers.h @@ -0,0 +1,62 @@ +/* ======================================== + * DitherMeDiskers - DitherMeDiskers.h + * Created 8/12/11 by SPIAdmin + * Copyright (c) 2011 __MyCompanyName__, All rights reserved + * ======================================== */ + +#ifndef __DitherMeDiskers_H +#define __DitherMeDiskers_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 = 'dmdk'; //Change this to what the AU identity is! + +class DitherMeDiskers : + public AudioEffectX +{ +public: + DitherMeDiskers(audioMasterCallback audioMaster); + ~DitherMeDiskers(); + 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; + + long double noiseShapingL; + long double noiseShapingR; + double lastSampleL; + double lastSample2L; + double lastSampleR; + double lastSample2R; +}; + +#endif diff --git a/plugins/MacVST/DitherMeDiskers/source/DitherMeDiskersProc.cpp b/plugins/MacVST/DitherMeDiskers/source/DitherMeDiskersProc.cpp new file mode 100755 index 0000000..9f8a34e --- /dev/null +++ b/plugins/MacVST/DitherMeDiskers/source/DitherMeDiskersProc.cpp @@ -0,0 +1,98 @@ +/* ======================================== + * DitherMeDiskers - DitherMeDiskers.h + * Copyright (c) 2016 airwindows, All rights reserved + * ======================================== */ + +#ifndef __DitherMeDiskers_H +#include "DitherMeDiskers.h" +#endif + +void DitherMeDiskers::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames) +{ + float* in1 = inputs[0]; + float* in2 = inputs[1]; + float* out1 = outputs[0]; + float* out2 = outputs[1]; + + while (--sampleFrames >= 0) + { + double inputSampleL = *in1 * 32768.0; + double inputSampleR = *in2 * 32768.0; + double outputSampleL; + double outputSampleR; + + lastSampleL -= (noiseShapingL*0.125); + lastSampleR -= (noiseShapingR*0.125); + + if ((lastSampleL+lastSampleL) >= (inputSampleL+lastSample2L)) outputSampleL = floor(lastSampleL); + else outputSampleL = floor(lastSampleL+1.0); //round down or up based on whether it softens treble angles + + if ((lastSampleR+lastSampleR) >= (inputSampleR+lastSample2R)) outputSampleR = floor(lastSampleR); + else outputSampleR = floor(lastSampleR+1.0); //round down or up based on whether it softens treble angles + + lastSample2L = lastSampleL; + lastSampleL = inputSampleL; //we retain three samples in a row + + lastSample2R = lastSampleR; + lastSampleR = inputSampleR; //we retain three samples in a row + + noiseShapingL += outputSampleL; + noiseShapingL -= lastSampleL; + + noiseShapingR += outputSampleR; + noiseShapingR -= lastSampleR; + + *out1 = outputSampleL / 32768.0; + *out2 = outputSampleR / 32768.0; + + *in1++; + *in2++; + *out1++; + *out2++; + } +} + +void DitherMeDiskers::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames) +{ + double* in1 = inputs[0]; + double* in2 = inputs[1]; + double* out1 = outputs[0]; + double* out2 = outputs[1]; + + while (--sampleFrames >= 0) + { + double inputSampleL = *in1 * 32768.0; + double inputSampleR = *in2 * 32768.0; + double outputSampleL; + double outputSampleR; + + lastSampleL -= (noiseShapingL*0.125); + lastSampleR -= (noiseShapingR*0.125); + + if ((lastSampleL+lastSampleL) >= (inputSampleL+lastSample2L)) outputSampleL = floor(lastSampleL); + else outputSampleL = floor(lastSampleL+1.0); //round down or up based on whether it softens treble angles + + if ((lastSampleR+lastSampleR) >= (inputSampleR+lastSample2R)) outputSampleR = floor(lastSampleR); + else outputSampleR = floor(lastSampleR+1.0); //round down or up based on whether it softens treble angles + + lastSample2L = lastSampleL; + lastSampleL = inputSampleL; //we retain three samples in a row + + lastSample2R = lastSampleR; + lastSampleR = inputSampleR; //we retain three samples in a row + + noiseShapingL += outputSampleL; + noiseShapingL -= lastSampleL; + + noiseShapingR += outputSampleR; + noiseShapingR -= lastSampleR; + + *out1 = outputSampleL / 32768.0; + *out2 = outputSampleR / 32768.0; + + *in1++; + *in2++; + *out1++; + *out2++; + } +} |