mirror of
https://github.com/airwindows/airwindows.git
synced 2026-05-21 06:46:21 -06:00
Baxandall
This commit is contained in:
parent
2970a44069
commit
ebeb1e6ee1
44 changed files with 11434 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ add_airwindows_plugin(Aura)
|
|||
add_airwindows_plugin(Average)
|
||||
add_airwindows_plugin(BassDrive)
|
||||
add_airwindows_plugin(BassKit)
|
||||
add_airwindows_plugin(Baxandall)
|
||||
add_airwindows_plugin(Biquad)
|
||||
add_airwindows_plugin(Biquad2)
|
||||
add_airwindows_plugin(BiquadOneHalf)
|
||||
|
|
|
|||
145
plugins/LinuxVST/src/Baxandall/Baxandall.cpp
Executable file
145
plugins/LinuxVST/src/Baxandall/Baxandall.cpp
Executable file
|
|
@ -0,0 +1,145 @@
|
|||
/* ========================================
|
||||
* Baxandall - Baxandall.h
|
||||
* Copyright (c) 2016 airwindows, All rights reserved
|
||||
* ======================================== */
|
||||
|
||||
#ifndef __Baxandall_H
|
||||
#include "Baxandall.h"
|
||||
#endif
|
||||
|
||||
AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new Baxandall(audioMaster);}
|
||||
|
||||
Baxandall::Baxandall(audioMasterCallback audioMaster) :
|
||||
AudioEffectX(audioMaster, kNumPrograms, kNumParameters)
|
||||
{
|
||||
A = 0.5;
|
||||
B = 0.5;
|
||||
C = 0.5;
|
||||
for (int x = 0; x < 9; x++) {
|
||||
trebleAL[x] = 0.0;
|
||||
trebleBL[x] = 0.0;
|
||||
bassAL[x] = 0.0;
|
||||
bassBL[x] = 0.0;
|
||||
trebleAR[x] = 0.0;
|
||||
trebleBR[x] = 0.0;
|
||||
bassAR[x] = 0.0;
|
||||
bassBR[x] = 0.0;
|
||||
}
|
||||
flip = false;
|
||||
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
|
||||
}
|
||||
|
||||
Baxandall::~Baxandall() {}
|
||||
VstInt32 Baxandall::getVendorVersion () {return 1000;}
|
||||
void Baxandall::setProgramName(char *name) {vst_strncpy (_programName, name, kVstMaxProgNameLen);}
|
||||
void Baxandall::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 Baxandall::getChunk (void** data, bool isPreset)
|
||||
{
|
||||
float *chunkData = (float *)calloc(kNumParameters, sizeof(float));
|
||||
chunkData[0] = A;
|
||||
chunkData[1] = B;
|
||||
chunkData[2] = C;
|
||||
/* 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 Baxandall::setChunk (void* data, VstInt32 byteSize, bool isPreset)
|
||||
{
|
||||
float *chunkData = (float *)data;
|
||||
A = pinParameter(chunkData[0]);
|
||||
B = pinParameter(chunkData[1]);
|
||||
C = pinParameter(chunkData[2]);
|
||||
/* 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 Baxandall::setParameter(VstInt32 index, float value) {
|
||||
switch (index) {
|
||||
case kParamA: A = value; break;
|
||||
case kParamB: B = value; break;
|
||||
case kParamC: C = value; break;
|
||||
default: throw; // unknown parameter, shouldn't happen!
|
||||
}
|
||||
}
|
||||
|
||||
float Baxandall::getParameter(VstInt32 index) {
|
||||
switch (index) {
|
||||
case kParamA: return A; break;
|
||||
case kParamB: return B; break;
|
||||
case kParamC: return C; 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 Baxandall::getParameterName(VstInt32 index, char *text) {
|
||||
switch (index) {
|
||||
case kParamA: vst_strncpy (text, "Treble", kVstMaxParamStrLen); break;
|
||||
case kParamB: vst_strncpy (text, "Bass", kVstMaxParamStrLen); break;
|
||||
case kParamC: vst_strncpy (text, "Output", kVstMaxParamStrLen); break;
|
||||
default: break; // unknown parameter, shouldn't happen!
|
||||
} //this is our labels for displaying in the VST host
|
||||
}
|
||||
|
||||
void Baxandall::getParameterDisplay(VstInt32 index, char *text) {
|
||||
switch (index) {
|
||||
case kParamA: float2string ((A*30.0)-15.0, text, kVstMaxParamStrLen); break;
|
||||
case kParamB: float2string ((B*30.0)-15.0, text, kVstMaxParamStrLen); break;
|
||||
case kParamC: float2string ((C*30.0)-15.0, text, kVstMaxParamStrLen); break;
|
||||
default: break; // unknown parameter, shouldn't happen!
|
||||
} //this displays the values and handles 'popups' where it's discrete choices
|
||||
}
|
||||
|
||||
void Baxandall::getParameterLabel(VstInt32 index, char *text) {
|
||||
switch (index) {
|
||||
case kParamA: vst_strncpy (text, "dB", kVstMaxParamStrLen); break;
|
||||
case kParamB: vst_strncpy (text, "dB", kVstMaxParamStrLen); break;
|
||||
case kParamC: vst_strncpy (text, "dB", kVstMaxParamStrLen); break;
|
||||
default: break; // unknown parameter, shouldn't happen!
|
||||
}
|
||||
}
|
||||
|
||||
VstInt32 Baxandall::canDo(char *text)
|
||||
{ return (_canDo.find(text) == _canDo.end()) ? -1: 1; } // 1 = yes, -1 = no, 0 = don't know
|
||||
|
||||
bool Baxandall::getEffectName(char* name) {
|
||||
vst_strncpy(name, "Baxandall", kVstMaxProductStrLen); return true;
|
||||
}
|
||||
|
||||
VstPlugCategory Baxandall::getPlugCategory() {return kPlugCategEffect;}
|
||||
|
||||
bool Baxandall::getProductString(char* text) {
|
||||
vst_strncpy (text, "airwindows Baxandall", kVstMaxProductStrLen); return true;
|
||||
}
|
||||
|
||||
bool Baxandall::getVendorString(char* text) {
|
||||
vst_strncpy (text, "airwindows", kVstMaxVendorStrLen); return true;
|
||||
}
|
||||
75
plugins/LinuxVST/src/Baxandall/Baxandall.h
Executable file
75
plugins/LinuxVST/src/Baxandall/Baxandall.h
Executable file
|
|
@ -0,0 +1,75 @@
|
|||
/* ========================================
|
||||
* Baxandall - Baxandall.h
|
||||
* Created 8/12/11 by SPIAdmin
|
||||
* Copyright (c) 2011 __MyCompanyName__, All rights reserved
|
||||
* ======================================== */
|
||||
|
||||
#ifndef __Baxandall_H
|
||||
#define __Baxandall_H
|
||||
|
||||
#ifndef __audioeffect__
|
||||
#include "audioeffectx.h"
|
||||
#endif
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <math.h>
|
||||
|
||||
enum {
|
||||
kParamA = 0,
|
||||
kParamB = 1,
|
||||
kParamC = 2,
|
||||
kNumParameters = 3
|
||||
}; //
|
||||
|
||||
const int kNumPrograms = 0;
|
||||
const int kNumInputs = 2;
|
||||
const int kNumOutputs = 2;
|
||||
const unsigned long kUniqueId = 'baxa'; //Change this to what the AU identity is!
|
||||
|
||||
class Baxandall :
|
||||
public AudioEffectX
|
||||
{
|
||||
public:
|
||||
Baxandall(audioMasterCallback audioMaster);
|
||||
~Baxandall();
|
||||
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;
|
||||
|
||||
uint32_t fpd;
|
||||
//default stuff
|
||||
long double trebleAL[9];
|
||||
long double trebleBL[9];
|
||||
long double bassAL[9];
|
||||
long double bassBL[9];
|
||||
|
||||
long double trebleAR[9];
|
||||
long double trebleBR[9];
|
||||
long double bassAR[9];
|
||||
long double bassBR[9];
|
||||
bool flip;
|
||||
|
||||
float A;
|
||||
float B;
|
||||
float C;
|
||||
};
|
||||
|
||||
#endif
|
||||
282
plugins/LinuxVST/src/Baxandall/BaxandallProc.cpp
Executable file
282
plugins/LinuxVST/src/Baxandall/BaxandallProc.cpp
Executable file
|
|
@ -0,0 +1,282 @@
|
|||
/* ========================================
|
||||
* Baxandall - Baxandall.h
|
||||
* Copyright (c) 2016 airwindows, All rights reserved
|
||||
* ======================================== */
|
||||
|
||||
#ifndef __Baxandall_H
|
||||
#include "Baxandall.h"
|
||||
#endif
|
||||
|
||||
void Baxandall::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames)
|
||||
{
|
||||
float* in1 = inputs[0];
|
||||
float* in2 = inputs[1];
|
||||
float* out1 = outputs[0];
|
||||
float* out2 = outputs[1];
|
||||
|
||||
double trebleGain = pow(10.0,((A*30.0)-15.0)/20.0);
|
||||
double trebleFreq = (4410.0*trebleGain)/getSampleRate();
|
||||
if (trebleFreq > 0.45) trebleFreq = 0.45;
|
||||
trebleAL[0] = trebleBL[0] = trebleAR[0] = trebleBR[0] = trebleFreq;
|
||||
double bassGain = pow(10.0,((B*30.0)-15.0)/20.0);
|
||||
double bassFreq = pow(10.0,-((B*30.0)-15.0)/20.0);
|
||||
bassFreq = (4410.0*bassFreq)/getSampleRate();
|
||||
if (bassFreq > 0.45) bassFreq = 0.45;
|
||||
bassAL[0] = bassBL[0] = bassAR[0] = bassBR[0] = bassFreq;
|
||||
trebleAL[1] = trebleBL[1] = trebleAR[1] = trebleBR[1] = 0.4;
|
||||
bassAL[1] = bassBL[1] = bassAR[1] = bassBR[1] = 0.2;
|
||||
double output = pow(10.0,((C*30.0)-15.0)/20.0);
|
||||
|
||||
double K = tan(M_PI * trebleAL[0]);
|
||||
double norm = 1.0 / (1.0 + K / trebleAL[1] + K * K);
|
||||
trebleBL[2] = trebleAL[2] = trebleBR[2] = trebleAR[2] = K * K * norm;
|
||||
trebleBL[3] = trebleAL[3] = trebleBR[3] = trebleAR[3] = 2.0 * trebleAL[2];
|
||||
trebleBL[4] = trebleAL[4] = trebleBR[4] = trebleAR[4] = trebleAL[2];
|
||||
trebleBL[5] = trebleAL[5] = trebleBR[5] = trebleAR[5] = 2.0 * (K * K - 1.0) * norm;
|
||||
trebleBL[6] = trebleAL[6] = trebleBR[6] = trebleAR[6] = (1.0 - K / trebleAL[1] + K * K) * norm;
|
||||
|
||||
K = tan(M_PI * bassAL[0]);
|
||||
norm = 1.0 / (1.0 + K / bassAL[1] + K * K);
|
||||
bassBL[2] = bassAL[2] = bassBR[2] = bassAR[2] = K * K * norm;
|
||||
bassBL[3] = bassAL[3] = bassBR[3] = bassAR[3] = 2.0 * bassAL[2];
|
||||
bassBL[4] = bassAL[4] = bassBR[4] = bassAR[4] = bassAL[2];
|
||||
bassBL[5] = bassAL[5] = bassBR[5] = bassAR[5] = 2.0 * (K * K - 1.0) * norm;
|
||||
bassBL[6] = bassAL[6] = bassBR[6] = bassAR[6] = (1.0 - K / bassAL[1] + K * K) * norm;
|
||||
|
||||
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 (output != 1.0) {
|
||||
inputSampleL *= output;
|
||||
inputSampleR *= output;
|
||||
}//gain trim in front of plugin, in case Console stage clips
|
||||
|
||||
inputSampleL = sin(inputSampleL);
|
||||
inputSampleR = sin(inputSampleR);
|
||||
//encode Console5: good cleanness
|
||||
|
||||
long double trebleSampleL;
|
||||
long double bassSampleL;
|
||||
long double trebleSampleR;
|
||||
long double bassSampleR;
|
||||
|
||||
if (flip)
|
||||
{
|
||||
trebleSampleL = (inputSampleL * trebleAL[2]) + trebleAL[7];
|
||||
trebleAL[7] = (inputSampleL * trebleAL[3]) - (trebleSampleL * trebleAL[5]) + trebleAL[8];
|
||||
trebleAL[8] = (inputSampleL * trebleAL[4]) - (trebleSampleL * trebleAL[6]);
|
||||
trebleSampleL = inputSampleL - trebleSampleL;
|
||||
|
||||
bassSampleL = (inputSampleL * bassAL[2]) + bassAL[7];
|
||||
bassAL[7] = (inputSampleL * bassAL[3]) - (bassSampleL * bassAL[5]) + bassAL[8];
|
||||
bassAL[8] = (inputSampleL * bassAL[4]) - (bassSampleL * bassAL[6]);
|
||||
|
||||
trebleSampleR = (inputSampleR * trebleAR[2]) + trebleAR[7];
|
||||
trebleAR[7] = (inputSampleR * trebleAR[3]) - (trebleSampleR * trebleAR[5]) + trebleAR[8];
|
||||
trebleAR[8] = (inputSampleR * trebleAR[4]) - (trebleSampleR * trebleAR[6]);
|
||||
trebleSampleR = inputSampleR - trebleSampleR;
|
||||
|
||||
bassSampleR = (inputSampleR * bassAR[2]) + bassAR[7];
|
||||
bassAR[7] = (inputSampleR * bassAR[3]) - (bassSampleR * bassAR[5]) + bassAR[8];
|
||||
bassAR[8] = (inputSampleR * bassAR[4]) - (bassSampleR * bassAR[6]);
|
||||
}
|
||||
else
|
||||
{
|
||||
trebleSampleL = (inputSampleL * trebleBL[2]) + trebleBL[7];
|
||||
trebleBL[7] = (inputSampleL * trebleBL[3]) - (trebleSampleL * trebleBL[5]) + trebleBL[8];
|
||||
trebleBL[8] = (inputSampleL * trebleBL[4]) - (trebleSampleL * trebleBL[6]);
|
||||
trebleSampleL = inputSampleL - trebleSampleL;
|
||||
|
||||
bassSampleL = (inputSampleL * bassBL[2]) + bassBL[7];
|
||||
bassBL[7] = (inputSampleL * bassBL[3]) - (bassSampleL * bassBL[5]) + bassBL[8];
|
||||
bassBL[8] = (inputSampleL * bassBL[4]) - (bassSampleL * bassBL[6]);
|
||||
|
||||
trebleSampleR = (inputSampleR * trebleBR[2]) + trebleBR[7];
|
||||
trebleBR[7] = (inputSampleR * trebleBR[3]) - (trebleSampleR * trebleBR[5]) + trebleBR[8];
|
||||
trebleBR[8] = (inputSampleR * trebleBR[4]) - (trebleSampleR * trebleBR[6]);
|
||||
trebleSampleR = inputSampleR - trebleSampleR;
|
||||
|
||||
bassSampleR = (inputSampleR * bassBR[2]) + bassBR[7];
|
||||
bassBR[7] = (inputSampleR * bassBR[3]) - (bassSampleR * bassBR[5]) + bassBR[8];
|
||||
bassBR[8] = (inputSampleR * bassBR[4]) - (bassSampleR * bassBR[6]);
|
||||
}
|
||||
flip = !flip;
|
||||
|
||||
trebleSampleL *= trebleGain;
|
||||
bassSampleL *= bassGain;
|
||||
inputSampleL = bassSampleL + trebleSampleL; //interleaved biquad
|
||||
trebleSampleR *= trebleGain;
|
||||
bassSampleR *= bassGain;
|
||||
inputSampleR = bassSampleR + trebleSampleR; //interleaved biquad
|
||||
|
||||
if (inputSampleL > 1.0) inputSampleL = 1.0;
|
||||
if (inputSampleL < -1.0) inputSampleL = -1.0;
|
||||
//without this, you can get a NaN condition where it spits out DC offset at full blast!
|
||||
inputSampleL = asin(inputSampleL);
|
||||
//amplitude aspect
|
||||
|
||||
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!
|
||||
inputSampleR = asin(inputSampleR);
|
||||
//amplitude aspect
|
||||
|
||||
//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 Baxandall::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames)
|
||||
{
|
||||
double* in1 = inputs[0];
|
||||
double* in2 = inputs[1];
|
||||
double* out1 = outputs[0];
|
||||
double* out2 = outputs[1];
|
||||
|
||||
double trebleGain = pow(10.0,((A*30.0)-15.0)/20.0);
|
||||
double trebleFreq = (4410.0*trebleGain)/getSampleRate();
|
||||
if (trebleFreq > 0.45) trebleFreq = 0.45;
|
||||
trebleAL[0] = trebleBL[0] = trebleAR[0] = trebleBR[0] = trebleFreq;
|
||||
double bassGain = pow(10.0,((B*30.0)-15.0)/20.0);
|
||||
double bassFreq = pow(10.0,-((B*30.0)-15.0)/20.0);
|
||||
bassFreq = (4410.0*bassFreq)/getSampleRate();
|
||||
if (bassFreq > 0.45) bassFreq = 0.45;
|
||||
bassAL[0] = bassBL[0] = bassAR[0] = bassBR[0] = bassFreq;
|
||||
trebleAL[1] = trebleBL[1] = trebleAR[1] = trebleBR[1] = 0.4;
|
||||
bassAL[1] = bassBL[1] = bassAR[1] = bassBR[1] = 0.2;
|
||||
double output = pow(10.0,((C*30.0)-15.0)/20.0);
|
||||
|
||||
double K = tan(M_PI * trebleAL[0]);
|
||||
double norm = 1.0 / (1.0 + K / trebleAL[1] + K * K);
|
||||
trebleBL[2] = trebleAL[2] = trebleBR[2] = trebleAR[2] = K * K * norm;
|
||||
trebleBL[3] = trebleAL[3] = trebleBR[3] = trebleAR[3] = 2.0 * trebleAL[2];
|
||||
trebleBL[4] = trebleAL[4] = trebleBR[4] = trebleAR[4] = trebleAL[2];
|
||||
trebleBL[5] = trebleAL[5] = trebleBR[5] = trebleAR[5] = 2.0 * (K * K - 1.0) * norm;
|
||||
trebleBL[6] = trebleAL[6] = trebleBR[6] = trebleAR[6] = (1.0 - K / trebleAL[1] + K * K) * norm;
|
||||
|
||||
K = tan(M_PI * bassAL[0]);
|
||||
norm = 1.0 / (1.0 + K / bassAL[1] + K * K);
|
||||
bassBL[2] = bassAL[2] = bassBR[2] = bassAR[2] = K * K * norm;
|
||||
bassBL[3] = bassAL[3] = bassBR[3] = bassAR[3] = 2.0 * bassAL[2];
|
||||
bassBL[4] = bassAL[4] = bassBR[4] = bassAR[4] = bassAL[2];
|
||||
bassBL[5] = bassAL[5] = bassBR[5] = bassAR[5] = 2.0 * (K * K - 1.0) * norm;
|
||||
bassBL[6] = bassAL[6] = bassBR[6] = bassAR[6] = (1.0 - K / bassAL[1] + K * K) * norm;
|
||||
|
||||
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 (output != 1.0) {
|
||||
inputSampleL *= output;
|
||||
inputSampleR *= output;
|
||||
}//gain trim in front of plugin, in case Console stage clips
|
||||
|
||||
inputSampleL = sin(inputSampleL);
|
||||
inputSampleR = sin(inputSampleR);
|
||||
//encode Console5: good cleanness
|
||||
|
||||
long double trebleSampleL;
|
||||
long double bassSampleL;
|
||||
long double trebleSampleR;
|
||||
long double bassSampleR;
|
||||
|
||||
if (flip)
|
||||
{
|
||||
trebleSampleL = (inputSampleL * trebleAL[2]) + trebleAL[7];
|
||||
trebleAL[7] = (inputSampleL * trebleAL[3]) - (trebleSampleL * trebleAL[5]) + trebleAL[8];
|
||||
trebleAL[8] = (inputSampleL * trebleAL[4]) - (trebleSampleL * trebleAL[6]);
|
||||
trebleSampleL = inputSampleL - trebleSampleL;
|
||||
|
||||
bassSampleL = (inputSampleL * bassAL[2]) + bassAL[7];
|
||||
bassAL[7] = (inputSampleL * bassAL[3]) - (bassSampleL * bassAL[5]) + bassAL[8];
|
||||
bassAL[8] = (inputSampleL * bassAL[4]) - (bassSampleL * bassAL[6]);
|
||||
|
||||
trebleSampleR = (inputSampleR * trebleAR[2]) + trebleAR[7];
|
||||
trebleAR[7] = (inputSampleR * trebleAR[3]) - (trebleSampleR * trebleAR[5]) + trebleAR[8];
|
||||
trebleAR[8] = (inputSampleR * trebleAR[4]) - (trebleSampleR * trebleAR[6]);
|
||||
trebleSampleR = inputSampleR - trebleSampleR;
|
||||
|
||||
bassSampleR = (inputSampleR * bassAR[2]) + bassAR[7];
|
||||
bassAR[7] = (inputSampleR * bassAR[3]) - (bassSampleR * bassAR[5]) + bassAR[8];
|
||||
bassAR[8] = (inputSampleR * bassAR[4]) - (bassSampleR * bassAR[6]);
|
||||
}
|
||||
else
|
||||
{
|
||||
trebleSampleL = (inputSampleL * trebleBL[2]) + trebleBL[7];
|
||||
trebleBL[7] = (inputSampleL * trebleBL[3]) - (trebleSampleL * trebleBL[5]) + trebleBL[8];
|
||||
trebleBL[8] = (inputSampleL * trebleBL[4]) - (trebleSampleL * trebleBL[6]);
|
||||
trebleSampleL = inputSampleL - trebleSampleL;
|
||||
|
||||
bassSampleL = (inputSampleL * bassBL[2]) + bassBL[7];
|
||||
bassBL[7] = (inputSampleL * bassBL[3]) - (bassSampleL * bassBL[5]) + bassBL[8];
|
||||
bassBL[8] = (inputSampleL * bassBL[4]) - (bassSampleL * bassBL[6]);
|
||||
|
||||
trebleSampleR = (inputSampleR * trebleBR[2]) + trebleBR[7];
|
||||
trebleBR[7] = (inputSampleR * trebleBR[3]) - (trebleSampleR * trebleBR[5]) + trebleBR[8];
|
||||
trebleBR[8] = (inputSampleR * trebleBR[4]) - (trebleSampleR * trebleBR[6]);
|
||||
trebleSampleR = inputSampleR - trebleSampleR;
|
||||
|
||||
bassSampleR = (inputSampleR * bassBR[2]) + bassBR[7];
|
||||
bassBR[7] = (inputSampleR * bassBR[3]) - (bassSampleR * bassBR[5]) + bassBR[8];
|
||||
bassBR[8] = (inputSampleR * bassBR[4]) - (bassSampleR * bassBR[6]);
|
||||
}
|
||||
flip = !flip;
|
||||
|
||||
trebleSampleL *= trebleGain;
|
||||
bassSampleL *= bassGain;
|
||||
inputSampleL = bassSampleL + trebleSampleL; //interleaved biquad
|
||||
trebleSampleR *= trebleGain;
|
||||
bassSampleR *= bassGain;
|
||||
inputSampleR = bassSampleR + trebleSampleR; //interleaved biquad
|
||||
|
||||
if (inputSampleL > 1.0) inputSampleL = 1.0;
|
||||
if (inputSampleL < -1.0) inputSampleL = -1.0;
|
||||
//without this, you can get a NaN condition where it spits out DC offset at full blast!
|
||||
inputSampleL = asin(inputSampleL);
|
||||
//amplitude aspect
|
||||
|
||||
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!
|
||||
inputSampleR = asin(inputSampleR);
|
||||
//amplitude aspect
|
||||
|
||||
//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++;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue