|
| 1 | +/* ======================================== |
| 2 | + * DeRez2 - DeRez2.h |
| 3 | + * Copyright (c) 2016 airwindows, Airwindows uses the MIT license |
| 4 | + * ======================================== */ |
| 5 | + |
| 6 | +#ifndef __DeRez2_H |
| 7 | +#include "DeRez2.h" |
| 8 | +#endif |
| 9 | + |
| 10 | +JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wfloat-conversion", "-Wimplicit-float-conversion", "-Wunused-parameter") |
| 11 | + |
| 12 | +DeRez2::DeRez2(audioMasterCallback audioMaster) : |
| 13 | + AudioEffectX(audioMaster, kNumPrograms, kNumParameters) |
| 14 | +{ |
| 15 | + A = 1.0; |
| 16 | + B = 1.0; |
| 17 | + C = 1.0; |
| 18 | + D = 1.0; |
| 19 | + lastSampleL = 0.0; |
| 20 | + heldSampleL = 0.0; |
| 21 | + lastDrySampleL = 0.0; |
| 22 | + lastOutputSampleL = 0.0; |
| 23 | + |
| 24 | + lastSampleR = 0.0; |
| 25 | + heldSampleR = 0.0; |
| 26 | + lastDrySampleR = 0.0; |
| 27 | + lastOutputSampleR = 0.0; |
| 28 | + |
| 29 | + position = 0.0; |
| 30 | + incrementA = 0.0; |
| 31 | + incrementB = 0.0; |
| 32 | + fpdL = 1.0; while (fpdL < 16386) fpdL = rand()*UINT32_MAX; |
| 33 | + fpdR = 1.0; while (fpdR < 16386) fpdR = rand()*UINT32_MAX; |
| 34 | + //this is reset: values being initialized only once. Startup values, whatever they are. |
| 35 | + |
| 36 | + _canDo.insert("plugAsChannelInsert"); // plug-in can be used as a channel insert effect. |
| 37 | + _canDo.insert("plugAsSend"); // plug-in can be used as a send effect. |
| 38 | + _canDo.insert("x2in2out"); |
| 39 | + setNumInputs(kNumInputs); |
| 40 | + setNumOutputs(kNumOutputs); |
| 41 | + setUniqueID(kUniqueId); |
| 42 | + canProcessReplacing(); // supports output replacing |
| 43 | + canDoubleReplacing(); // supports double precision processing |
| 44 | + programsAreChunks(true); |
| 45 | + vst_strncpy (_programName, "Default", kVstMaxProgNameLen); // default program name |
| 46 | +} |
| 47 | + |
| 48 | +DeRez2::~DeRez2() {} |
| 49 | +VstInt32 DeRez2::getVendorVersion () {return 1000;} |
| 50 | +void DeRez2::setProgramName(char *name) {vst_strncpy (_programName, name, kVstMaxProgNameLen);} |
| 51 | +void DeRez2::getProgramName(char *name) {vst_strncpy (name, _programName, kVstMaxProgNameLen);} |
| 52 | +//airwindows likes to ignore this stuff. Make your own programs, and make a different plugin rather than |
| 53 | +//trying to do versioning and preventing people from using older versions. Maybe they like the old one! |
| 54 | + |
| 55 | +static float pinParameter(float data) |
| 56 | +{ |
| 57 | + if (data < 0.0f) return 0.0f; |
| 58 | + if (data > 1.0f) return 1.0f; |
| 59 | + return data; |
| 60 | +} |
| 61 | + |
| 62 | +VstInt32 DeRez2::getChunk (void** data, bool isPreset) |
| 63 | +{ |
| 64 | + float *chunkData = (float *)calloc(kNumParameters, sizeof(float)); |
| 65 | + chunkData[0] = A; |
| 66 | + chunkData[1] = B; |
| 67 | + chunkData[2] = C; |
| 68 | + chunkData[3] = D; |
| 69 | + /* Note: The way this is set up, it will break if you manage to save settings on an Intel |
| 70 | + machine and load them on a PPC Mac. However, it's fine if you stick to the machine you |
| 71 | + started with. */ |
| 72 | + |
| 73 | + *data = chunkData; |
| 74 | + return kNumParameters * sizeof(float); |
| 75 | +} |
| 76 | + |
| 77 | +VstInt32 DeRez2::setChunk (void* data, VstInt32 byteSize, bool isPreset) |
| 78 | +{ |
| 79 | + float *chunkData = (float *)data; |
| 80 | + A = pinParameter(chunkData[0]); |
| 81 | + B = pinParameter(chunkData[1]); |
| 82 | + C = pinParameter(chunkData[2]); |
| 83 | + D = pinParameter(chunkData[3]); |
| 84 | + /* We're ignoring byteSize as we found it to be a filthy liar */ |
| 85 | + |
| 86 | + /* calculate any other fields you need here - you could copy in |
| 87 | + code from setParameter() here. */ |
| 88 | + return 0; |
| 89 | +} |
| 90 | + |
| 91 | +void DeRez2::setParameter(VstInt32 index, float value) { |
| 92 | + switch (index) { |
| 93 | + case kParamA: A = value; break; |
| 94 | + case kParamB: B = value; break; |
| 95 | + case kParamC: C = value; break; |
| 96 | + case kParamD: D = value; break; |
| 97 | + default: throw; // unknown parameter, shouldn't happen! |
| 98 | + } |
| 99 | +} |
| 100 | + |
| 101 | +float DeRez2::getParameter(VstInt32 index) { |
| 102 | + switch (index) { |
| 103 | + case kParamA: return A; break; |
| 104 | + case kParamB: return B; break; |
| 105 | + case kParamC: return C; break; |
| 106 | + case kParamD: return D; break; |
| 107 | + default: break; // unknown parameter, shouldn't happen! |
| 108 | + } return 0.0; //we only need to update the relevant name, this is simple to manage |
| 109 | +} |
| 110 | + |
| 111 | +void DeRez2::getParameterName(VstInt32 index, char *text) { |
| 112 | + switch (index) { |
| 113 | + case kParamA: vst_strncpy (text, "Rate", kVstMaxParamStrLen); break; |
| 114 | + case kParamB: vst_strncpy (text, "Rez", kVstMaxParamStrLen); break; |
| 115 | + case kParamC: vst_strncpy (text, "Hard", kVstMaxParamStrLen); break; |
| 116 | + case kParamD: vst_strncpy (text, "Dry/Wet", kVstMaxParamStrLen); break; |
| 117 | + default: break; // unknown parameter, shouldn't happen! |
| 118 | + } //this is our labels for displaying in the VST host |
| 119 | +} |
| 120 | + |
| 121 | +void DeRez2::getParameterDisplay(VstInt32 index, char *text) { |
| 122 | + switch (index) { |
| 123 | + case kParamA: float2string (A, text, kVstMaxParamStrLen); break; |
| 124 | + case kParamB: float2string (B, text, kVstMaxParamStrLen); break; |
| 125 | + case kParamC: float2string (C, text, kVstMaxParamStrLen); break; |
| 126 | + case kParamD: float2string (D, text, kVstMaxParamStrLen); break; |
| 127 | + default: break; // unknown parameter, shouldn't happen! |
| 128 | + } //this displays the values and handles 'popups' where it's discrete choices |
| 129 | +} |
| 130 | + |
| 131 | +void DeRez2::getParameterLabel(VstInt32 index, char *text) { |
| 132 | + switch (index) { |
| 133 | + case kParamA: vst_strncpy (text, "", kVstMaxParamStrLen); break; |
| 134 | + case kParamB: vst_strncpy (text, "", kVstMaxParamStrLen); break; |
| 135 | + case kParamC: vst_strncpy (text, "", kVstMaxParamStrLen); break; |
| 136 | + case kParamD: vst_strncpy (text, "", kVstMaxParamStrLen); break; |
| 137 | + default: break; // unknown parameter, shouldn't happen! |
| 138 | + } |
| 139 | +} |
| 140 | + |
| 141 | +VstInt32 DeRez2::canDo(char *text) |
| 142 | +{ return (_canDo.find(text) == _canDo.end()) ? -1: 1; } // 1 = yes, -1 = no, 0 = don't know |
| 143 | + |
| 144 | +bool DeRez2::getEffectName(char* name) { |
| 145 | + vst_strncpy(name, "DeRez2", kVstMaxProductStrLen); return true; |
| 146 | +} |
| 147 | + |
| 148 | +VstPlugCategory DeRez2::getPlugCategory() {return kPlugCategEffect;} |
| 149 | + |
| 150 | +bool DeRez2::getProductString(char* text) { |
| 151 | + vst_strncpy (text, "airwindows DeRez2", kVstMaxProductStrLen); return true; |
| 152 | +} |
| 153 | + |
| 154 | +bool DeRez2::getVendorString(char* text) { |
| 155 | + vst_strncpy (text, "airwindows", kVstMaxVendorStrLen); return true; |
| 156 | +} |
0 commit comments