diff options
author | Chris Johnson <jinx6568@sover.net> | 2018-01-21 20:53:47 -0500 |
---|---|---|
committer | Chris Johnson <jinx6568@sover.net> | 2018-01-21 20:53:47 -0500 |
commit | 8c4e1842efd13a80ddc5519d45e29ba5e4695184 (patch) | |
tree | 9117eda262f5bcce359dfb24f17a0418d76b7988 /plugins/MacVST/BitShiftGain/source | |
download | airwindows-lv2-port-8c4e1842efd13a80ddc5519d45e29ba5e4695184.tar.gz airwindows-lv2-port-8c4e1842efd13a80ddc5519d45e29ba5e4695184.tar.bz2 airwindows-lv2-port-8c4e1842efd13a80ddc5519d45e29ba5e4695184.zip |
Initial upload of plugins
Diffstat (limited to 'plugins/MacVST/BitShiftGain/source')
-rwxr-xr-x | plugins/MacVST/BitShiftGain/source/BitShiftGain.cpp | 117 | ||||
-rwxr-xr-x | plugins/MacVST/BitShiftGain/source/BitShiftGain.h | 59 | ||||
-rwxr-xr-x | plugins/MacVST/BitShiftGain/source/BitShiftGainProc.cpp | 126 |
3 files changed, 302 insertions, 0 deletions
diff --git a/plugins/MacVST/BitShiftGain/source/BitShiftGain.cpp b/plugins/MacVST/BitShiftGain/source/BitShiftGain.cpp new file mode 100755 index 0000000..c89bb9f --- /dev/null +++ b/plugins/MacVST/BitShiftGain/source/BitShiftGain.cpp @@ -0,0 +1,117 @@ +/* ======================================== + * BitShiftGain - BitShiftGain.h + * Copyright (c) 2016 airwindows, All rights reserved + * ======================================== */ + +#ifndef __BitShiftGain_H +#include "BitShiftGain.h" +#endif + +AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new BitShiftGain(audioMaster);} + +BitShiftGain::BitShiftGain(audioMasterCallback audioMaster) : + AudioEffectX(audioMaster, kNumPrograms, kNumParameters) +{ + A = 0.5; + //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 +} + +BitShiftGain::~BitShiftGain() {} +VstInt32 BitShiftGain::getVendorVersion () {return 1000;} +void BitShiftGain::setProgramName(char *name) {vst_strncpy (_programName, name, kVstMaxProgNameLen);} +void BitShiftGain::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 BitShiftGain::getChunk (void** data, bool isPreset) +{ + float *chunkData = (float *)calloc(kNumParameters, sizeof(float)); + chunkData[0] = A; + /* 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 BitShiftGain::setChunk (void* data, VstInt32 byteSize, bool isPreset) +{ + float *chunkData = (float *)data; + A = pinParameter(chunkData[0]); + /* 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 BitShiftGain::setParameter(VstInt32 index, float value) { + switch (index) { + case kParamA: A = value; break; + default: throw; // unknown parameter, shouldn't happen! + } +} + +float BitShiftGain::getParameter(VstInt32 index) { + switch (index) { + case kParamA: return A; 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 BitShiftGain::getParameterName(VstInt32 index, char *text) { + switch (index) { + case kParamA: vst_strncpy (text, "BitShift", kVstMaxParamStrLen); break; + default: break; // unknown parameter, shouldn't happen! + } //this is our labels for displaying in the VST host +} + +void BitShiftGain::getParameterDisplay(VstInt32 index, char *text) { + switch (index) { + case kParamA: int2string ((VstInt32)((A * 32)-16), text, kVstMaxParamStrLen); break; + default: break; // unknown parameter, shouldn't happen! + } //this displays the values and handles 'popups' where it's discrete choices +} + +void BitShiftGain::getParameterLabel(VstInt32 index, char *text) { + switch (index) { + case kParamA: vst_strncpy (text, "bits", kVstMaxParamStrLen); break; + default: break; // unknown parameter, shouldn't happen! + } +} + +VstInt32 BitShiftGain::canDo(char *text) +{ return (_canDo.find(text) == _canDo.end()) ? -1: 1; } // 1 = yes, -1 = no, 0 = don't know + +bool BitShiftGain::getEffectName(char* name) { + vst_strncpy(name, "BitShiftGain", kVstMaxProductStrLen); return true; +} + +VstPlugCategory BitShiftGain::getPlugCategory() {return kPlugCategEffect;} + +bool BitShiftGain::getProductString(char* text) { + vst_strncpy (text, "airwindows BitShiftGain", kVstMaxProductStrLen); return true; +} + +bool BitShiftGain::getVendorString(char* text) { + vst_strncpy (text, "airwindows", kVstMaxVendorStrLen); return true; +} diff --git a/plugins/MacVST/BitShiftGain/source/BitShiftGain.h b/plugins/MacVST/BitShiftGain/source/BitShiftGain.h new file mode 100755 index 0000000..00400a2 --- /dev/null +++ b/plugins/MacVST/BitShiftGain/source/BitShiftGain.h @@ -0,0 +1,59 @@ +/* ======================================== + * BitShiftGain - BitShiftGain.h + * Created 8/12/11 by SPIAdmin + * Copyright (c) 2011 __MyCompanyName__, All rights reserved + * ======================================== */ + +#ifndef __BitShiftGain_H +#define __BitShiftGain_H + +#ifndef __audioeffect__ +#include "audioeffectx.h" +#endif + +#include <set> +#include <string> +#include <math.h> + +enum { + kParamA = 0, + kNumParameters = 1 +}; // + +const int kNumPrograms = 0; +const int kNumInputs = 2; +const int kNumOutputs = 2; +const unsigned long kUniqueId = 'btsh'; //Change this to what the AU identity is! + +class BitShiftGain : + public AudioEffectX +{ +public: + BitShiftGain(audioMasterCallback audioMaster); + ~BitShiftGain(); + 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; + + + float A; +}; + +#endif diff --git a/plugins/MacVST/BitShiftGain/source/BitShiftGainProc.cpp b/plugins/MacVST/BitShiftGain/source/BitShiftGainProc.cpp new file mode 100755 index 0000000..c680ebe --- /dev/null +++ b/plugins/MacVST/BitShiftGain/source/BitShiftGainProc.cpp @@ -0,0 +1,126 @@ +/* ======================================== + * BitShiftGain - BitShiftGain.h + * Copyright (c) 2016 airwindows, All rights reserved + * ======================================== */ + +#ifndef __BitShiftGain_H +#include "BitShiftGain.h" +#endif + +void BitShiftGain::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames) +{ + float* in1 = inputs[0]; + float* in2 = inputs[1]; + float* out1 = outputs[0]; + float* out2 = outputs[1]; + + int bitshiftGain = (A * 32)-16; + double gain = 1.0; + switch (bitshiftGain) + { + case -16: gain = 0.0000152587890625; break; + case -15: gain = 0.000030517578125; break; + case -14: gain = 0.00006103515625; break; + case -13: gain = 0.0001220703125; break; + case -12: gain = 0.000244140625; break; + case -11: gain = 0.00048828125; break; + case -10: gain = 0.0009765625; break; + case -9: gain = 0.001953125; break; + case -8: gain = 0.00390625; break; + case -7: gain = 0.0078125; break; + case -6: gain = 0.015625; break; + case -5: gain = 0.03125; break; + case -4: gain = 0.0625; break; + case -3: gain = 0.125; break; + case -2: gain = 0.25; break; + case -1: gain = 0.5; break; + case 0: gain = 1.0; break; + case 1: gain = 2.0; break; + case 2: gain = 4.0; break; + case 3: gain = 8.0; break; + case 4: gain = 16.0; break; + case 5: gain = 32.0; break; + case 6: gain = 64.0; break; + case 7: gain = 128.0; break; + case 8: gain = 256.0; break; + case 9: gain = 512.0; break; + case 10: gain = 1024.0; break; + case 11: gain = 2048.0; break; + case 12: gain = 4096.0; break; + case 13: gain = 8192.0; break; + case 14: gain = 16384.0; break; + case 15: gain = 32768.0; break; + case 16: gain = 65536.0; break; + } + //we are directly punching in the gain values rather than calculating them + + while (--sampleFrames >= 0) + { + *out1 = *in1 * gain; + *out2 = *in2 * gain; + + *in1++; + *in2++; + *out1++; + *out2++; + } +} + +void BitShiftGain::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames) +{ + double* in1 = inputs[0]; + double* in2 = inputs[1]; + double* out1 = outputs[0]; + double* out2 = outputs[1]; + + int bitshiftGain = (A * 32)-16; + double gain = 1.0; + switch (bitshiftGain) + { + case -16: gain = 0.0000152587890625; break; + case -15: gain = 0.000030517578125; break; + case -14: gain = 0.00006103515625; break; + case -13: gain = 0.0001220703125; break; + case -12: gain = 0.000244140625; break; + case -11: gain = 0.00048828125; break; + case -10: gain = 0.0009765625; break; + case -9: gain = 0.001953125; break; + case -8: gain = 0.00390625; break; + case -7: gain = 0.0078125; break; + case -6: gain = 0.015625; break; + case -5: gain = 0.03125; break; + case -4: gain = 0.0625; break; + case -3: gain = 0.125; break; + case -2: gain = 0.25; break; + case -1: gain = 0.5; break; + case 0: gain = 1.0; break; + case 1: gain = 2.0; break; + case 2: gain = 4.0; break; + case 3: gain = 8.0; break; + case 4: gain = 16.0; break; + case 5: gain = 32.0; break; + case 6: gain = 64.0; break; + case 7: gain = 128.0; break; + case 8: gain = 256.0; break; + case 9: gain = 512.0; break; + case 10: gain = 1024.0; break; + case 11: gain = 2048.0; break; + case 12: gain = 4096.0; break; + case 13: gain = 8192.0; break; + case 14: gain = 16384.0; break; + case 15: gain = 32768.0; break; + case 16: gain = 65536.0; break; + } + //we are directly punching in the gain values rather than calculating them + + while (--sampleFrames >= 0) + { + *out1 = *in1 * gain; + *out2 = *in2 * gain; + + *in1++; + *in2++; + *out1++; + *out2++; + } +}
\ No newline at end of file |