Skip to content

Commit

Permalink
Add Mackity and MackEQ Airwindows FX (surge-synthesizer#4998)
Browse files Browse the repository at this point in the history
  • Loading branch information
baconpaul authored Sep 6, 2021
1 parent ffb717d commit b0027d1
Show file tree
Hide file tree
Showing 8 changed files with 1,184 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libs/airwindows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ add_library(${PROJECT_NAME}
src/Loud.cpp
src/Loud.h
src/LoudProc.cpp
src/Mackity.cpp
src/Mackity.h
src/MackityProc.cpp
src/MackEQ.cpp
src/MackEQ.h
src/MackEQProc.cpp
src/MatrixVerb.cpp
src/MatrixVerb.h
src/MatrixVerbProc.cpp
Expand Down
5 changes: 5 additions & 0 deletions libs/airwindows/src/AirWinBaseClass_pluginRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include "IronOxide5.h"
#include "Logical4.h"
#include "Loud.h"
#include "Mackity.h"
#include "MackEQ.h"
#include "MatrixVerb.h"
#include "Melt.h"
#include "Mojo.h"
Expand Down Expand Up @@ -166,6 +168,9 @@ std::vector<AirWinBaseClass::Registration> AirWinBaseClass::pluginRegistry()
reg.emplace_back(create<TripleSpread::TripleSpread>, id++, 440, gnStereo, "Triple Spread" );

reg.emplace_back(create<Chamber::Chamber>, id++, 223, gnAmbience, "Chamber" );

reg.emplace_back(create<Mackity::Mackity>, id++, 355, gnSaturation, "Mackity" );
reg.emplace_back(create<MackEQ::MackEQ>, id++, 430, gnFilter, "MackEQ" );
return reg;
}

Expand Down
181 changes: 181 additions & 0 deletions libs/airwindows/src/MackEQ.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
/* ========================================
* MackEQ - MackEQ.h
* Copyright (c) 2016 airwindows, All rights reserved
* ======================================== */

#ifndef __MackEQ_H
#include "MackEQ.h"
#endif

namespace MackEQ {


// AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new MackEQ(audioMaster);}

MackEQ::MackEQ(audioMasterCallback audioMaster) :
AudioEffectX(audioMaster, kNumPrograms, kNumParameters)
{
A = 0.1;
B = 0.5;
C = 0.5;
D = 1.0;
E = 1.0;

iirSampleAL = 0.0;
iirSampleBL = 0.0;
iirSampleCL = 0.0;
iirSampleDL = 0.0;
iirSampleEL = 0.0;
iirSampleFL = 0.0;
iirSampleAR = 0.0;
iirSampleBR = 0.0;
iirSampleCR = 0.0;
iirSampleDR = 0.0;
iirSampleER = 0.0;
iirSampleFR = 0.0;
for (int x = 0; x < 15; x++) {biquadA[x] = 0.0; biquadB[x] = 0.0; biquadC[x] = 0.0; biquadD[x] = 0.0;}

fpdL = 1.0; while (fpdL < 16386) fpdL = rand()*UINT32_MAX;
fpdR = 1.0; while (fpdR < 16386) fpdR = rand()*UINT32_MAX;
//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
}

MackEQ::~MackEQ() {}
VstInt32 MackEQ::getVendorVersion () {return 1000;}
void MackEQ::setProgramName(char *name) {vst_strncpy (_programName, name, kVstMaxProgNameLen);}
void MackEQ::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 MackEQ::getChunk (void** data, bool isPreset)
{
float *chunkData = (float *)calloc(kNumParameters, sizeof(float));
chunkData[0] = A;
chunkData[1] = B;
chunkData[2] = C;
chunkData[3] = D;
chunkData[4] = E;
/* 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 MackEQ::setChunk (void* data, VstInt32 byteSize, bool isPreset)
{
float *chunkData = (float *)data;
A = pinParameter(chunkData[0]);
B = pinParameter(chunkData[1]);
C = pinParameter(chunkData[2]);
D = pinParameter(chunkData[3]);
E = pinParameter(chunkData[4]);
/* 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 MackEQ::setParameter(VstInt32 index, float value) {
switch (index) {
case kParamA: A = value; break;
case kParamB: B = value; break;
case kParamC: C = value; break;
case kParamD: D = value; break;
case kParamE: E = value; break;
default: throw; // unknown parameter, shouldn't happen!
}
}

float MackEQ::getParameter(VstInt32 index) {
switch (index) {
case kParamA: return A; break;
case kParamB: return B; break;
case kParamC: return C; break;
case kParamD: return D; break;
case kParamE: return E; 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 MackEQ::getParameterName(VstInt32 index, char *text) {
switch (index) {
case kParamA: vst_strncpy (text, "Trim", kVstMaxParamStrLen); break;
case kParamB: vst_strncpy (text, "Hi", kVstMaxParamStrLen); break;
case kParamC: vst_strncpy (text, "Lo", kVstMaxParamStrLen); break;
case kParamD: vst_strncpy (text, "Gain", kVstMaxParamStrLen); break;
case kParamE: 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 MackEQ::getParameterDisplay(VstInt32 index, char *text, float extVal, bool isExternal) {
switch (index) {
case kParamA: float2string (EXTV(A) * 100, text, kVstMaxParamStrLen); break;
case kParamB: float2string (EXTV(B) * 100, text, kVstMaxParamStrLen); break;
case kParamC: float2string (EXTV(C) * 100, text, kVstMaxParamStrLen); break;
case kParamD: float2string (EXTV(D) * 100, text, kVstMaxParamStrLen); break;
case kParamE: float2string (EXTV(E) * 100, text, kVstMaxParamStrLen); break;
default: break; // unknown parameter, shouldn't happen!
} //this displays the values and handles 'popups' where it's discrete choices
}

void MackEQ::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;
case kParamD: vst_strncpy (text, "%", kVstMaxParamStrLen); break;
case kParamE: vst_strncpy (text, "%", kVstMaxParamStrLen); break;
default: break; // unknown parameter, shouldn't happen!
}
}


bool MackEQ::parseParameterValueFromString(VstInt32 index, const char *str, float &f)
{
auto v = std::atof(str);
f = v / 100.0;
return true;
}

VstInt32 MackEQ::canDo(char *text)
{ return (_canDo.find(text) == _canDo.end()) ? -1: 1; } // 1 = yes, -1 = no, 0 = don't know

bool MackEQ::getEffectName(char* name) {
vst_strncpy(name, "MackEQ", kVstMaxProductStrLen); return true;
}

VstPlugCategory MackEQ::getPlugCategory() {return kPlugCategEffect;}

bool MackEQ::getProductString(char* text) {
vst_strncpy (text, "airwindows MackEQ", kVstMaxProductStrLen); return true;
}

bool MackEQ::getVendorString(char* text) {
vst_strncpy (text, "airwindows", kVstMaxVendorStrLen); return true;
}


} // end namespace MackEQ

94 changes: 94 additions & 0 deletions libs/airwindows/src/MackEQ.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/* ========================================
* MackEQ - MackEQ.h
* Created 8/12/11 by SPIAdmin
* Copyright (c) 2011 __MyCompanyName__, All rights reserved
* ======================================== */

#ifndef __MackEQ_H
#define __MackEQ_H

#ifndef __audioeffect__
#include "airwindows/AirWinBaseClass.h"
#endif

#include <set>
#include <string>
#include <math.h>

namespace MackEQ {

enum {
kParamA = 0,
kParamB = 1,
kParamC = 2,
kParamD = 3,
kParamE = 4,
kNumParameters = 5
}; //

const int kNumPrograms = 0;
const int kNumInputs = 2;
const int kNumOutputs = 2;
const unsigned long kUniqueId = 'mkeq'; //Change this to what the AU identity is!

class MackEQ :
public AudioEffectX
{
public:
MackEQ(audioMasterCallback audioMaster);
~MackEQ();
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, float extVal, bool isExternal); // text description of the current value
virtual bool parseParameterValueFromString(VstInt32 index, const char *str, float &f);

virtual VstInt32 canDo(char *text);
private:
char _programName[kVstMaxProgNameLen + 1];
std::set< std::string > _canDo;

long double iirSampleAL;
long double iirSampleBL;
long double iirSampleCL;
long double iirSampleDL;
long double iirSampleEL;
long double iirSampleFL;
long double iirSampleAR;
long double iirSampleBR;
long double iirSampleCR;
long double iirSampleDR;
long double iirSampleER;
long double iirSampleFR;
long double biquadA[15];
long double biquadB[15];
long double biquadC[15];
long double biquadD[15];

uint32_t fpdL;
uint32_t fpdR;
//default stuff

float A;
float B;
float C;
float D;
float E; //parameters. Always 0-1, and we scale/alter them elsewhere.

};

} // end namespace MackEQ

#endif
Loading

0 comments on commit b0027d1

Please sign in to comment.