From 0a54362d10fe8658ab398d6cea2b6014691b9b3c Mon Sep 17 00:00:00 2001 From: GithubActions BaconPaul Bot Date: Fri, 10 May 2024 22:11:24 +0000 Subject: [PATCH] Update to Latest Airwin --- libs/airwindows | 2 +- res/awpdoc/HighImpact.txt | 23 + src/ModuleAdd.h | 16 +- src/autogen_airwin/BiquadHiLo.cpp | 123 ++ src/autogen_airwin/BiquadHiLo.h | 80 ++ src/autogen_airwin/BiquadHiLoProc.cpp | 260 ++++ src/autogen_airwin/BiquadStack.cpp | 133 ++ src/autogen_airwin/BiquadStack.h | 81 ++ src/autogen_airwin/BiquadStackProc.cpp | 304 +++++ src/autogen_airwin/CMakeLists.txt | 16 +- src/autogen_airwin/ConsoleXBuss.cpp | 395 ++++-- src/autogen_airwin/ConsoleXBuss.h | 237 ++-- src/autogen_airwin/ConsoleXBussProc.cpp | 1400 ++++++++++++++++---- src/autogen_airwin/ConsoleXChannel.cpp | 393 ++++-- src/autogen_airwin/ConsoleXChannel.h | 238 ++-- src/autogen_airwin/ConsoleXChannelProc.cpp | 1216 +++++++++++++---- src/autogen_airwin/Distance3.cpp | 158 +++ src/autogen_airwin/Distance3.h | 131 ++ src/autogen_airwin/Distance3Proc.cpp | 374 ++++++ src/autogen_airwin/Parametric.cpp | 193 +++ src/autogen_airwin/Parametric.h | 98 ++ src/autogen_airwin/ParametricProc.cpp | 500 +++++++ src/autogen_airwin/Pop3.cpp | 175 +++ src/autogen_airwin/Pop3.h | 83 ++ src/autogen_airwin/Pop3Proc.cpp | 150 +++ src/autogen_airwin/StoneFireComp.cpp | 193 +++ src/autogen_airwin/StoneFireComp.h | 100 ++ src/autogen_airwin/StoneFireCompProc.cpp | 314 +++++ 28 files changed, 6497 insertions(+), 889 deletions(-) create mode 100644 res/awpdoc/HighImpact.txt create mode 100644 src/autogen_airwin/BiquadHiLo.cpp create mode 100644 src/autogen_airwin/BiquadHiLo.h create mode 100644 src/autogen_airwin/BiquadHiLoProc.cpp create mode 100644 src/autogen_airwin/BiquadStack.cpp create mode 100644 src/autogen_airwin/BiquadStack.h create mode 100644 src/autogen_airwin/BiquadStackProc.cpp create mode 100644 src/autogen_airwin/Distance3.cpp create mode 100644 src/autogen_airwin/Distance3.h create mode 100644 src/autogen_airwin/Distance3Proc.cpp create mode 100644 src/autogen_airwin/Parametric.cpp create mode 100644 src/autogen_airwin/Parametric.h create mode 100644 src/autogen_airwin/ParametricProc.cpp create mode 100644 src/autogen_airwin/Pop3.cpp create mode 100644 src/autogen_airwin/Pop3.h create mode 100644 src/autogen_airwin/Pop3Proc.cpp create mode 100644 src/autogen_airwin/StoneFireComp.cpp create mode 100644 src/autogen_airwin/StoneFireComp.h create mode 100644 src/autogen_airwin/StoneFireCompProc.cpp diff --git a/libs/airwindows b/libs/airwindows index ad8ecb5..1e0fd75 160000 --- a/libs/airwindows +++ b/libs/airwindows @@ -1 +1 @@ -Subproject commit ad8ecb58b267d94787687fa860cbdcbc51b967d4 +Subproject commit 1e0fd756ed12ad59028da6eb3d6d023450f8a8fe diff --git a/res/awpdoc/HighImpact.txt b/res/awpdoc/HighImpact.txt new file mode 100644 index 0000000..d1065db --- /dev/null +++ b/res/awpdoc/HighImpact.txt @@ -0,0 +1,23 @@ +# HighImpact is distorted grit and punch without fatness. This is also another little window into Airwindows history, as this is the point where I began putting out the for-pay plugins for free through Patreon. The post is presented in its entirety as a picture of where I was at on April 9, 2017. By now I have put out more than 300 plugins and I'm still going, but this was when I'd done 47 and all the most sought-after ones were still being held back as goals… here is the original post. + +Sometimes it’s all in the name. + +High Impact has been one of the Airwindows secret weapons for a long time. It’s a pretty basic idea: know how Density distorts and makes audio huge and fat, and Drive distorts and doesn’t make stuff as fat? High Impact answers the question, ‘what if you could distort and not make things fatter AT ALL’. + +This is not EQ I’m talking about, though it can come off like EQ depending on what you feed into it. High Impact combines a distortion and anti-distortion circuit to reshape the transfer function of the audio, as follows: crank it up, and quiet subtle samples aren’t turned up much. Then medium samples are turned up a LOT, and then the loudest samples are distorted and hit a wall past which they can’t go. The result is an obvious distort which doesn’t bloat things. It’s a ‘dial-a-rasp’, or ‘dial-a-slam’ for percussive noises, and though the concept is two different kinds of overdrive combined, it’s an Airwindows plugin so it’s not overprocessed, it’s super raw. + +That suits this plugin super well, and that’s why the AU-only High Impact has been a secret weapon for many people for years—and now it’s out for Mac and PC VST. + +A word about the ‘secret weapon’ thing: I hate that. Do as I do, and communicate openly. Airwindows plugins are not preset things that you hide somewhere to add magic sauce to your mixes. They require intention, and there’s no one right way to use them: Airwindows plugins are like if a certain mic modeler you can rent that offers ‘silky expensive microphone models’ had just a blank ugly faceplate with just one knob, ‘silky’. And you could use it as a guitar stompbox if you wanted, not even a microphone anymore, and it was no longer connected to a ‘magic gear item’ so you’d have to ask, ‘HOW silky does this sound need to be, in my mix?’ because there was no one right answer. + +That’s what Airwindows is like. For High Impact, read ‘raspy’ or ‘mean’ or ‘grindy’, whatever describes the sound for you. Now you’ve got an extra parameter: instead of just bass, treble, loud, soft (or even fat and thin) you’ve got ‘aggro’ on a knob. That can relate to any bit of audio you’re working with… and your ‘secret sauce’ is not the plugin, but your sense of taste (or tastelessness) in using and abusing it. So, don’t keep Airwindows plugins a secret weapon. I hate that. Tell people what you’re using, so I can get more supporters and keep doing all this, on a bigger and bigger scale. + +Speaking of which, I have a Patreon milestone! As of a couple days ago, I hit $600 a month, and I’ve recently changed that to be the point where I start releasing the Kagi catalog! Now, people sometimes bail as the first of the month rolls around (and also I don’t get paid quite the full amount shown). So, it’s possible this milestone will go poof as we reach May, in which case we’re still waiting. BUT, if the dust settles and it’s still over $600 going into May, I will put out Iron Oxide 4 (the second most popular plugin I have EVER made) as free AU/VST! + +(oh my God, I look so young in that video o_O ) + +If I’m still over $600 when May begins, you get THAT plugin free. My hope is that, as I reach this stage, people get more of an idea of what’s possible out of my Patreon project. All this time, I’ve been putting out more than 47 plugins entirely from the ‘freebie pile’, and not touching the ones that kept me in business a decade. Now, we start to get into the serious ones, the ones worth $50 to a lot of people. I’ve even drawn up a timeline on the Patreon, showing when each plugin will come out if I stay above $600. (if I clear $1000 they go twice as fast and I’ll revise the timeline accordingly!) + +Here’s where things REALLY get interesting. Hang on to your DAWs, because we’re about to go full warp drive :) + + diff --git a/src/ModuleAdd.h b/src/ModuleAdd.h index 7064480..350cc76 100644 --- a/src/ModuleAdd.h +++ b/src/ModuleAdd.h @@ -52,12 +52,16 @@ int Biquad_unused = AirwinRegistry::registerAirwindow({"Biquad", "Biquads", 45, int Biquad2_unused = AirwinRegistry::registerAirwindow({"Biquad2", "Biquads", 49, "Biquad2 is the Airwindows biquad filter that's more sweepable and synthy.", airwinconsolidated::Biquad2::kNumParameters, []() { return std::make_unique(0); }, -1, { }}); #include "autogen_airwin/BiquadDouble.h" int BiquadDouble_unused = AirwinRegistry::registerAirwindow({"BiquadDouble", "Biquads", 46, "BiquadDouble is a handy Airwindows cascaded biquad filter: steeper roll-off before resonance.", airwinconsolidated::BiquadDouble::kNumParameters, []() { return std::make_unique(0); }, -1, { }}); +#include "autogen_airwin/BiquadHiLo.h" +int BiquadHiLo_unused = AirwinRegistry::registerAirwindow({"BiquadHiLo", "Unclassified", -1, "", airwinconsolidated::BiquadHiLo::kNumParameters, []() { return std::make_unique(0); }, -1, { }}); #include "autogen_airwin/BiquadNonLin.h" int BiquadNonLin_unused = AirwinRegistry::registerAirwindow({"BiquadNonLin", "Biquads", 43, "BiquadNonLin is Capacitor2, but for biquad filtering.", airwinconsolidated::BiquadNonLin::kNumParameters, []() { return std::make_unique(0); }, -1, { "Latest" }}); #include "autogen_airwin/BiquadOneHalf.h" int BiquadOneHalf_unused = AirwinRegistry::registerAirwindow({"BiquadOneHalf", "Biquads", 47, "BiquadOneHalf is an interleaved biquad filter like Biquad.", airwinconsolidated::BiquadOneHalf::kNumParameters, []() { return std::make_unique(0); }, -1, { }}); #include "autogen_airwin/BiquadPlus.h" int BiquadPlus_unused = AirwinRegistry::registerAirwindow({"BiquadPlus", "Biquads", 44, "BiquadPlus is Biquad plus zipper noise suppression! For twiddling the controls.", airwinconsolidated::BiquadPlus::kNumParameters, []() { return std::make_unique(0); }, -1, { }}); +#include "autogen_airwin/BiquadStack.h" +int BiquadStack_unused = AirwinRegistry::registerAirwindow({"BiquadStack", "Unclassified", -1, "", airwinconsolidated::BiquadStack::kNumParameters, []() { return std::make_unique(0); }, -1, { }}); #include "autogen_airwin/BiquadTriple.h" int BiquadTriple_unused = AirwinRegistry::registerAirwindow({"BiquadTriple", "Biquads", 48, "BiquadTriple is a handy Airwindows cascaded biquad filter: steeper roll-off before resonance.", airwinconsolidated::BiquadTriple::kNumParameters, []() { return std::make_unique(0); }, -1, { }}); #include "autogen_airwin/BitGlitter.h" @@ -210,10 +214,6 @@ int ConsoleMDChannel_unused = AirwinRegistry::registerAirwindow({"ConsoleMDChann int ConsoleXBuss_unused = AirwinRegistry::registerAirwindow({"ConsoleXBuss", "Unclassified", -1, "", airwinconsolidated::ConsoleXBuss::kNumParameters, []() { return std::make_unique(0); }, -1, { }}); #include "autogen_airwin/ConsoleXChannel.h" int ConsoleXChannel_unused = AirwinRegistry::registerAirwindow({"ConsoleXChannel", "Unclassified", -1, "", airwinconsolidated::ConsoleXChannel::kNumParameters, []() { return std::make_unique(0); }, -1, { }}); -#include "autogen_airwin/ConsoleXSubIn.h" -int ConsoleXSubIn_unused = AirwinRegistry::registerAirwindow({"ConsoleXSubIn", "Unclassified", -1, "", airwinconsolidated::ConsoleXSubIn::kNumParameters, []() { return std::make_unique(0); }, -1, { }}); -#include "autogen_airwin/ConsoleXSubOut.h" -int ConsoleXSubOut_unused = AirwinRegistry::registerAirwindow({"ConsoleXSubOut", "Unclassified", -1, "", airwinconsolidated::ConsoleXSubOut::kNumParameters, []() { return std::make_unique(0); }, -1, { }}); #include "autogen_airwin/ContentHideD.h" int ContentHideD_unused = AirwinRegistry::registerAirwindow({"ContentHideD", "Utility", 367, "ContentHideD mutes audio except for brief glimpses.", airwinconsolidated::ContentHideD::kNumParameters, []() { return std::make_unique(0); }, -1, { "Latest" }}); #include "autogen_airwin/Creature.h" @@ -260,6 +260,8 @@ int Discontinuity_unused = AirwinRegistry::registerAirwindow({"Discontinuity", " int Distance_unused = AirwinRegistry::registerAirwindow({"Distance", "Filter", 239, "Distance is a sound design or reverb far-away-izer.", airwinconsolidated::Distance::kNumParameters, []() { return std::make_unique(0); }, -1, { }}); #include "autogen_airwin/Distance2.h" int Distance2_unused = AirwinRegistry::registerAirwindow({"Distance2", "Filter", 238, "Distance2 is a versatile space shaper for creating depth.", airwinconsolidated::Distance2::kNumParameters, []() { return std::make_unique(0); }, -1, { "Latest" }}); +#include "autogen_airwin/Distance3.h" +int Distance3_unused = AirwinRegistry::registerAirwindow({"Distance3", "Unclassified", -1, "", airwinconsolidated::Distance3::kNumParameters, []() { return std::make_unique(0); }, -1, { }}); #include "autogen_airwin/Distortion.h" int Distortion_unused = AirwinRegistry::registerAirwindow({"Distortion", "Distortion", 125, "Distortion is a slightly dark analog-style distortion with several presets, like Focus.", airwinconsolidated::Distortion::kNumParameters, []() { return std::make_unique(0); }, -1, { "Latest" }}); #include "autogen_airwin/DitherFloat.h" @@ -492,6 +494,8 @@ int PDChannel_unused = AirwinRegistry::registerAirwindow({"PDChannel", "Consoles int Pafnuty_unused = AirwinRegistry::registerAirwindow({"Pafnuty", "Unclassified", -1, "Pafnuty is a Chebyshev filter, that adds harmonics.", airwinconsolidated::Pafnuty::kNumParameters, []() { return std::make_unique(0); }, -1, { }}); #include "autogen_airwin/Pafnuty2.h" int Pafnuty2_unused = AirwinRegistry::registerAirwindow({"Pafnuty2", "Effects", 192, "Pafnuty2 is a Chebyshev filter, that adds harmonics, and fits in the VCV Rack port.", airwinconsolidated::Pafnuty2::kNumParameters, []() { return std::make_unique(0); }, -1, { "Latest" }}); +#include "autogen_airwin/Parametric.h" +int Parametric_unused = AirwinRegistry::registerAirwindow({"Parametric", "Unclassified", -1, "", airwinconsolidated::Parametric::kNumParameters, []() { return std::make_unique(0); }, -1, { }}); #include "autogen_airwin/PaulDither.h" int PaulDither_unused = AirwinRegistry::registerAirwindow({"PaulDither", "Dithers", 139, "PaulDither is a highpassed TPDF dither. (quieter, airier)", airwinconsolidated::PaulDither::kNumParameters, []() { return std::make_unique(0); }, -1, { "Recommended" }}); #include "autogen_airwin/PaulWide.h" @@ -526,6 +530,8 @@ int Point_unused = AirwinRegistry::registerAirwindow({"Point", "Dynamics", 179, int Pop_unused = AirwinRegistry::registerAirwindow({"Pop", "Dynamics", 163, "Pop is a crazy overcompressor with a very exaggerated sound.", airwinconsolidated::Pop::kNumParameters, []() { return std::make_unique(0); }, -1, { }}); #include "autogen_airwin/Pop2.h" int Pop2_unused = AirwinRegistry::registerAirwindow({"Pop2", "Dynamics", 160, "Pop2 adds control and punch to Pop.", airwinconsolidated::Pop2::kNumParameters, []() { return std::make_unique(0); }, -1, { "Recommended", "Latest" }}); +#include "autogen_airwin/Pop3.h" +int Pop3_unused = AirwinRegistry::registerAirwindow({"Pop3", "Unclassified", -1, "", airwinconsolidated::Pop3::kNumParameters, []() { return std::make_unique(0); }, -1, { }}); #include "autogen_airwin/PowerSag.h" int PowerSag_unused = AirwinRegistry::registerAirwindow({"PowerSag", "Effects", 208, "PowerSag is for emulating power supply limitations in analog modeling.", airwinconsolidated::PowerSag::kNumParameters, []() { return std::make_unique(0); }, -1, { }}); #include "autogen_airwin/PowerSag2.h" @@ -638,6 +644,8 @@ int StereoDoubler_unused = AirwinRegistry::registerAirwindow({"StereoDoubler", " int StereoEnsemble_unused = AirwinRegistry::registerAirwindow({"StereoEnsemble", "Ambience", 20, "StereoEnsemble is a sort of hyperchorus blast from the past.", airwinconsolidated::StereoEnsemble::kNumParameters, []() { return std::make_unique(0); }, -1, { "Latest" }}); #include "autogen_airwin/StereoFX.h" int StereoFX_unused = AirwinRegistry::registerAirwindow({"StereoFX", "Stereo", 299, "StereoFX is an aggressive stereo widener.", airwinconsolidated::StereoFX::kNumParameters, []() { return std::make_unique(0); }, -1, { "Latest" }}); +#include "autogen_airwin/StoneFireComp.h" +int StoneFireComp_unused = AirwinRegistry::registerAirwindow({"StoneFireComp", "Unclassified", -1, "", airwinconsolidated::StoneFireComp::kNumParameters, []() { return std::make_unique(0); }, -1, { }}); #include "autogen_airwin/Stonefire.h" int Stonefire_unused = AirwinRegistry::registerAirwindow({"Stonefire", "Filter", 211, "Stonefire is the non-EQ EQ designed for ConsoleX.", airwinconsolidated::Stonefire::kNumParameters, []() { return std::make_unique(0); }, -1, { "Recommended", "Latest" }}); #include "autogen_airwin/StudioTan.h" diff --git a/src/autogen_airwin/BiquadHiLo.cpp b/src/autogen_airwin/BiquadHiLo.cpp new file mode 100644 index 0000000..c58d725 --- /dev/null +++ b/src/autogen_airwin/BiquadHiLo.cpp @@ -0,0 +1,123 @@ +/* ======================================== + * BiquadHiLo - BiquadHiLo.h + * Copyright (c) airwindows, Airwindows uses the MIT license + * ======================================== */ + +#ifndef __BiquadHiLo_H +#include "BiquadHiLo.h" +#endif +#include +#include +namespace airwinconsolidated::BiquadHiLo { + +AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new BiquadHiLo(audioMaster);} + +BiquadHiLo::BiquadHiLo(audioMasterCallback audioMaster) : + AudioEffectX(audioMaster, kNumPrograms, kNumParameters) +{ + A = 0.0; + B = 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 +} + +BiquadHiLo::~BiquadHiLo() {} +VstInt32 BiquadHiLo::getVendorVersion () {return 1000;} +void BiquadHiLo::setProgramName(char *name) {vst_strncpy (_programName, name, kVstMaxProgNameLen);} +void BiquadHiLo::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; +} + +void BiquadHiLo::setParameter(VstInt32 index, float value) { + switch (index) { + case kParamA: A = value; break; + case kParamB: B = value; break; + default: break; // unknown parameter, shouldn't happen! + } +} + +float BiquadHiLo::getParameter(VstInt32 index) { + switch (index) { + case kParamA: return A; break; + case kParamB: return B; 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 BiquadHiLo::getParameterName(VstInt32 index, char *text) { + switch (index) { + case kParamA: vst_strncpy (text, "Highpas", kVstMaxParamStrLen); break; + case kParamB: vst_strncpy (text, "Lowpass", kVstMaxParamStrLen); break; + default: break; // unknown parameter, shouldn't happen! + } //this is our labels for displaying in the VST host +} + +void BiquadHiLo::getParameterDisplay(VstInt32 index, char *text) { + switch (index) { + case kParamA: float2string (A, text, kVstMaxParamStrLen); break; + case kParamB: float2string (B, text, kVstMaxParamStrLen); break; + default: break; // unknown parameter, shouldn't happen! + } //this displays the values and handles 'popups' where it's discrete choices +} + +void BiquadHiLo::getParameterLabel(VstInt32 index, char *text) { + switch (index) { + case kParamA: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamB: vst_strncpy (text, "", kVstMaxParamStrLen); break; + default: break; // unknown parameter, shouldn't happen! + } +} + +VstInt32 BiquadHiLo::canDo(char *text) +{ return (_canDo.find(text) == _canDo.end()) ? -1: 1; } // 1 = yes, -1 = no, 0 = don't know + +bool BiquadHiLo::getEffectName(char* name) { + vst_strncpy(name, "BiquadHiLo", kVstMaxProductStrLen); return true; +} + +VstPlugCategory BiquadHiLo::getPlugCategory() {return kPlugCategEffect;} + +bool BiquadHiLo::getProductString(char* text) { + vst_strncpy (text, "airwindows BiquadHiLo", kVstMaxProductStrLen); return true; +} + +bool BiquadHiLo::getVendorString(char* text) { + vst_strncpy (text, "airwindows", kVstMaxVendorStrLen); return true; +} +bool BiquadHiLo::parameterTextToValue(VstInt32 index, const char *text, float &value) { + switch(index) { + case kParamA: { auto b = string2float(text, value); return b; break; } + case kParamB: { auto b = string2float(text, value); return b; break; } + + } + return false; +} +bool BiquadHiLo::canConvertParameterTextToValue(VstInt32 index) { + switch(index) { + case kParamA: return true; + case kParamB: return true; + + } + return false; +} +} // end namespace diff --git a/src/autogen_airwin/BiquadHiLo.h b/src/autogen_airwin/BiquadHiLo.h new file mode 100644 index 0000000..c01b660 --- /dev/null +++ b/src/autogen_airwin/BiquadHiLo.h @@ -0,0 +1,80 @@ +/* ======================================== + * BiquadHiLo - BiquadHiLo.h + * Created 8/12/11 by SPIAdmin + * Copyright (c) Airwindows, Airwindows uses the MIT license + * ======================================== */ + +#ifndef __BiquadHiLo_BiquadHiLo_H +#define __BiquadHiLo_BiquadHiLo_H + +#ifndef __audioeffect__ +#include "../airwin_consolidated_base.h" +#endif + +#include +#include +#include + +namespace airwinconsolidated::BiquadHiLo { +enum { + kParamA =0, + kParamB =1, + kNumParameters = 2 +}; // + +const int kNumPrograms = 0; +const int kNumInputs = 2; +const int kNumOutputs = 2; +const unsigned long kUniqueId = 'biqh'; //Change this to what the AU identity is! + +class BiquadHiLo : + public AudioEffectX +{ +public: + BiquadHiLo(audioMasterCallback audioMaster); + ~BiquadHiLo(); + 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 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 + // Added by the perl as inverses + virtual bool parameterTextToValue(VstInt32 index, const char *text, float &value); + virtual bool canConvertParameterTextToValue(VstInt32 index); + virtual VstInt32 canDo(char *text); +private: + char _programName[kVstMaxProgNameLen + 1]; + std::set< std::string > _canDo; + + float A; + float B; + + enum { + hilp_freq, hilp_temp, + hilp_a0, hilp_a1, hilp_b1, hilp_b2, + hilp_c0, hilp_c1, hilp_d1, hilp_d2, + hilp_e0, hilp_e1, hilp_f1, hilp_f2, + hilp_aL1, hilp_aL2, hilp_aR1, hilp_aR2, + hilp_cL1, hilp_cL2, hilp_cR1, hilp_cR2, + hilp_eL1, hilp_eL2, hilp_eR1, hilp_eR2, + hilp_total + }; + double highpass[hilp_total]; + double lowpass[hilp_total]; + + uint32_t fpdL; + uint32_t fpdR; + //default stuff +}; + +#endif +} // end namespace diff --git a/src/autogen_airwin/BiquadHiLoProc.cpp b/src/autogen_airwin/BiquadHiLoProc.cpp new file mode 100644 index 0000000..6a38c77 --- /dev/null +++ b/src/autogen_airwin/BiquadHiLoProc.cpp @@ -0,0 +1,260 @@ +/* ======================================== + * BiquadHiLo - BiquadHiLo.h + * Copyright (c) airwindows, Airwindows uses the MIT license + * ======================================== */ + +#ifndef __BiquadHiLo_H +#include "BiquadHiLo.h" +#endif +namespace airwinconsolidated::BiquadHiLo { + +void BiquadHiLo::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames) +{ + float* in1 = inputs[0]; + float* in2 = inputs[1]; + float* out1 = outputs[0]; + float* out2 = outputs[1]; + + double overallscale = 1.0; + overallscale /= 44100.0; + overallscale *= getSampleRate(); + + highpass[hilp_freq] = ((A*330.0)+20.0)/getSampleRate(); + bool highpassEngage = true; if (A == 0.0) highpassEngage = false; + + lowpass[hilp_freq] = ((pow(1.0-B,2)*17000.0)+3000.0)/getSampleRate(); + bool lowpassEngage = true; if (B == 0.0) lowpassEngage = false; + + double K = tan(M_PI * highpass[hilp_freq]); //highpass + double norm = 1.0 / (1.0 + K / 1.93185165 + K * K); + highpass[hilp_a0] = norm; + highpass[hilp_a1] = -2.0 * highpass[hilp_a0]; + highpass[hilp_b1] = 2.0 * (K * K - 1.0) * norm; + highpass[hilp_b2] = (1.0 - K / 1.93185165 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.70710678 + K * K); + highpass[hilp_c0] = norm; + highpass[hilp_c1] = -2.0 * highpass[hilp_c0]; + highpass[hilp_d1] = 2.0 * (K * K - 1.0) * norm; + highpass[hilp_d2] = (1.0 - K / 0.70710678 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.51763809 + K * K); + highpass[hilp_e0] = norm; + highpass[hilp_e1] = -2.0 * highpass[hilp_e0]; + highpass[hilp_f1] = 2.0 * (K * K - 1.0) * norm; + highpass[hilp_f2] = (1.0 - K / 0.51763809 + K * K) * norm; + + K = tan(M_PI * lowpass[hilp_freq]); //lowpass + norm = 1.0 / (1.0 + K / 1.93185165 + K * K); + lowpass[hilp_a0] = K * K * norm; + lowpass[hilp_a1] = 2.0 * lowpass[hilp_a0]; + lowpass[hilp_b1] = 2.0 * (K * K - 1.0) * norm; + lowpass[hilp_b2] = (1.0 - K / 1.93185165 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.70710678 + K * K); + lowpass[hilp_c0] = K * K * norm; + lowpass[hilp_c1] = 2.0 * lowpass[hilp_c0]; + lowpass[hilp_d1] = 2.0 * (K * K - 1.0) * norm; + lowpass[hilp_d2] = (1.0 - K / 0.70710678 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.51763809 + K * K); + lowpass[hilp_e0] = K * K * norm; + lowpass[hilp_e1] = 2.0 * lowpass[hilp_e0]; + lowpass[hilp_f1] = 2.0 * (K * K - 1.0) * norm; + lowpass[hilp_f2] = (1.0 - K / 0.51763809 + K * K) * norm; + + while (--sampleFrames >= 0) + { + double inputSampleL = *in1; + double inputSampleR = *in2; + if (fabs(inputSampleL)<1.18e-23) inputSampleL = fpdL * 1.18e-17; + if (fabs(inputSampleR)<1.18e-23) inputSampleR = fpdR * 1.18e-17; + + if (highpassEngage) { //begin Stacked Highpass + highpass[hilp_temp] = (inputSampleL*highpass[hilp_a0])+highpass[hilp_aL1]; + highpass[hilp_aL1] = (inputSampleL*highpass[hilp_a1])-(highpass[hilp_temp]*highpass[hilp_b1])+highpass[hilp_aL2]; + highpass[hilp_aL2] = (inputSampleL*highpass[hilp_a0])-(highpass[hilp_temp]*highpass[hilp_b2]); inputSampleL = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleL*highpass[hilp_c0])+highpass[hilp_cL1]; + highpass[hilp_cL1] = (inputSampleL*highpass[hilp_c1])-(highpass[hilp_temp]*highpass[hilp_d1])+highpass[hilp_cL2]; + highpass[hilp_cL2] = (inputSampleL*highpass[hilp_c0])-(highpass[hilp_temp]*highpass[hilp_d2]); inputSampleL = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleL*highpass[hilp_e0])+highpass[hilp_eL1]; + highpass[hilp_eL1] = (inputSampleL*highpass[hilp_e1])-(highpass[hilp_temp]*highpass[hilp_f1])+highpass[hilp_eL2]; + highpass[hilp_eL2] = (inputSampleL*highpass[hilp_e0])-(highpass[hilp_temp]*highpass[hilp_f2]); inputSampleL = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleR*highpass[hilp_a0])+highpass[hilp_aR1]; + highpass[hilp_aR1] = (inputSampleR*highpass[hilp_a1])-(highpass[hilp_temp]*highpass[hilp_b1])+highpass[hilp_aR2]; + highpass[hilp_aR2] = (inputSampleR*highpass[hilp_a0])-(highpass[hilp_temp]*highpass[hilp_b2]); inputSampleR = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleR*highpass[hilp_c0])+highpass[hilp_cR1]; + highpass[hilp_cR1] = (inputSampleR*highpass[hilp_c1])-(highpass[hilp_temp]*highpass[hilp_d1])+highpass[hilp_cR2]; + highpass[hilp_cR2] = (inputSampleR*highpass[hilp_c0])-(highpass[hilp_temp]*highpass[hilp_d2]); inputSampleR = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleR*highpass[hilp_e0])+highpass[hilp_eR1]; + highpass[hilp_eR1] = (inputSampleR*highpass[hilp_e1])-(highpass[hilp_temp]*highpass[hilp_f1])+highpass[hilp_eR2]; + highpass[hilp_eR2] = (inputSampleR*highpass[hilp_e0])-(highpass[hilp_temp]*highpass[hilp_f2]); inputSampleR = highpass[hilp_temp]; + } else { + highpass[hilp_aL1] = highpass[hilp_aL2] = highpass[hilp_aR1] = highpass[hilp_aR2] = 0.0; + } //end Stacked Highpass + + //rest of control strip goes here + + if (lowpassEngage) { //begin Stacked Lowpass + lowpass[hilp_temp] = (inputSampleL*lowpass[hilp_a0])+lowpass[hilp_aL1]; + lowpass[hilp_aL1] = (inputSampleL*lowpass[hilp_a1])-(lowpass[hilp_temp]*lowpass[hilp_b1])+lowpass[hilp_aL2]; + lowpass[hilp_aL2] = (inputSampleL*lowpass[hilp_a0])-(lowpass[hilp_temp]*lowpass[hilp_b2]); inputSampleL = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleL*lowpass[hilp_c0])+lowpass[hilp_cL1]; + lowpass[hilp_cL1] = (inputSampleL*lowpass[hilp_c1])-(lowpass[hilp_temp]*lowpass[hilp_d1])+lowpass[hilp_cL2]; + lowpass[hilp_cL2] = (inputSampleL*lowpass[hilp_c0])-(lowpass[hilp_temp]*lowpass[hilp_d2]); inputSampleL = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleL*lowpass[hilp_e0])+lowpass[hilp_eL1]; + lowpass[hilp_eL1] = (inputSampleL*lowpass[hilp_e1])-(lowpass[hilp_temp]*lowpass[hilp_f1])+lowpass[hilp_eL2]; + lowpass[hilp_eL2] = (inputSampleL*lowpass[hilp_e0])-(lowpass[hilp_temp]*lowpass[hilp_f2]); inputSampleL = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleR*lowpass[hilp_a0])+lowpass[hilp_aR1]; + lowpass[hilp_aR1] = (inputSampleR*lowpass[hilp_a1])-(lowpass[hilp_temp]*lowpass[hilp_b1])+lowpass[hilp_aR2]; + lowpass[hilp_aR2] = (inputSampleR*lowpass[hilp_a0])-(lowpass[hilp_temp]*lowpass[hilp_b2]); inputSampleR = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleR*lowpass[hilp_c0])+lowpass[hilp_cR1]; + lowpass[hilp_cR1] = (inputSampleR*lowpass[hilp_c1])-(lowpass[hilp_temp]*lowpass[hilp_d1])+lowpass[hilp_cR2]; + lowpass[hilp_cR2] = (inputSampleR*lowpass[hilp_c0])-(lowpass[hilp_temp]*lowpass[hilp_d2]); inputSampleR = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleR*lowpass[hilp_e0])+lowpass[hilp_eR1]; + lowpass[hilp_eR1] = (inputSampleR*lowpass[hilp_e1])-(lowpass[hilp_temp]*lowpass[hilp_f1])+lowpass[hilp_eR2]; + lowpass[hilp_eR2] = (inputSampleR*lowpass[hilp_e0])-(lowpass[hilp_temp]*lowpass[hilp_f2]); inputSampleR = lowpass[hilp_temp]; + } else { + lowpass[hilp_aL1] = lowpass[hilp_aL2] = lowpass[hilp_aR1] = lowpass[hilp_aR2] = 0.0; + } //end Stacked Lowpass + + //begin 32 bit stereo floating point dither + int expon; frexpf((float)inputSampleL, &expon); + fpdL ^= fpdL << 13; fpdL ^= fpdL >> 17; fpdL ^= fpdL << 5; + inputSampleL += ((double(fpdL)-uint32_t(0x7fffffff)) * 5.5e-36l * pow(2,expon+62)); + frexpf((float)inputSampleR, &expon); + fpdR ^= fpdR << 13; fpdR ^= fpdR >> 17; fpdR ^= fpdR << 5; + inputSampleR += ((double(fpdR)-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 BiquadHiLo::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames) +{ + double* in1 = inputs[0]; + double* in2 = inputs[1]; + double* out1 = outputs[0]; + double* out2 = outputs[1]; + + double overallscale = 1.0; + overallscale /= 44100.0; + overallscale *= getSampleRate(); + + highpass[hilp_freq] = ((A*330.0)+20.0)/getSampleRate(); + bool highpassEngage = true; if (A == 0.0) highpassEngage = false; + + lowpass[hilp_freq] = ((pow(1.0-B,2)*17000.0)+3000.0)/getSampleRate(); + bool lowpassEngage = true; if (B == 0.0) lowpassEngage = false; + + double K = tan(M_PI * highpass[hilp_freq]); //highpass + double norm = 1.0 / (1.0 + K / 1.93185165 + K * K); + highpass[hilp_a0] = norm; + highpass[hilp_a1] = -2.0 * highpass[hilp_a0]; + highpass[hilp_b1] = 2.0 * (K * K - 1.0) * norm; + highpass[hilp_b2] = (1.0 - K / 1.93185165 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.70710678 + K * K); + highpass[hilp_c0] = norm; + highpass[hilp_c1] = -2.0 * highpass[hilp_c0]; + highpass[hilp_d1] = 2.0 * (K * K - 1.0) * norm; + highpass[hilp_d2] = (1.0 - K / 0.70710678 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.51763809 + K * K); + highpass[hilp_e0] = norm; + highpass[hilp_e1] = -2.0 * highpass[hilp_e0]; + highpass[hilp_f1] = 2.0 * (K * K - 1.0) * norm; + highpass[hilp_f2] = (1.0 - K / 0.51763809 + K * K) * norm; + + K = tan(M_PI * lowpass[hilp_freq]); //lowpass + norm = 1.0 / (1.0 + K / 1.93185165 + K * K); + lowpass[hilp_a0] = K * K * norm; + lowpass[hilp_a1] = 2.0 * lowpass[hilp_a0]; + lowpass[hilp_b1] = 2.0 * (K * K - 1.0) * norm; + lowpass[hilp_b2] = (1.0 - K / 1.93185165 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.70710678 + K * K); + lowpass[hilp_c0] = K * K * norm; + lowpass[hilp_c1] = 2.0 * lowpass[hilp_c0]; + lowpass[hilp_d1] = 2.0 * (K * K - 1.0) * norm; + lowpass[hilp_d2] = (1.0 - K / 0.70710678 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.51763809 + K * K); + lowpass[hilp_e0] = K * K * norm; + lowpass[hilp_e1] = 2.0 * lowpass[hilp_e0]; + lowpass[hilp_f1] = 2.0 * (K * K - 1.0) * norm; + lowpass[hilp_f2] = (1.0 - K / 0.51763809 + K * K) * norm; + + while (--sampleFrames >= 0) + { + double inputSampleL = *in1; + double inputSampleR = *in2; + if (fabs(inputSampleL)<1.18e-23) inputSampleL = fpdL * 1.18e-17; + if (fabs(inputSampleR)<1.18e-23) inputSampleR = fpdR * 1.18e-17; + + if (highpassEngage) { //begin Stacked Highpass + highpass[hilp_temp] = (inputSampleL*highpass[hilp_a0])+highpass[hilp_aL1]; + highpass[hilp_aL1] = (inputSampleL*highpass[hilp_a1])-(highpass[hilp_temp]*highpass[hilp_b1])+highpass[hilp_aL2]; + highpass[hilp_aL2] = (inputSampleL*highpass[hilp_a0])-(highpass[hilp_temp]*highpass[hilp_b2]); inputSampleL = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleL*highpass[hilp_c0])+highpass[hilp_cL1]; + highpass[hilp_cL1] = (inputSampleL*highpass[hilp_c1])-(highpass[hilp_temp]*highpass[hilp_d1])+highpass[hilp_cL2]; + highpass[hilp_cL2] = (inputSampleL*highpass[hilp_c0])-(highpass[hilp_temp]*highpass[hilp_d2]); inputSampleL = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleL*highpass[hilp_e0])+highpass[hilp_eL1]; + highpass[hilp_eL1] = (inputSampleL*highpass[hilp_e1])-(highpass[hilp_temp]*highpass[hilp_f1])+highpass[hilp_eL2]; + highpass[hilp_eL2] = (inputSampleL*highpass[hilp_e0])-(highpass[hilp_temp]*highpass[hilp_f2]); inputSampleL = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleR*highpass[hilp_a0])+highpass[hilp_aR1]; + highpass[hilp_aR1] = (inputSampleR*highpass[hilp_a1])-(highpass[hilp_temp]*highpass[hilp_b1])+highpass[hilp_aR2]; + highpass[hilp_aR2] = (inputSampleR*highpass[hilp_a0])-(highpass[hilp_temp]*highpass[hilp_b2]); inputSampleR = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleR*highpass[hilp_c0])+highpass[hilp_cR1]; + highpass[hilp_cR1] = (inputSampleR*highpass[hilp_c1])-(highpass[hilp_temp]*highpass[hilp_d1])+highpass[hilp_cR2]; + highpass[hilp_cR2] = (inputSampleR*highpass[hilp_c0])-(highpass[hilp_temp]*highpass[hilp_d2]); inputSampleR = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleR*highpass[hilp_e0])+highpass[hilp_eR1]; + highpass[hilp_eR1] = (inputSampleR*highpass[hilp_e1])-(highpass[hilp_temp]*highpass[hilp_f1])+highpass[hilp_eR2]; + highpass[hilp_eR2] = (inputSampleR*highpass[hilp_e0])-(highpass[hilp_temp]*highpass[hilp_f2]); inputSampleR = highpass[hilp_temp]; + } else { + highpass[hilp_aL1] = highpass[hilp_aL2] = highpass[hilp_aR1] = highpass[hilp_aR2] = 0.0; + } //end Stacked Highpass + + //rest of control strip goes here + + if (lowpassEngage) { //begin Stacked Lowpass + lowpass[hilp_temp] = (inputSampleL*lowpass[hilp_a0])+lowpass[hilp_aL1]; + lowpass[hilp_aL1] = (inputSampleL*lowpass[hilp_a1])-(lowpass[hilp_temp]*lowpass[hilp_b1])+lowpass[hilp_aL2]; + lowpass[hilp_aL2] = (inputSampleL*lowpass[hilp_a0])-(lowpass[hilp_temp]*lowpass[hilp_b2]); inputSampleL = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleL*lowpass[hilp_c0])+lowpass[hilp_cL1]; + lowpass[hilp_cL1] = (inputSampleL*lowpass[hilp_c1])-(lowpass[hilp_temp]*lowpass[hilp_d1])+lowpass[hilp_cL2]; + lowpass[hilp_cL2] = (inputSampleL*lowpass[hilp_c0])-(lowpass[hilp_temp]*lowpass[hilp_d2]); inputSampleL = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleL*lowpass[hilp_e0])+lowpass[hilp_eL1]; + lowpass[hilp_eL1] = (inputSampleL*lowpass[hilp_e1])-(lowpass[hilp_temp]*lowpass[hilp_f1])+lowpass[hilp_eL2]; + lowpass[hilp_eL2] = (inputSampleL*lowpass[hilp_e0])-(lowpass[hilp_temp]*lowpass[hilp_f2]); inputSampleL = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleR*lowpass[hilp_a0])+lowpass[hilp_aR1]; + lowpass[hilp_aR1] = (inputSampleR*lowpass[hilp_a1])-(lowpass[hilp_temp]*lowpass[hilp_b1])+lowpass[hilp_aR2]; + lowpass[hilp_aR2] = (inputSampleR*lowpass[hilp_a0])-(lowpass[hilp_temp]*lowpass[hilp_b2]); inputSampleR = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleR*lowpass[hilp_c0])+lowpass[hilp_cR1]; + lowpass[hilp_cR1] = (inputSampleR*lowpass[hilp_c1])-(lowpass[hilp_temp]*lowpass[hilp_d1])+lowpass[hilp_cR2]; + lowpass[hilp_cR2] = (inputSampleR*lowpass[hilp_c0])-(lowpass[hilp_temp]*lowpass[hilp_d2]); inputSampleR = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleR*lowpass[hilp_e0])+lowpass[hilp_eR1]; + lowpass[hilp_eR1] = (inputSampleR*lowpass[hilp_e1])-(lowpass[hilp_temp]*lowpass[hilp_f1])+lowpass[hilp_eR2]; + lowpass[hilp_eR2] = (inputSampleR*lowpass[hilp_e0])-(lowpass[hilp_temp]*lowpass[hilp_f2]); inputSampleR = lowpass[hilp_temp]; + } else { + lowpass[hilp_aL1] = lowpass[hilp_aL2] = lowpass[hilp_aR1] = lowpass[hilp_aR2] = 0.0; + } //end Stacked Lowpass + + //begin 64 bit stereo floating point dither + //int expon; frexp((double)inputSampleL, &expon); + fpdL ^= fpdL << 13; fpdL ^= fpdL >> 17; fpdL ^= fpdL << 5; + //inputSampleL += ((double(fpdL)-uint32_t(0x7fffffff)) * 1.1e-44l * pow(2,expon+62)); + //frexp((double)inputSampleR, &expon); + fpdR ^= fpdR << 13; fpdR ^= fpdR >> 17; fpdR ^= fpdR << 5; + //inputSampleR += ((double(fpdR)-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++; + } +} +} // end namespace diff --git a/src/autogen_airwin/BiquadStack.cpp b/src/autogen_airwin/BiquadStack.cpp new file mode 100644 index 0000000..82e9c77 --- /dev/null +++ b/src/autogen_airwin/BiquadStack.cpp @@ -0,0 +1,133 @@ +/* ======================================== + * BiquadStack - BiquadStack.h + * Copyright (c) airwindows, Airwindows uses the MIT license + * ======================================== */ + +#ifndef __BiquadStack_H +#include "BiquadStack.h" +#endif +#include +#include +namespace airwinconsolidated::BiquadStack { + +AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new BiquadStack(audioMaster);} + +BiquadStack::BiquadStack(audioMasterCallback audioMaster) : + AudioEffectX(audioMaster, kNumPrograms, kNumParameters) +{ + A = 0.5; + B = 0.5; + C = 0.5; + + for (int x = 0; x < biqs_total; x++) {biqs[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 +} + +BiquadStack::~BiquadStack() {} +VstInt32 BiquadStack::getVendorVersion () {return 1000;} +void BiquadStack::setProgramName(char *name) {vst_strncpy (_programName, name, kVstMaxProgNameLen);} +void BiquadStack::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; +} + +void BiquadStack::setParameter(VstInt32 index, float value) { + switch (index) { + case kParamA: A = value; break; + case kParamB: B = value; break; + case kParamC: C = value; break; + default: break; // unknown parameter, shouldn't happen! + } +} + +float BiquadStack::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 BiquadStack::getParameterName(VstInt32 index, char *text) { + switch (index) { + case kParamA: vst_strncpy (text, "Freq", kVstMaxParamStrLen); break; + case kParamB: vst_strncpy (text, "Level", kVstMaxParamStrLen); break; + case kParamC: vst_strncpy (text, "Reso", kVstMaxParamStrLen); break; + default: break; // unknown parameter, shouldn't happen! + } //this is our labels for displaying in the VST host +} + +void BiquadStack::getParameterDisplay(VstInt32 index, char *text) { + switch (index) { + case kParamA: float2string (A, text, kVstMaxParamStrLen); break; + case kParamB: float2string (B, text, kVstMaxParamStrLen); break; + case kParamC: float2string (C, text, kVstMaxParamStrLen); break; + default: break; // unknown parameter, shouldn't happen! + } //this displays the values and handles 'popups' where it's discrete choices +} + +void BiquadStack::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; + default: break; // unknown parameter, shouldn't happen! + } +} + +VstInt32 BiquadStack::canDo(char *text) +{ return (_canDo.find(text) == _canDo.end()) ? -1: 1; } // 1 = yes, -1 = no, 0 = don't know + +bool BiquadStack::getEffectName(char* name) { + vst_strncpy(name, "BiquadStack", kVstMaxProductStrLen); return true; +} + +VstPlugCategory BiquadStack::getPlugCategory() {return kPlugCategEffect;} + +bool BiquadStack::getProductString(char* text) { + vst_strncpy (text, "airwindows BiquadStack", kVstMaxProductStrLen); return true; +} + +bool BiquadStack::getVendorString(char* text) { + vst_strncpy (text, "airwindows", kVstMaxVendorStrLen); return true; +} +bool BiquadStack::parameterTextToValue(VstInt32 index, const char *text, float &value) { + switch(index) { + case kParamA: { auto b = string2float(text, value); return b; break; } + case kParamB: { auto b = string2float(text, value); return b; break; } + case kParamC: { auto b = string2float(text, value); return b; break; } + + } + return false; +} +bool BiquadStack::canConvertParameterTextToValue(VstInt32 index) { + switch(index) { + case kParamA: return true; + case kParamB: return true; + case kParamC: return true; + + } + return false; +} +} // end namespace diff --git a/src/autogen_airwin/BiquadStack.h b/src/autogen_airwin/BiquadStack.h new file mode 100644 index 0000000..43d4d4f --- /dev/null +++ b/src/autogen_airwin/BiquadStack.h @@ -0,0 +1,81 @@ +/* ======================================== + * BiquadStack - BiquadStack.h + * Created 8/12/11 by SPIAdmin + * Copyright (c) Airwindows, Airwindows uses the MIT license + * ======================================== */ + +#ifndef __BiquadStack_BiquadStack_H +#define __BiquadStack_BiquadStack_H + +#ifndef __audioeffect__ +#include "../airwin_consolidated_base.h" +#endif + +#include +#include +#include + +namespace airwinconsolidated::BiquadStack { +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 = 'biqk'; //Change this to what the AU identity is! + +class BiquadStack : + public AudioEffectX +{ +public: + BiquadStack(audioMasterCallback audioMaster); + ~BiquadStack(); + 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 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 + // Added by the perl as inverses + virtual bool parameterTextToValue(VstInt32 index, const char *text, float &value); + virtual bool canConvertParameterTextToValue(VstInt32 index); + virtual VstInt32 canDo(char *text); +private: + char _programName[kVstMaxProgNameLen + 1]; + std::set< std::string > _canDo; + + float A; + float B; + float C; + + enum { + biqs_freq, biqs_reso, biqs_level, biqs_levelA, biqs_levelB, biqs_nonlin, biqs_temp, biqs_dis, + biqs_a0, biqs_aA0, biqs_aB0, biqs_b1, biqs_bA1, biqs_bB1, biqs_b2, biqs_bA2, biqs_bB2, + biqs_c0, biqs_cA0, biqs_cB0, biqs_d1, biqs_dA1, biqs_dB1, biqs_d2, biqs_dA2, biqs_dB2, + biqs_e0, biqs_eA0, biqs_eB0, biqs_f1, biqs_fA1, biqs_fB1, biqs_f2, biqs_fA2, biqs_fB2, + biqs_aL1, biqs_aL2, biqs_aR1, biqs_aR2, + biqs_cL1, biqs_cL2, biqs_cR1, biqs_cR2, + biqs_eL1, biqs_eL2, biqs_eR1, biqs_eR2, + biqs_outL, biqs_outR, biqs_total + }; + double biqs[biqs_total]; + + uint32_t fpdL; + uint32_t fpdR; + //default stuff +}; + +#endif +} // end namespace diff --git a/src/autogen_airwin/BiquadStackProc.cpp b/src/autogen_airwin/BiquadStackProc.cpp new file mode 100644 index 0000000..8668c69 --- /dev/null +++ b/src/autogen_airwin/BiquadStackProc.cpp @@ -0,0 +1,304 @@ +/* ======================================== + * BiquadStack - BiquadStack.h + * Copyright (c) airwindows, Airwindows uses the MIT license + * ======================================== */ + +#ifndef __BiquadStack_H +#include "BiquadStack.h" +#endif +namespace airwinconsolidated::BiquadStack { + +void BiquadStack::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames) +{ + float* in1 = inputs[0]; + float* in2 = inputs[1]; + float* out1 = outputs[0]; + float* out2 = outputs[1]; + + VstInt32 inFramesToProcess = sampleFrames; //vst doesn't give us this as a separate variable so we'll make it + double overallscale = 1.0; + overallscale /= 44100.0; + overallscale *= getSampleRate(); + + biqs[biqs_levelA] = biqs[biqs_levelB]; + biqs[biqs_aA0] = biqs[biqs_aB0]; + biqs[biqs_bA1] = biqs[biqs_bB1]; + biqs[biqs_bA2] = biqs[biqs_bB2]; + biqs[biqs_cA0] = biqs[biqs_cB0]; + biqs[biqs_dA1] = biqs[biqs_dB1]; + biqs[biqs_dA2] = biqs[biqs_dB2]; + biqs[biqs_eA0] = biqs[biqs_eB0]; + biqs[biqs_fA1] = biqs[biqs_fB1]; + biqs[biqs_fA2] = biqs[biqs_fB2]; + //previous run through the buffer is still in the filter, so we move it + //to the A section and now it's the new starting point. + + biqs[biqs_freq] = (((pow(A,4)*19980.0)+20.0)/getSampleRate()); + biqs[biqs_nonlin] = B; + biqs[biqs_levelB] = (biqs[biqs_nonlin]*2.0)-1.0; + if (biqs[biqs_levelB] > 0.0) biqs[biqs_levelB] *= 2.0; + biqs[biqs_reso] = ((0.5+(biqs[biqs_nonlin]*0.5)+sqrt(biqs[biqs_freq]))-(1.0-pow(1.0-C,2.0)))+0.5+(biqs[biqs_nonlin]*0.5); + + double K = tan(M_PI * biqs[biqs_freq]); + double norm = 1.0 / (1.0 + K / (biqs[biqs_reso]*1.93185165) + K * K); + biqs[biqs_aB0] = K / (biqs[biqs_reso]*1.93185165) * norm; + biqs[biqs_bB1] = 2.0 * (K * K - 1.0) * norm; + biqs[biqs_bB2] = (1.0 - K / (biqs[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (biqs[biqs_reso]*0.70710678) + K * K); + biqs[biqs_cB0] = K / (biqs[biqs_reso]*0.70710678) * norm; + biqs[biqs_dB1] = 2.0 * (K * K - 1.0) * norm; + biqs[biqs_dB2] = (1.0 - K / (biqs[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (biqs[biqs_reso]*0.51763809) + K * K); + biqs[biqs_eB0] = K / (biqs[biqs_reso]*0.51763809) * norm; + biqs[biqs_fB1] = 2.0 * (K * K - 1.0) * norm; + biqs[biqs_fB2] = (1.0 - K / (biqs[biqs_reso]*0.51763809) + K * K) * norm; + + if (biqs[biqs_aA0] == 0.0) { // if we have just started, start directly with raw info + biqs[biqs_levelA] = biqs[biqs_levelB]; + biqs[biqs_aA0] = biqs[biqs_aB0]; + biqs[biqs_bA1] = biqs[biqs_bB1]; + biqs[biqs_bA2] = biqs[biqs_bB2]; + biqs[biqs_cA0] = biqs[biqs_cB0]; + biqs[biqs_dA1] = biqs[biqs_dB1]; + biqs[biqs_dA2] = biqs[biqs_dB2]; + biqs[biqs_eA0] = biqs[biqs_eB0]; + biqs[biqs_fA1] = biqs[biqs_fB1]; + biqs[biqs_fA2] = biqs[biqs_fB2]; + } + + while (--sampleFrames >= 0) + { + double inputSampleL = *in1; + double inputSampleR = *in2; + if (fabs(inputSampleL)<1.18e-23) inputSampleL = fpdL * 1.18e-17; + if (fabs(inputSampleR)<1.18e-23) inputSampleR = fpdR * 1.18e-17; + + double buf = (double)sampleFrames/inFramesToProcess; + biqs[biqs_level] = (biqs[biqs_levelA]*buf)+(biqs[biqs_levelB]*(1.0-buf)); + biqs[biqs_a0] = (biqs[biqs_aA0]*buf)+(biqs[biqs_aB0]*(1.0-buf)); + biqs[biqs_b1] = (biqs[biqs_bA1]*buf)+(biqs[biqs_bB1]*(1.0-buf)); + biqs[biqs_b2] = (biqs[biqs_bA2]*buf)+(biqs[biqs_bB2]*(1.0-buf)); + biqs[biqs_c0] = (biqs[biqs_cA0]*buf)+(biqs[biqs_cB0]*(1.0-buf)); + biqs[biqs_d1] = (biqs[biqs_dA1]*buf)+(biqs[biqs_dB1]*(1.0-buf)); + biqs[biqs_d2] = (biqs[biqs_dA2]*buf)+(biqs[biqs_dB2]*(1.0-buf)); + biqs[biqs_e0] = (biqs[biqs_eA0]*buf)+(biqs[biqs_eB0]*(1.0-buf)); + biqs[biqs_f1] = (biqs[biqs_fA1]*buf)+(biqs[biqs_fB1]*(1.0-buf)); + biqs[biqs_f2] = (biqs[biqs_fA2]*buf)+(biqs[biqs_fB2]*(1.0-buf)); + + //begin Stacked Biquad With Reversed Neutron Flow L + biqs[biqs_outL] = inputSampleL * fabs(biqs[biqs_level]); + biqs[biqs_dis] = fabs(biqs[biqs_a0] * (1.0+(biqs[biqs_outL]*biqs[biqs_nonlin]))); + if (biqs[biqs_dis] > 1.0) biqs[biqs_dis] = 1.0; + biqs[biqs_temp] = (biqs[biqs_outL] * biqs[biqs_dis]) + biqs[biqs_aL1]; + biqs[biqs_aL1] = biqs[biqs_aL2] - (biqs[biqs_temp]*biqs[biqs_b1]); + biqs[biqs_aL2] = (biqs[biqs_outL] * -biqs[biqs_dis]) - (biqs[biqs_temp]*biqs[biqs_b2]); + biqs[biqs_outL] = biqs[biqs_temp]; + biqs[biqs_dis] = fabs(biqs[biqs_c0] * (1.0+(biqs[biqs_outL]*biqs[biqs_nonlin]))); + if (biqs[biqs_dis] > 1.0) biqs[biqs_dis] = 1.0; + biqs[biqs_temp] = (biqs[biqs_outL] * biqs[biqs_dis]) + biqs[biqs_cL1]; + biqs[biqs_cL1] = biqs[biqs_cL2] - (biqs[biqs_temp]*biqs[biqs_d1]); + biqs[biqs_cL2] = (biqs[biqs_outL] * -biqs[biqs_dis]) - (biqs[biqs_temp]*biqs[biqs_d2]); + biqs[biqs_outL] = biqs[biqs_temp]; + biqs[biqs_dis] = fabs(biqs[biqs_e0] * (1.0+(biqs[biqs_outL]*biqs[biqs_nonlin]))); + if (biqs[biqs_dis] > 1.0) biqs[biqs_dis] = 1.0; + biqs[biqs_temp] = (biqs[biqs_outL] * biqs[biqs_dis]) + biqs[biqs_eL1]; + biqs[biqs_eL1] = biqs[biqs_eL2] - (biqs[biqs_temp]*biqs[biqs_f1]); + biqs[biqs_eL2] = (biqs[biqs_outL] * -biqs[biqs_dis]) - (biqs[biqs_temp]*biqs[biqs_f2]); + biqs[biqs_outL] = biqs[biqs_temp]; + biqs[biqs_outL] *= biqs[biqs_level]; + if (biqs[biqs_level] > 1.0) biqs[biqs_outL] *= biqs[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L + + //begin Stacked Biquad With Reversed Neutron Flow R + biqs[biqs_outR] = inputSampleR * fabs(biqs[biqs_level]); + biqs[biqs_dis] = fabs(biqs[biqs_a0] * (1.0+(biqs[biqs_outR]*biqs[biqs_nonlin]))); + if (biqs[biqs_dis] > 1.0) biqs[biqs_dis] = 1.0; + biqs[biqs_temp] = (biqs[biqs_outR] * biqs[biqs_dis]) + biqs[biqs_aR1]; + biqs[biqs_aR1] = biqs[biqs_aR2] - (biqs[biqs_temp]*biqs[biqs_b1]); + biqs[biqs_aR2] = (biqs[biqs_outR] * -biqs[biqs_dis]) - (biqs[biqs_temp]*biqs[biqs_b2]); + biqs[biqs_outR] = biqs[biqs_temp]; + biqs[biqs_dis] = fabs(biqs[biqs_c0] * (1.0+(biqs[biqs_outR]*biqs[biqs_nonlin]))); + if (biqs[biqs_dis] > 1.0) biqs[biqs_dis] = 1.0; + biqs[biqs_temp] = (biqs[biqs_outR] * biqs[biqs_dis]) + biqs[biqs_cR1]; + biqs[biqs_cR1] = biqs[biqs_cR2] - (biqs[biqs_temp]*biqs[biqs_d1]); + biqs[biqs_cR2] = (biqs[biqs_outR] * -biqs[biqs_dis]) - (biqs[biqs_temp]*biqs[biqs_d2]); + biqs[biqs_outR] = biqs[biqs_temp]; + biqs[biqs_dis] = fabs(biqs[biqs_e0] * (1.0+(biqs[biqs_outR]*biqs[biqs_nonlin]))); + if (biqs[biqs_dis] > 1.0) biqs[biqs_dis] = 1.0; + biqs[biqs_temp] = (biqs[biqs_outR] * biqs[biqs_dis]) + biqs[biqs_eR1]; + biqs[biqs_eR1] = biqs[biqs_eR2] - (biqs[biqs_temp]*biqs[biqs_f1]); + biqs[biqs_eR2] = (biqs[biqs_outR] * -biqs[biqs_dis]) - (biqs[biqs_temp]*biqs[biqs_f2]); + biqs[biqs_outR] = biqs[biqs_temp]; + biqs[biqs_outR] *= biqs[biqs_level]; + if (biqs[biqs_level] > 1.0) biqs[biqs_outR] *= biqs[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R + + inputSampleL += biqs[biqs_outL]; //purely a parallel filter stage here + inputSampleR += biqs[biqs_outR]; //purely a parallel filter stage here + + //begin 32 bit stereo floating point dither + int expon; frexpf((float)inputSampleL, &expon); + fpdL ^= fpdL << 13; fpdL ^= fpdL >> 17; fpdL ^= fpdL << 5; + inputSampleL += ((double(fpdL)-uint32_t(0x7fffffff)) * 5.5e-36l * pow(2,expon+62)); + frexpf((float)inputSampleR, &expon); + fpdR ^= fpdR << 13; fpdR ^= fpdR >> 17; fpdR ^= fpdR << 5; + inputSampleR += ((double(fpdR)-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 BiquadStack::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames) +{ + double* in1 = inputs[0]; + double* in2 = inputs[1]; + double* out1 = outputs[0]; + double* out2 = outputs[1]; + + VstInt32 inFramesToProcess = sampleFrames; //vst doesn't give us this as a separate variable so we'll make it + double overallscale = 1.0; + overallscale /= 44100.0; + overallscale *= getSampleRate(); + + biqs[biqs_levelA] = biqs[biqs_levelB]; + biqs[biqs_aA0] = biqs[biqs_aB0]; + biqs[biqs_bA1] = biqs[biqs_bB1]; + biqs[biqs_bA2] = biqs[biqs_bB2]; + biqs[biqs_cA0] = biqs[biqs_cB0]; + biqs[biqs_dA1] = biqs[biqs_dB1]; + biqs[biqs_dA2] = biqs[biqs_dB2]; + biqs[biqs_eA0] = biqs[biqs_eB0]; + biqs[biqs_fA1] = biqs[biqs_fB1]; + biqs[biqs_fA2] = biqs[biqs_fB2]; + //previous run through the buffer is still in the filter, so we move it + //to the A section and now it's the new starting point. + + biqs[biqs_freq] = (((pow(A,4)*19980.0)+20.0)/getSampleRate()); + biqs[biqs_nonlin] = B; + biqs[biqs_levelB] = (biqs[biqs_nonlin]*2.0)-1.0; + if (biqs[biqs_levelB] > 0.0) biqs[biqs_levelB] *= 2.0; + biqs[biqs_reso] = ((0.5+(biqs[biqs_nonlin]*0.5)+sqrt(biqs[biqs_freq]))-(1.0-pow(1.0-C,2.0)))+0.5+(biqs[biqs_nonlin]*0.5); + + double K = tan(M_PI * biqs[biqs_freq]); + double norm = 1.0 / (1.0 + K / (biqs[biqs_reso]*1.93185165) + K * K); + biqs[biqs_aB0] = K / (biqs[biqs_reso]*1.93185165) * norm; + biqs[biqs_bB1] = 2.0 * (K * K - 1.0) * norm; + biqs[biqs_bB2] = (1.0 - K / (biqs[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (biqs[biqs_reso]*0.70710678) + K * K); + biqs[biqs_cB0] = K / (biqs[biqs_reso]*0.70710678) * norm; + biqs[biqs_dB1] = 2.0 * (K * K - 1.0) * norm; + biqs[biqs_dB2] = (1.0 - K / (biqs[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (biqs[biqs_reso]*0.51763809) + K * K); + biqs[biqs_eB0] = K / (biqs[biqs_reso]*0.51763809) * norm; + biqs[biqs_fB1] = 2.0 * (K * K - 1.0) * norm; + biqs[biqs_fB2] = (1.0 - K / (biqs[biqs_reso]*0.51763809) + K * K) * norm; + + if (biqs[biqs_aA0] == 0.0) { // if we have just started, start directly with raw info + biqs[biqs_levelA] = biqs[biqs_levelB]; + biqs[biqs_aA0] = biqs[biqs_aB0]; + biqs[biqs_bA1] = biqs[biqs_bB1]; + biqs[biqs_bA2] = biqs[biqs_bB2]; + biqs[biqs_cA0] = biqs[biqs_cB0]; + biqs[biqs_dA1] = biqs[biqs_dB1]; + biqs[biqs_dA2] = biqs[biqs_dB2]; + biqs[biqs_eA0] = biqs[biqs_eB0]; + biqs[biqs_fA1] = biqs[biqs_fB1]; + biqs[biqs_fA2] = biqs[biqs_fB2]; + } + + while (--sampleFrames >= 0) + { + double inputSampleL = *in1; + double inputSampleR = *in2; + if (fabs(inputSampleL)<1.18e-23) inputSampleL = fpdL * 1.18e-17; + if (fabs(inputSampleR)<1.18e-23) inputSampleR = fpdR * 1.18e-17; + + double buf = (double)sampleFrames/inFramesToProcess; + biqs[biqs_level] = (biqs[biqs_levelA]*buf)+(biqs[biqs_levelB]*(1.0-buf)); + biqs[biqs_a0] = (biqs[biqs_aA0]*buf)+(biqs[biqs_aB0]*(1.0-buf)); + biqs[biqs_b1] = (biqs[biqs_bA1]*buf)+(biqs[biqs_bB1]*(1.0-buf)); + biqs[biqs_b2] = (biqs[biqs_bA2]*buf)+(biqs[biqs_bB2]*(1.0-buf)); + biqs[biqs_c0] = (biqs[biqs_cA0]*buf)+(biqs[biqs_cB0]*(1.0-buf)); + biqs[biqs_d1] = (biqs[biqs_dA1]*buf)+(biqs[biqs_dB1]*(1.0-buf)); + biqs[biqs_d2] = (biqs[biqs_dA2]*buf)+(biqs[biqs_dB2]*(1.0-buf)); + biqs[biqs_e0] = (biqs[biqs_eA0]*buf)+(biqs[biqs_eB0]*(1.0-buf)); + biqs[biqs_f1] = (biqs[biqs_fA1]*buf)+(biqs[biqs_fB1]*(1.0-buf)); + biqs[biqs_f2] = (biqs[biqs_fA2]*buf)+(biqs[biqs_fB2]*(1.0-buf)); + + //begin Stacked Biquad With Reversed Neutron Flow L + biqs[biqs_outL] = inputSampleL * fabs(biqs[biqs_level]); + biqs[biqs_dis] = fabs(biqs[biqs_a0] * (1.0+(biqs[biqs_outL]*biqs[biqs_nonlin]))); + if (biqs[biqs_dis] > 1.0) biqs[biqs_dis] = 1.0; + biqs[biqs_temp] = (biqs[biqs_outL] * biqs[biqs_dis]) + biqs[biqs_aL1]; + biqs[biqs_aL1] = biqs[biqs_aL2] - (biqs[biqs_temp]*biqs[biqs_b1]); + biqs[biqs_aL2] = (biqs[biqs_outL] * -biqs[biqs_dis]) - (biqs[biqs_temp]*biqs[biqs_b2]); + biqs[biqs_outL] = biqs[biqs_temp]; + biqs[biqs_dis] = fabs(biqs[biqs_c0] * (1.0+(biqs[biqs_outL]*biqs[biqs_nonlin]))); + if (biqs[biqs_dis] > 1.0) biqs[biqs_dis] = 1.0; + biqs[biqs_temp] = (biqs[biqs_outL] * biqs[biqs_dis]) + biqs[biqs_cL1]; + biqs[biqs_cL1] = biqs[biqs_cL2] - (biqs[biqs_temp]*biqs[biqs_d1]); + biqs[biqs_cL2] = (biqs[biqs_outL] * -biqs[biqs_dis]) - (biqs[biqs_temp]*biqs[biqs_d2]); + biqs[biqs_outL] = biqs[biqs_temp]; + biqs[biqs_dis] = fabs(biqs[biqs_e0] * (1.0+(biqs[biqs_outL]*biqs[biqs_nonlin]))); + if (biqs[biqs_dis] > 1.0) biqs[biqs_dis] = 1.0; + biqs[biqs_temp] = (biqs[biqs_outL] * biqs[biqs_dis]) + biqs[biqs_eL1]; + biqs[biqs_eL1] = biqs[biqs_eL2] - (biqs[biqs_temp]*biqs[biqs_f1]); + biqs[biqs_eL2] = (biqs[biqs_outL] * -biqs[biqs_dis]) - (biqs[biqs_temp]*biqs[biqs_f2]); + biqs[biqs_outL] = biqs[biqs_temp]; + biqs[biqs_outL] *= biqs[biqs_level]; + if (biqs[biqs_level] > 1.0) biqs[biqs_outL] *= biqs[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L + + //begin Stacked Biquad With Reversed Neutron Flow R + biqs[biqs_outR] = inputSampleR * fabs(biqs[biqs_level]); + biqs[biqs_dis] = fabs(biqs[biqs_a0] * (1.0+(biqs[biqs_outR]*biqs[biqs_nonlin]))); + if (biqs[biqs_dis] > 1.0) biqs[biqs_dis] = 1.0; + biqs[biqs_temp] = (biqs[biqs_outR] * biqs[biqs_dis]) + biqs[biqs_aR1]; + biqs[biqs_aR1] = biqs[biqs_aR2] - (biqs[biqs_temp]*biqs[biqs_b1]); + biqs[biqs_aR2] = (biqs[biqs_outR] * -biqs[biqs_dis]) - (biqs[biqs_temp]*biqs[biqs_b2]); + biqs[biqs_outR] = biqs[biqs_temp]; + biqs[biqs_dis] = fabs(biqs[biqs_c0] * (1.0+(biqs[biqs_outR]*biqs[biqs_nonlin]))); + if (biqs[biqs_dis] > 1.0) biqs[biqs_dis] = 1.0; + biqs[biqs_temp] = (biqs[biqs_outR] * biqs[biqs_dis]) + biqs[biqs_cR1]; + biqs[biqs_cR1] = biqs[biqs_cR2] - (biqs[biqs_temp]*biqs[biqs_d1]); + biqs[biqs_cR2] = (biqs[biqs_outR] * -biqs[biqs_dis]) - (biqs[biqs_temp]*biqs[biqs_d2]); + biqs[biqs_outR] = biqs[biqs_temp]; + biqs[biqs_dis] = fabs(biqs[biqs_e0] * (1.0+(biqs[biqs_outR]*biqs[biqs_nonlin]))); + if (biqs[biqs_dis] > 1.0) biqs[biqs_dis] = 1.0; + biqs[biqs_temp] = (biqs[biqs_outR] * biqs[biqs_dis]) + biqs[biqs_eR1]; + biqs[biqs_eR1] = biqs[biqs_eR2] - (biqs[biqs_temp]*biqs[biqs_f1]); + biqs[biqs_eR2] = (biqs[biqs_outR] * -biqs[biqs_dis]) - (biqs[biqs_temp]*biqs[biqs_f2]); + biqs[biqs_outR] = biqs[biqs_temp]; + biqs[biqs_outR] *= biqs[biqs_level]; + if (biqs[biqs_level] > 1.0) biqs[biqs_outR] *= biqs[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R + + inputSampleL += biqs[biqs_outL]; //purely a parallel filter stage here + inputSampleR += biqs[biqs_outR]; //purely a parallel filter stage here + + //begin 64 bit stereo floating point dither + //int expon; frexp((double)inputSampleL, &expon); + fpdL ^= fpdL << 13; fpdL ^= fpdL >> 17; fpdL ^= fpdL << 5; + //inputSampleL += ((double(fpdL)-uint32_t(0x7fffffff)) * 1.1e-44l * pow(2,expon+62)); + //frexp((double)inputSampleR, &expon); + fpdR ^= fpdR << 13; fpdR ^= fpdR >> 17; fpdR ^= fpdR << 5; + //inputSampleR += ((double(fpdR)-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++; + } +} +} // end namespace diff --git a/src/autogen_airwin/CMakeLists.txt b/src/autogen_airwin/CMakeLists.txt index 6893110..01664ea 100644 --- a/src/autogen_airwin/CMakeLists.txt +++ b/src/autogen_airwin/CMakeLists.txt @@ -53,12 +53,16 @@ set(AIRWIN_SOURCES src/autogen_airwin/Biquad2Proc.cpp src/autogen_airwin/BiquadDouble.cpp src/autogen_airwin/BiquadDoubleProc.cpp + src/autogen_airwin/BiquadHiLo.cpp + src/autogen_airwin/BiquadHiLoProc.cpp src/autogen_airwin/BiquadNonLin.cpp src/autogen_airwin/BiquadNonLinProc.cpp src/autogen_airwin/BiquadOneHalf.cpp src/autogen_airwin/BiquadOneHalfProc.cpp src/autogen_airwin/BiquadPlus.cpp src/autogen_airwin/BiquadPlusProc.cpp + src/autogen_airwin/BiquadStack.cpp + src/autogen_airwin/BiquadStackProc.cpp src/autogen_airwin/BiquadTriple.cpp src/autogen_airwin/BiquadTripleProc.cpp src/autogen_airwin/BitGlitter.cpp @@ -211,10 +215,6 @@ set(AIRWIN_SOURCES src/autogen_airwin/ConsoleXBussProc.cpp src/autogen_airwin/ConsoleXChannel.cpp src/autogen_airwin/ConsoleXChannelProc.cpp - src/autogen_airwin/ConsoleXSubIn.cpp - src/autogen_airwin/ConsoleXSubInProc.cpp - src/autogen_airwin/ConsoleXSubOut.cpp - src/autogen_airwin/ConsoleXSubOutProc.cpp src/autogen_airwin/ContentHideD.cpp src/autogen_airwin/ContentHideDProc.cpp src/autogen_airwin/Creature.cpp @@ -261,6 +261,8 @@ set(AIRWIN_SOURCES src/autogen_airwin/DistanceProc.cpp src/autogen_airwin/Distance2.cpp src/autogen_airwin/Distance2Proc.cpp + src/autogen_airwin/Distance3.cpp + src/autogen_airwin/Distance3Proc.cpp src/autogen_airwin/Distortion.cpp src/autogen_airwin/DistortionProc.cpp src/autogen_airwin/DitherFloat.cpp @@ -493,6 +495,8 @@ set(AIRWIN_SOURCES src/autogen_airwin/PafnutyProc.cpp src/autogen_airwin/Pafnuty2.cpp src/autogen_airwin/Pafnuty2Proc.cpp + src/autogen_airwin/Parametric.cpp + src/autogen_airwin/ParametricProc.cpp src/autogen_airwin/PaulDither.cpp src/autogen_airwin/PaulDitherProc.cpp src/autogen_airwin/PaulWide.cpp @@ -527,6 +531,8 @@ set(AIRWIN_SOURCES src/autogen_airwin/PopProc.cpp src/autogen_airwin/Pop2.cpp src/autogen_airwin/Pop2Proc.cpp + src/autogen_airwin/Pop3.cpp + src/autogen_airwin/Pop3Proc.cpp src/autogen_airwin/PowerSag.cpp src/autogen_airwin/PowerSagProc.cpp src/autogen_airwin/PowerSag2.cpp @@ -639,6 +645,8 @@ set(AIRWIN_SOURCES src/autogen_airwin/StereoEnsembleProc.cpp src/autogen_airwin/StereoFX.cpp src/autogen_airwin/StereoFXProc.cpp + src/autogen_airwin/StoneFireComp.cpp + src/autogen_airwin/StoneFireCompProc.cpp src/autogen_airwin/Stonefire.cpp src/autogen_airwin/StonefireProc.cpp src/autogen_airwin/StudioTan.cpp diff --git a/src/autogen_airwin/ConsoleXBuss.cpp b/src/autogen_airwin/ConsoleXBuss.cpp index 0d460fa..d1d008b 100644 --- a/src/autogen_airwin/ConsoleXBuss.cpp +++ b/src/autogen_airwin/ConsoleXBuss.cpp @@ -15,24 +15,64 @@ AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new C ConsoleXBuss::ConsoleXBuss(audioMasterCallback audioMaster) : AudioEffectX(audioMaster, kNumPrograms, kNumParameters) { - A = 0.5; - B = 0.5; - C = 0.5; - D = 0.5; - E = 0.5; - F = 0.5; - G = 0.5; - H = 0.5; + HIP = 0.0; + LOP = 0.0; + AIR = 0.5; + FIR = 0.5; + STO = 0.5; + RNG = 0.5; + FCT = 1.0; + SCT = 1.0; + FCR = 1.0; + SCR = 1.0; + FCA = 0.5; + SCA = 0.5; + FCL = 0.5; + SCL = 0.5; + FGT = 0.0; + SGT = 0.0; + FGR = 1.0; + SGR = 1.0; + FGS = 0.5; + SGS = 0.5; + FGL = 0.5; + SGL = 0.5; + TRF = 0.5; + TRG = 0.5; + TRR = 0.5; + HMF = 0.5; + HMG = 0.5; + HMR = 0.5; + LMF = 0.5; + LMG = 0.5; + LMR = 0.5; + BSF = 0.5; + BSG = 0.5; + BSR = 0.5; + DSC = 0.5; + PAN = 0.5; + FAD = 0.5; + + for (int x = 0; x < hilp_total; x++) { + highpass[x] = 0.0; + lowpass[x] = 0.0; + } - for (int x = 0; x < biq_total; x++) {biquad[x] = 0.0;} for (int x = 0; x < air_total; x++) air[x] = 0.0; for (int x = 0; x < kal_total; x++) kal[x] = 0.0; + fireCompL = 1.0; + fireCompR = 1.0; + fireGate = 1.0; + stoneCompL = 1.0; + stoneCompR = 1.0; + stoneGate = 1.0; - for(int count = 0; count < 2004; count++) {mpkL[count] = 0.0; mpkR[count] = 0.0;} - for(int count = 0; count < 65; count++) {f[count] = 0.0;} - prevfreqMPeak = -1; - prevamountMPeak = -1; - mpc = 1; + for (int x = 0; x < biqs_total; x++) { + high[x] = 0.0; + hmid[x] = 0.0; + lmid[x] = 0.0; + bass[x] = 0.0; + } for(int count = 0; count < dscBuf+2; count++) { dBaL[count] = 0.0; @@ -42,13 +82,13 @@ ConsoleXBuss::ConsoleXBuss(audioMasterCallback audioMaster) : dBaPosR = 0.0; dBaXL = 1; dBaXR = 1; - - trebleGainA = 1.0; trebleGainB = 1.0; - midGainA = 1.0; midGainB = 1.0; - mPeakA = 1.0; mPeakB = 1.0; - bassGainA = 1.0; bassGainB = 1.0; + + airGainA = 0.5; airGainB = 0.5; + fireGainA = 0.5; fireGainB = 0.5; + stoneGainA = 0.5; stoneGainB = 0.5; panA = 0.5; panB = 0.5; - inTrimA = 1.0; inTrimB = 1.0; + inTrimA = 1.0; inTrimB = 1.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. @@ -81,70 +121,215 @@ static float pinParameter(float data) void ConsoleXBuss::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; - case kParamF: F = value; break; - case kParamG: G = value; break; - case kParamH: H = value; break; + case kParamHIP: HIP = value; break; + case kParamLOP: LOP = value; break; + case kParamAIR: AIR = value; break; + case kParamFIR: FIR = value; break; + case kParamSTO: STO = value; break; + case kParamRNG: RNG = value; break; + case kParamFCT: FCT = value; break; + case kParamSCT: SCT = value; break; + case kParamFCR: FCR = value; break; + case kParamSCR: SCR = value; break; + case kParamFCA: FCA = value; break; + case kParamSCA: SCA = value; break; + case kParamFCL: FCL = value; break; + case kParamSCL: SCL = value; break; + case kParamFGT: FGT = value; break; + case kParamSGT: SGT = value; break; + case kParamFGR: FGR = value; break; + case kParamSGR: SGR = value; break; + case kParamFGS: FGS = value; break; + case kParamSGS: SGS = value; break; + case kParamFGL: FGL = value; break; + case kParamSGL: SGL = value; break; + case kParamTRF: TRF = value; break; + case kParamTRG: TRG = value; break; + case kParamTRR: TRR = value; break; + case kParamHMF: HMF = value; break; + case kParamHMG: HMG = value; break; + case kParamHMR: HMR = value; break; + case kParamLMF: LMF = value; break; + case kParamLMG: LMG = value; break; + case kParamLMR: LMR = value; break; + case kParamBSF: BSF = value; break; + case kParamBSG: BSG = value; break; + case kParamBSR: BSR = value; break; + case kParamDSC: DSC = value; break; + case kParamPAN: PAN = value; break; + case kParamFAD: FAD = value; break; default: break; // unknown parameter, shouldn't happen! } } float ConsoleXBuss::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; - case kParamF: return F; break; - case kParamG: return G; break; - case kParamH: return H; break; + case kParamHIP: return HIP; break; + case kParamLOP: return LOP; break; + case kParamAIR: return AIR; break; + case kParamFIR: return FIR; break; + case kParamSTO: return STO; break; + case kParamRNG: return RNG; break; + case kParamFCT: return FCT; break; + case kParamSCT: return SCT; break; + case kParamFCR: return FCR; break; + case kParamSCR: return SCR; break; + case kParamFCA: return FCA; break; + case kParamSCA: return SCA; break; + case kParamFCL: return FCL; break; + case kParamSCL: return SCL; break; + case kParamFGT: return FGT; break; + case kParamSGT: return SGT; break; + case kParamFGR: return FGR; break; + case kParamSGR: return SGR; break; + case kParamFGS: return FGS; break; + case kParamSGS: return SGS; break; + case kParamFGL: return FGL; break; + case kParamSGL: return SGL; break; + case kParamTRF: return TRF; break; + case kParamTRG: return TRG; break; + case kParamTRR: return TRR; break; + case kParamHMF: return HMF; break; + case kParamHMG: return HMG; break; + case kParamHMR: return HMR; break; + case kParamLMF: return LMF; break; + case kParamLMG: return LMG; break; + case kParamLMR: return LMR; break; + case kParamBSF: return BSF; break; + case kParamBSG: return BSG; break; + case kParamBSR: return BSR; break; + case kParamDSC: return DSC; break; + case kParamPAN: return PAN; break; + case kParamFAD: return FAD; 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 ConsoleXBuss::getParameterName(VstInt32 index, char *text) { switch (index) { - case kParamA: vst_strncpy (text, "Air", kVstMaxParamStrLen); break; - case kParamB: vst_strncpy (text, "Fire", kVstMaxParamStrLen); break; - case kParamC: vst_strncpy (text, "Stone", kVstMaxParamStrLen); break; - case kParamD: vst_strncpy (text, "Reso", kVstMaxParamStrLen); break; - case kParamE: vst_strncpy (text, "Range", kVstMaxParamStrLen); break; - case kParamF: vst_strncpy (text, "Top dB", kVstMaxParamStrLen); break; - case kParamG: vst_strncpy (text, "Pan", kVstMaxParamStrLen); break; - case kParamH: vst_strncpy (text, "Fader", kVstMaxParamStrLen); break; + case kParamHIP: vst_strncpy (text, "Highpas", kVstMaxParamStrLen); break; + case kParamLOP: vst_strncpy (text, "Lowpass", kVstMaxParamStrLen); break; + case kParamAIR: vst_strncpy (text, "Air", kVstMaxParamStrLen); break; + case kParamFIR: vst_strncpy (text, "Fire", kVstMaxParamStrLen); break; + case kParamSTO: vst_strncpy (text, "Stone", kVstMaxParamStrLen); break; + case kParamRNG: vst_strncpy (text, "Range", kVstMaxParamStrLen); break; + case kParamFCT: vst_strncpy (text, "FC Thrs", kVstMaxParamStrLen); break; + case kParamSCT: vst_strncpy (text, "SC Thrs", kVstMaxParamStrLen); break; + case kParamFCR: vst_strncpy (text, "FC Rati", kVstMaxParamStrLen); break; + case kParamSCR: vst_strncpy (text, "SC Rati", kVstMaxParamStrLen); break; + case kParamFCA: vst_strncpy (text, "FC Atk", kVstMaxParamStrLen); break; + case kParamSCA: vst_strncpy (text, "SC Atk", kVstMaxParamStrLen); break; + case kParamFCL: vst_strncpy (text, "FC Rls", kVstMaxParamStrLen); break; + case kParamSCL: vst_strncpy (text, "SC Rls", kVstMaxParamStrLen); break; + case kParamFGT: vst_strncpy (text, "FG Thrs", kVstMaxParamStrLen); break; + case kParamSGT: vst_strncpy (text, "SG Thrs", kVstMaxParamStrLen); break; + case kParamFGR: vst_strncpy (text, "FG Rati", kVstMaxParamStrLen); break; + case kParamSGR: vst_strncpy (text, "SG Rati", kVstMaxParamStrLen); break; + case kParamFGS: vst_strncpy (text, "FG Sust", kVstMaxParamStrLen); break; + case kParamSGS: vst_strncpy (text, "SG Sust", kVstMaxParamStrLen); break; + case kParamFGL: vst_strncpy (text, "FG Rls", kVstMaxParamStrLen); break; + case kParamSGL: vst_strncpy (text, "SG Rls", kVstMaxParamStrLen); break; + case kParamTRF: vst_strncpy (text, "Tr Freq", kVstMaxParamStrLen); break; + case kParamTRG: vst_strncpy (text, "Treble", kVstMaxParamStrLen); break; + case kParamTRR: vst_strncpy (text, "Tr Reso", kVstMaxParamStrLen); break; + case kParamHMF: vst_strncpy (text, "HM Freq", kVstMaxParamStrLen); break; + case kParamHMG: vst_strncpy (text, "HighMid", kVstMaxParamStrLen); break; + case kParamHMR: vst_strncpy (text, "HM Reso", kVstMaxParamStrLen); break; + case kParamLMF: vst_strncpy (text, "LM Freq", kVstMaxParamStrLen); break; + case kParamLMG: vst_strncpy (text, "LowMid", kVstMaxParamStrLen); break; + case kParamLMR: vst_strncpy (text, "LM Reso", kVstMaxParamStrLen); break; + case kParamBSF: vst_strncpy (text, "Bs Freq", kVstMaxParamStrLen); break; + case kParamBSG: vst_strncpy (text, "Bass", kVstMaxParamStrLen); break; + case kParamBSR: vst_strncpy (text, "Bs Reso", kVstMaxParamStrLen); break; + case kParamDSC: vst_strncpy (text, "Top dB", kVstMaxParamStrLen); break; + case kParamPAN: vst_strncpy (text, "Pan", kVstMaxParamStrLen); break; + case kParamFAD: vst_strncpy (text, "Fader", kVstMaxParamStrLen); break; default: break; // unknown parameter, shouldn't happen! } //this is our labels for displaying in the VST host } void ConsoleXBuss::getParameterDisplay(VstInt32 index, char *text) { switch (index) { - case kParamA: float2string (A, text, kVstMaxParamStrLen); break; - case kParamB: float2string (B, text, kVstMaxParamStrLen); break; - case kParamC: float2string (C, text, kVstMaxParamStrLen); break; - case kParamD: float2string (D, text, kVstMaxParamStrLen); break; - case kParamE: float2string (E, text, kVstMaxParamStrLen); break; - case kParamF: float2string ((F*70.0)+70.0, text, kVstMaxParamStrLen); break; - case kParamG: float2string (G, text, kVstMaxParamStrLen); break; - case kParamH: float2string (H, text, kVstMaxParamStrLen); break; + case kParamHIP: float2string (HIP, text, kVstMaxParamStrLen); break; + case kParamLOP: float2string (LOP, text, kVstMaxParamStrLen); break; + case kParamAIR: float2string (AIR, text, kVstMaxParamStrLen); break; + case kParamFIR: float2string (FIR, text, kVstMaxParamStrLen); break; + case kParamSTO: float2string (STO, text, kVstMaxParamStrLen); break; + case kParamRNG: float2string (RNG, text, kVstMaxParamStrLen); break; + case kParamFCT: float2string (FCT, text, kVstMaxParamStrLen); break; + case kParamSCT: float2string (SCT, text, kVstMaxParamStrLen); break; + case kParamFCR: float2string (FCR, text, kVstMaxParamStrLen); break; + case kParamSCR: float2string (SCR, text, kVstMaxParamStrLen); break; + case kParamFCA: float2string (FCA, text, kVstMaxParamStrLen); break; + case kParamSCA: float2string (SCA, text, kVstMaxParamStrLen); break; + case kParamFCL: float2string (FCL, text, kVstMaxParamStrLen); break; + case kParamSCL: float2string (SCL, text, kVstMaxParamStrLen); break; + case kParamFGT: float2string (FGT, text, kVstMaxParamStrLen); break; + case kParamSGT: float2string (SGT, text, kVstMaxParamStrLen); break; + case kParamFGR: float2string (FGR, text, kVstMaxParamStrLen); break; + case kParamSGR: float2string (SGR, text, kVstMaxParamStrLen); break; + case kParamFGS: float2string (FGS, text, kVstMaxParamStrLen); break; + case kParamSGS: float2string (SGS, text, kVstMaxParamStrLen); break; + case kParamFGL: float2string (FGL, text, kVstMaxParamStrLen); break; + case kParamSGL: float2string (SGL, text, kVstMaxParamStrLen); break; + case kParamTRF: float2string (TRF, text, kVstMaxParamStrLen); break; + case kParamTRG: float2string (TRG, text, kVstMaxParamStrLen); break; + case kParamTRR: float2string (TRR, text, kVstMaxParamStrLen); break; + case kParamHMF: float2string (HMF, text, kVstMaxParamStrLen); break; + case kParamHMG: float2string (HMG, text, kVstMaxParamStrLen); break; + case kParamHMR: float2string (HMR, text, kVstMaxParamStrLen); break; + case kParamLMF: float2string (LMF, text, kVstMaxParamStrLen); break; + case kParamLMG: float2string (LMG, text, kVstMaxParamStrLen); break; + case kParamLMR: float2string (LMR, text, kVstMaxParamStrLen); break; + case kParamBSF: float2string (BSF, text, kVstMaxParamStrLen); break; + case kParamBSG: float2string (BSG, text, kVstMaxParamStrLen); break; + case kParamBSR: float2string (BSR, text, kVstMaxParamStrLen); break; + case kParamDSC: float2string ((DSC*70.0)+70.0, text, kVstMaxParamStrLen); break; + case kParamPAN: float2string (PAN, text, kVstMaxParamStrLen); break; + case kParamFAD: float2string (FAD, text, kVstMaxParamStrLen); break; default: break; // unknown parameter, shouldn't happen! } //this displays the values and handles 'popups' where it's discrete choices } void ConsoleXBuss::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; - case kParamF: vst_strncpy (text, "dB", kVstMaxParamStrLen); break; - case kParamG: vst_strncpy (text, "", kVstMaxParamStrLen); break; - case kParamH: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamHIP: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamLOP: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamAIR: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamFIR: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamSTO: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamRNG: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamFCT: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamSCT: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamFCR: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamSCR: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamFCA: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamSCA: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamFCL: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamSCL: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamFGT: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamSGT: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamFGR: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamSGR: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamFGS: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamSGS: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamFGL: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamSGL: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamTRF: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamTRG: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamTRR: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamHMF: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamHMG: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamHMR: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamLMF: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamLMG: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamLMR: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamBSF: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamBSG: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamBSR: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamDSC: vst_strncpy (text, "dB", kVstMaxParamStrLen); break; + case kParamPAN: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamFAD: vst_strncpy (text, "", kVstMaxParamStrLen); break; default: break; // unknown parameter, shouldn't happen! } } @@ -167,28 +352,86 @@ bool ConsoleXBuss::getVendorString(char* text) { } bool ConsoleXBuss::parameterTextToValue(VstInt32 index, const char *text, float &value) { switch(index) { - case kParamA: { auto b = string2float(text, value); return b; break; } - case kParamB: { auto b = string2float(text, value); return b; break; } - case kParamC: { auto b = string2float(text, value); return b; break; } - case kParamD: { auto b = string2float(text, value); return b; break; } - case kParamE: { auto b = string2float(text, value); return b; break; } - case kParamF: { auto b = string2float(text, value); if (b) { value = (value - 70.0) / (70.0); } return b; break; } - case kParamG: { auto b = string2float(text, value); return b; break; } - case kParamH: { auto b = string2float(text, value); return b; break; } + case kParamHIP: { auto b = string2float(text, value); return b; break; } + case kParamLOP: { auto b = string2float(text, value); return b; break; } + case kParamAIR: { auto b = string2float(text, value); return b; break; } + case kParamFIR: { auto b = string2float(text, value); return b; break; } + case kParamSTO: { auto b = string2float(text, value); return b; break; } + case kParamRNG: { auto b = string2float(text, value); return b; break; } + case kParamFCT: { auto b = string2float(text, value); return b; break; } + case kParamSCT: { auto b = string2float(text, value); return b; break; } + case kParamFCR: { auto b = string2float(text, value); return b; break; } + case kParamSCR: { auto b = string2float(text, value); return b; break; } + case kParamFCA: { auto b = string2float(text, value); return b; break; } + case kParamSCA: { auto b = string2float(text, value); return b; break; } + case kParamFCL: { auto b = string2float(text, value); return b; break; } + case kParamSCL: { auto b = string2float(text, value); return b; break; } + case kParamFGT: { auto b = string2float(text, value); return b; break; } + case kParamSGT: { auto b = string2float(text, value); return b; break; } + case kParamFGR: { auto b = string2float(text, value); return b; break; } + case kParamSGR: { auto b = string2float(text, value); return b; break; } + case kParamFGS: { auto b = string2float(text, value); return b; break; } + case kParamSGS: { auto b = string2float(text, value); return b; break; } + case kParamFGL: { auto b = string2float(text, value); return b; break; } + case kParamSGL: { auto b = string2float(text, value); return b; break; } + case kParamTRF: { auto b = string2float(text, value); return b; break; } + case kParamTRG: { auto b = string2float(text, value); return b; break; } + case kParamTRR: { auto b = string2float(text, value); return b; break; } + case kParamHMF: { auto b = string2float(text, value); return b; break; } + case kParamHMG: { auto b = string2float(text, value); return b; break; } + case kParamHMR: { auto b = string2float(text, value); return b; break; } + case kParamLMF: { auto b = string2float(text, value); return b; break; } + case kParamLMG: { auto b = string2float(text, value); return b; break; } + case kParamLMR: { auto b = string2float(text, value); return b; break; } + case kParamBSF: { auto b = string2float(text, value); return b; break; } + case kParamBSG: { auto b = string2float(text, value); return b; break; } + case kParamBSR: { auto b = string2float(text, value); return b; break; } + case kParamDSC: { auto b = string2float(text, value); if (b) { value = (value - 70.0) / (70.0); } return b; break; } + case kParamPAN: { auto b = string2float(text, value); return b; break; } + case kParamFAD: { auto b = string2float(text, value); return b; break; } } return false; } bool ConsoleXBuss::canConvertParameterTextToValue(VstInt32 index) { switch(index) { - case kParamA: return true; - case kParamB: return true; - case kParamC: return true; - case kParamD: return true; - case kParamE: return true; - case kParamF: return true; - case kParamG: return true; - case kParamH: return true; + case kParamHIP: return true; + case kParamLOP: return true; + case kParamAIR: return true; + case kParamFIR: return true; + case kParamSTO: return true; + case kParamRNG: return true; + case kParamFCT: return true; + case kParamSCT: return true; + case kParamFCR: return true; + case kParamSCR: return true; + case kParamFCA: return true; + case kParamSCA: return true; + case kParamFCL: return true; + case kParamSCL: return true; + case kParamFGT: return true; + case kParamSGT: return true; + case kParamFGR: return true; + case kParamSGR: return true; + case kParamFGS: return true; + case kParamSGS: return true; + case kParamFGL: return true; + case kParamSGL: return true; + case kParamTRF: return true; + case kParamTRG: return true; + case kParamTRR: return true; + case kParamHMF: return true; + case kParamHMG: return true; + case kParamHMR: return true; + case kParamLMF: return true; + case kParamLMG: return true; + case kParamLMR: return true; + case kParamBSF: return true; + case kParamBSG: return true; + case kParamBSR: return true; + case kParamDSC: return true; + case kParamPAN: return true; + case kParamFAD: return true; } return false; diff --git a/src/autogen_airwin/ConsoleXBuss.h b/src/autogen_airwin/ConsoleXBuss.h index 45f6cc5..8c2803b 100644 --- a/src/autogen_airwin/ConsoleXBuss.h +++ b/src/autogen_airwin/ConsoleXBuss.h @@ -17,18 +17,48 @@ namespace airwinconsolidated::ConsoleXBuss { enum { - kParamA = 0, - kParamB = 1, - kParamC = 2, - kParamD = 3, - kParamE = 4, - kParamF = 5, - kParamG = 6, - kParamH = 7, - kNumParameters = 8 + kParamHIP = 0, + kParamLOP = 1, + kParamAIR = 2, + kParamFIR = 3, + kParamSTO = 4, + kParamRNG = 5, + kParamFCT = 6, + kParamSCT = 7, + kParamFCR = 8, + kParamSCR = 9, + kParamFCA = 10, + kParamSCA = 11, + kParamFCL = 12, + kParamSCL = 13, + kParamFGT = 14, + kParamSGT = 15, + kParamFGR = 16, + kParamSGR = 17, + kParamFGS = 18, + kParamSGS = 19, + kParamFGL = 20, + kParamSGL = 21, + kParamTRF = 22, + kParamTRG = 23, + kParamTRR = 24, + kParamHMF = 25, + kParamHMG = 26, + kParamHMR = 27, + kParamLMF = 28, + kParamLMG = 29, + kParamLMR = 30, + kParamBSF = 31, + kParamBSG = 32, + kParamBSR = 33, + kParamDSC = 34, + kParamPAN = 35, + kParamFAD = 36, + kNumParameters = 37 }; // const int dscBuf = 90; + const int kNumPrograms = 0; const int kNumInputs = 2; const int kNumOutputs = 2; @@ -62,96 +92,112 @@ class ConsoleXBuss : char _programName[kVstMaxProgNameLen + 1]; std::set< std::string > _canDo; - uint32_t fpdL; - uint32_t fpdR; - //default stuff + float HIP; + float LOP; + float AIR; + float FIR; + float STO; + float RNG; + float FCT; + float SCT; + float FCR; + float SCR; + float FCA; + float SCA; + float FCL; + float SCL; + float FGT; + float SGT; + float FGR; + float SGR; + float FGS; + float SGS; + float FGL; + float SGL; + float TRF; + float TRG; + float TRR; + float HMF; + float HMG; + float HMR; + float LMF; + float LMG; + float LMR; + float BSF; + float BSG; + float BSR; + float DSC; + float PAN; + float FAD; enum { - biq_freq, - biq_reso, - biq_a0, - biq_a1, - biq_a2, - biq_b1, - biq_b2, - biq_sL1, - biq_sL2, - biq_sR1, - biq_sR2, - biq_total + hilp_freq, hilp_temp, + hilp_a0, hilp_aA0, hilp_aB0, hilp_a1, hilp_aA1, hilp_aB1, hilp_b1, hilp_bA1, hilp_bB1, hilp_b2, hilp_bA2, hilp_bB2, + hilp_c0, hilp_cA0, hilp_cB0, hilp_c1, hilp_cA1, hilp_cB1, hilp_d1, hilp_dA1, hilp_dB1, hilp_d2, hilp_dA2, hilp_dB2, + hilp_e0, hilp_eA0, hilp_eB0, hilp_e1, hilp_eA1, hilp_eB1, hilp_f1, hilp_fA1, hilp_fB1, hilp_f2, hilp_fA2, hilp_fB2, + hilp_aL1, hilp_aL2, hilp_aR1, hilp_aR2, + hilp_cL1, hilp_cL2, hilp_cR1, hilp_cR2, + hilp_eL1, hilp_eL2, hilp_eR1, hilp_eR2, + hilp_total }; - double biquad[biq_total]; + double highpass[hilp_total]; + double lowpass[hilp_total]; enum { - pvAL1, - pvSL1, - accSL1, - acc2SL1, - pvAL2, - pvSL2, - accSL2, - acc2SL2, - pvAL3, - pvSL3, - accSL3, - pvAL4, - pvSL4, - gndavgL, - outAL, - gainAL, - pvAR1, - pvSR1, - accSR1, - acc2SR1, - pvAR2, - pvSR2, - accSR2, - acc2SR2, - pvAR3, - pvSR3, - accSR3, - pvAR4, - pvSR4, - gndavgR, - outAR, - gainAR, + pvAL1, pvSL1, accSL1, acc2SL1, + pvAL2, pvSL2, accSL2, acc2SL2, + pvAL3, pvSL3, accSL3, + pvAL4, pvSL4, + gndavgL, outAL, gainAL, + pvAR1, pvSR1, accSR1, acc2SR1, + pvAR2, pvSR2, accSR2, acc2SR2, + pvAR3, pvSR3, accSR3, + pvAR4, pvSR4, + gndavgR, outAR, gainAR, air_total }; double air[air_total]; enum { - prevSampL1, - prevSlewL1, - accSlewL1, - prevSampL2, - prevSlewL2, - accSlewL2, - prevSampL3, - prevSlewL3, - accSlewL3, - kalGainL, - kalOutL, - prevSampR1, - prevSlewR1, - accSlewR1, - prevSampR2, - prevSlewR2, - accSlewR2, - prevSampR3, - prevSlewR3, - accSlewR3, - kalGainR, - kalOutR, + prevSampL1, prevSlewL1, accSlewL1, + prevSampL2, prevSlewL2, accSlewL2, + prevSampL3, prevSlewL3, accSlewL3, + kalGainL, kalOutL, + prevSampR1, prevSlewR1, accSlewR1, + prevSampR2, prevSlewR2, accSlewR2, + prevSampR3, prevSlewR3, accSlewR3, + kalGainR, kalOutR, kal_total }; double kal[kal_total]; + double fireCompL; + double fireCompR; + double fireGate; + double stoneCompL; + double stoneCompR; + double stoneGate; + double airGainA; + double airGainB; + double fireGainA; + double fireGainB; + double stoneGainA; + double stoneGainB; - double mpkL[2005]; - double mpkR[2005]; - double f[66]; - double prevfreqMPeak; - double prevamountMPeak; - int mpc; + enum { + biqs_freq, biqs_reso, biqs_level, + biqs_nonlin, biqs_temp, biqs_dis, + biqs_a0, biqs_a1, biqs_b1, biqs_b2, + biqs_c0, biqs_c1, biqs_d1, biqs_d2, + biqs_e0, biqs_e1, biqs_f1, biqs_f2, + biqs_aL1, biqs_aL2, biqs_aR1, biqs_aR2, + biqs_cL1, biqs_cL2, biqs_cR1, biqs_cR2, + biqs_eL1, biqs_eL2, biqs_eR1, biqs_eR2, + biqs_outL, biqs_outR, biqs_total + }; + double high[biqs_total]; + double hmid[biqs_total]; + double lmid[biqs_total]; + double bass[biqs_total]; double dBaL[dscBuf+5]; double dBaR[dscBuf+5]; @@ -160,27 +206,14 @@ class ConsoleXBuss : int dBaXL; int dBaXR; - double trebleGainA; - double trebleGainB; - double midGainA; - double midGainB; - double mPeakA; - double mPeakB; - double bassGainA; - double bassGainB; double panA; double panB; double inTrimA; double inTrimB; - - float A; - float B; - float C; - float D; - float E; - float F; - float G; - float H; + + uint32_t fpdL; + uint32_t fpdR; + //default stuff }; #endif diff --git a/src/autogen_airwin/ConsoleXBussProc.cpp b/src/autogen_airwin/ConsoleXBussProc.cpp index 5b3e8db..a94ebf7 100644 --- a/src/autogen_airwin/ConsoleXBussProc.cpp +++ b/src/autogen_airwin/ConsoleXBussProc.cpp @@ -19,48 +19,215 @@ void ConsoleXBuss::processReplacing(float **inputs, float **outputs, VstInt32 sa double overallscale = 1.0; overallscale /= 44100.0; overallscale *= getSampleRate(); - int cycleEnd = floor(overallscale); - if (cycleEnd < 1) cycleEnd = 1; - if (cycleEnd > 3) cycleEnd = 3; - biquad[biq_freq] = 25000.0/getSampleRate(); - biquad[biq_reso] = 2.56291545; - double K = tan(M_PI * biquad[biq_freq]); - double norm = 1.0 / (1.0 + K / biquad[biq_reso] + K * K); - biquad[biq_a0] = K * K * norm; - biquad[biq_a1] = 2.0 * biquad[biq_a0]; - biquad[biq_a2] = biquad[biq_a0]; - biquad[biq_b1] = 2.0 * (K * K - 1.0) * norm; - biquad[biq_b2] = (1.0 - K / biquad[biq_reso] + K * K) * norm; - //ultrasonic nonlinear filter + highpass[hilp_freq] = ((pow(HIP,3)*24000.0)+10.0)/getSampleRate(); + if (highpass[hilp_freq] > 0.495) highpass[hilp_freq] = 0.495; + bool highpassEngage = true; if (HIP == 0.0) highpassEngage = false; - trebleGainA = trebleGainB; trebleGainB = A*2.0; - midGainA = midGainB; midGainB = B*2.0; - bassGainA = bassGainB; bassGainB = C*2.0; - //simple three band to adjust + lowpass[hilp_freq] = ((pow(1.0-LOP,3)*24000.0)+10.0)/getSampleRate(); + if (lowpass[hilp_freq] > 0.495) lowpass[hilp_freq] = 0.495; + bool lowpassEngage = true; if (LOP == 0.0) lowpassEngage = false; - //begin ResEQ2 Mid Boost - double freqMPeak = pow(D+0.16,3); - mPeakA = mPeakB; mPeakB = fabs(midGainB-1.0); //amount of mid peak leak through (or boost) - if (midGainB < 1.0) mPeakB *= 0.5; - int maxMPeak = (24.0*(2.0-freqMPeak))+16; - if ((freqMPeak != prevfreqMPeak)||(mPeakB != prevamountMPeak)) { - for (int x = 0; x < maxMPeak; x++) { - if (((double)x*freqMPeak) < M_PI_4) f[x] = sin(((double)x*freqMPeak)*4.0)*freqMPeak*sin(((double)(maxMPeak-x)/(double)maxMPeak)*M_PI_2); - else f[x] = cos((double)x*freqMPeak)*freqMPeak*sin(((double)(maxMPeak-x)/(double)maxMPeak)*M_PI_2); - } - prevfreqMPeak = freqMPeak; prevamountMPeak = mPeakB; - }//end ResEQ2 Mid Boost - //mid peak for either retaining during mid cut, or adding during mid boost + highpass[hilp_aA0] = highpass[hilp_aB0]; + highpass[hilp_aA1] = highpass[hilp_aB1]; + highpass[hilp_bA1] = highpass[hilp_bB1]; + highpass[hilp_bA2] = highpass[hilp_bB2]; + highpass[hilp_cA0] = highpass[hilp_cB0]; + highpass[hilp_cA1] = highpass[hilp_cB1]; + highpass[hilp_dA1] = highpass[hilp_dB1]; + highpass[hilp_dA2] = highpass[hilp_dB2]; + highpass[hilp_eA0] = highpass[hilp_eB0]; + highpass[hilp_eA1] = highpass[hilp_eB1]; + highpass[hilp_fA1] = highpass[hilp_fB1]; + highpass[hilp_fA2] = highpass[hilp_fB2]; + lowpass[hilp_aA0] = lowpass[hilp_aB0]; + lowpass[hilp_aA1] = lowpass[hilp_aB1]; + lowpass[hilp_bA1] = lowpass[hilp_bB1]; + lowpass[hilp_bA2] = lowpass[hilp_bB2]; + lowpass[hilp_cA0] = lowpass[hilp_cB0]; + lowpass[hilp_cA1] = lowpass[hilp_cB1]; + lowpass[hilp_dA1] = lowpass[hilp_dB1]; + lowpass[hilp_dA2] = lowpass[hilp_dB2]; + lowpass[hilp_eA0] = lowpass[hilp_eB0]; + lowpass[hilp_eA1] = lowpass[hilp_eB1]; + lowpass[hilp_fA1] = lowpass[hilp_fB1]; + lowpass[hilp_fA2] = lowpass[hilp_fB2]; + //previous run through the buffer is still in the filter, so we move it + //to the A section and now it's the new starting point. + + double K = tan(M_PI * highpass[hilp_freq]); //highpass + double norm = 1.0 / (1.0 + K / 1.93185165 + K * K); + highpass[hilp_aB0] = norm; + highpass[hilp_aB1] = -2.0 * highpass[hilp_aB0]; + highpass[hilp_bB1] = 2.0 * (K * K - 1.0) * norm; + highpass[hilp_bB2] = (1.0 - K / 1.93185165 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.70710678 + K * K); + highpass[hilp_cB0] = norm; + highpass[hilp_cB1] = -2.0 * highpass[hilp_cB0]; + highpass[hilp_dB1] = 2.0 * (K * K - 1.0) * norm; + highpass[hilp_dB2] = (1.0 - K / 0.70710678 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.51763809 + K * K); + highpass[hilp_eB0] = norm; + highpass[hilp_eB1] = -2.0 * highpass[hilp_eB0]; + highpass[hilp_fB1] = 2.0 * (K * K - 1.0) * norm; + highpass[hilp_fB2] = (1.0 - K / 0.51763809 + K * K) * norm; - double kalman = 1.0-pow(E,2); + K = tan(M_PI * lowpass[hilp_freq]); //lowpass + norm = 1.0 / (1.0 + K / 1.93185165 + K * K); + lowpass[hilp_aB0] = K * K * norm; + lowpass[hilp_aB1] = 2.0 * lowpass[hilp_aB0]; + lowpass[hilp_bB1] = 2.0 * (K * K - 1.0) * norm; + lowpass[hilp_bB2] = (1.0 - K / 1.93185165 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.70710678 + K * K); + lowpass[hilp_cB0] = K * K * norm; + lowpass[hilp_cB1] = 2.0 * lowpass[hilp_cB0]; + lowpass[hilp_dB1] = 2.0 * (K * K - 1.0) * norm; + lowpass[hilp_dB2] = (1.0 - K / 0.70710678 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.51763809 + K * K); + lowpass[hilp_eB0] = K * K * norm; + lowpass[hilp_eB1] = 2.0 * lowpass[hilp_eB0]; + lowpass[hilp_fB1] = 2.0 * (K * K - 1.0) * norm; + lowpass[hilp_fB2] = (1.0 - K / 0.51763809 + K * K) * norm; + + if (highpass[hilp_aA0] == 0.0) { // if we have just started, start directly with raw info + highpass[hilp_aA0] = highpass[hilp_aB0]; + highpass[hilp_aA1] = highpass[hilp_aB1]; + highpass[hilp_bA1] = highpass[hilp_bB1]; + highpass[hilp_bA2] = highpass[hilp_bB2]; + highpass[hilp_cA0] = highpass[hilp_cB0]; + highpass[hilp_cA1] = highpass[hilp_cB1]; + highpass[hilp_dA1] = highpass[hilp_dB1]; + highpass[hilp_dA2] = highpass[hilp_dB2]; + highpass[hilp_eA0] = highpass[hilp_eB0]; + highpass[hilp_eA1] = highpass[hilp_eB1]; + highpass[hilp_fA1] = highpass[hilp_fB1]; + highpass[hilp_fA2] = highpass[hilp_fB2]; + lowpass[hilp_aA0] = lowpass[hilp_aB0]; + lowpass[hilp_aA1] = lowpass[hilp_aB1]; + lowpass[hilp_bA1] = lowpass[hilp_bB1]; + lowpass[hilp_bA2] = lowpass[hilp_bB2]; + lowpass[hilp_cA0] = lowpass[hilp_cB0]; + lowpass[hilp_cA1] = lowpass[hilp_cB1]; + lowpass[hilp_dA1] = lowpass[hilp_dB1]; + lowpass[hilp_dA2] = lowpass[hilp_dB2]; + lowpass[hilp_eA0] = lowpass[hilp_eB0]; + lowpass[hilp_eA1] = lowpass[hilp_eB1]; + lowpass[hilp_fA1] = lowpass[hilp_fB1]; + lowpass[hilp_fA2] = lowpass[hilp_fB2]; + } + airGainA = airGainB; airGainB = AIR *2.0; + fireGainA = fireGainB; fireGainB = FIR *2.0; + stoneGainA = stoneGainB; stoneGainB = STO *2.0; + //simple three band to adjust + double kalmanRange = 1.0-pow(RNG,2); //crossover frequency between mid/bass - double refdB = (F*70.0)+70.0; + double compFThresh = pow(FCT,4); + double compSThresh = pow(SCT,4); + double compFRatio = 1.0-pow(1.0-FCR,2); + double compSRatio = 1.0-pow(1.0-SCR,2); + double compFAttack = 1.0/(((pow(FCA,3)*5000.0)+500.0)*overallscale); + double compSAttack = 1.0/(((pow(SCA,3)*5000.0)+500.0)*overallscale); + double compFRelease = 1.0/(((pow(FCL,5)*50000.0)+500.0)*overallscale); + double compSRelease = 1.0/(((pow(SCL,5)*50000.0)+500.0)*overallscale); + double gateFThresh = pow(FGT,4); + double gateSThresh = pow(SGT,4); + double gateFRatio = 1.0-pow(1.0-FGR,2); + double gateSRatio = 1.0-pow(1.0-SGR,2); + double gateFSustain = M_PI_2 * pow(FGS+1.0,4.0); + double gateSSustain = M_PI_2 * pow(SGS+1.0,4.0); + double gateFRelease = 1.0/(((pow(FGL,5)*500000.0)+500.0)*overallscale); + double gateSRelease = 1.0/(((pow(SGL,5)*500000.0)+500.0)*overallscale); + + high[biqs_freq] = (((pow(TRF,3)*14500.0)+1500.0)/getSampleRate()); + if (high[biqs_freq] < 0.0001) high[biqs_freq] = 0.0001; + high[biqs_nonlin] = TRG; + high[biqs_level] = (high[biqs_nonlin]*2.0)-1.0; + if (high[biqs_level] > 0.0) high[biqs_level] *= 2.0; + high[biqs_reso] = ((0.5+(high[biqs_nonlin]*0.5)+sqrt(high[biqs_freq]))-(1.0-pow(1.0-TRR,2.0)))+0.5+(high[biqs_nonlin]*0.5); + K = tan(M_PI * high[biqs_freq]); + norm = 1.0 / (1.0 + K / (high[biqs_reso]*1.93185165) + K * K); + high[biqs_a0] = K / (high[biqs_reso]*1.93185165) * norm; + high[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + high[biqs_b2] = (1.0 - K / (high[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (high[biqs_reso]*0.70710678) + K * K); + high[biqs_c0] = K / (high[biqs_reso]*0.70710678) * norm; + high[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + high[biqs_d2] = (1.0 - K / (high[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (high[biqs_reso]*0.51763809) + K * K); + high[biqs_e0] = K / (high[biqs_reso]*0.51763809) * norm; + high[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + high[biqs_f2] = (1.0 - K / (high[biqs_reso]*0.51763809) + K * K) * norm; + //high + + hmid[biqs_freq] = (((pow(HMF,3)*6400.0)+600.0)/getSampleRate()); + if (hmid[biqs_freq] < 0.0001) hmid[biqs_freq] = 0.0001; + hmid[biqs_nonlin] = HMG; + hmid[biqs_level] = (hmid[biqs_nonlin]*2.0)-1.0; + if (hmid[biqs_level] > 0.0) hmid[biqs_level] *= 2.0; + hmid[biqs_reso] = ((0.5+(hmid[biqs_nonlin]*0.5)+sqrt(hmid[biqs_freq]))-(1.0-pow(1.0-HMR,2.0)))+0.5+(hmid[biqs_nonlin]*0.5); + K = tan(M_PI * hmid[biqs_freq]); + norm = 1.0 / (1.0 + K / (hmid[biqs_reso]*1.93185165) + K * K); + hmid[biqs_a0] = K / (hmid[biqs_reso]*1.93185165) * norm; + hmid[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + hmid[biqs_b2] = (1.0 - K / (hmid[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (hmid[biqs_reso]*0.70710678) + K * K); + hmid[biqs_c0] = K / (hmid[biqs_reso]*0.70710678) * norm; + hmid[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + hmid[biqs_d2] = (1.0 - K / (hmid[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (hmid[biqs_reso]*0.51763809) + K * K); + hmid[biqs_e0] = K / (hmid[biqs_reso]*0.51763809) * norm; + hmid[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + hmid[biqs_f2] = (1.0 - K / (hmid[biqs_reso]*0.51763809) + K * K) * norm; + //hmid + + lmid[biqs_freq] = (((pow(LMF,3)*2200.0)+200.0)/getSampleRate()); + if (lmid[biqs_freq] < 0.0001) lmid[biqs_freq] = 0.0001; + lmid[biqs_nonlin] = LMG; + lmid[biqs_level] = (lmid[biqs_nonlin]*2.0)-1.0; + if (lmid[biqs_level] > 0.0) lmid[biqs_level] *= 2.0; + lmid[biqs_reso] = ((0.5+(lmid[biqs_nonlin]*0.5)+sqrt(lmid[biqs_freq]))-(1.0-pow(1.0-LMR,2.0)))+0.5+(lmid[biqs_nonlin]*0.5); + K = tan(M_PI * lmid[biqs_freq]); + norm = 1.0 / (1.0 + K / (lmid[biqs_reso]*1.93185165) + K * K); + lmid[biqs_a0] = K / (lmid[biqs_reso]*1.93185165) * norm; + lmid[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + lmid[biqs_b2] = (1.0 - K / (lmid[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (lmid[biqs_reso]*0.70710678) + K * K); + lmid[biqs_c0] = K / (lmid[biqs_reso]*0.70710678) * norm; + lmid[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + lmid[biqs_d2] = (1.0 - K / (lmid[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (lmid[biqs_reso]*0.51763809) + K * K); + lmid[biqs_e0] = K / (lmid[biqs_reso]*0.51763809) * norm; + lmid[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + lmid[biqs_f2] = (1.0 - K / (lmid[biqs_reso]*0.51763809) + K * K) * norm; + //lmid + + bass[biqs_freq] = (((pow(BSF,3)*570.0)+30.0)/getSampleRate()); + if (bass[biqs_freq] < 0.0001) bass[biqs_freq] = 0.0001; + bass[biqs_nonlin] = BSG; + bass[biqs_level] = (bass[biqs_nonlin]*2.0)-1.0; + if (bass[biqs_level] > 0.0) bass[biqs_level] *= 2.0; + bass[biqs_reso] = ((0.5+(bass[biqs_nonlin]*0.5)+sqrt(bass[biqs_freq]))-(1.0-pow(1.0-BSR,2.0)))+0.5+(bass[biqs_nonlin]*0.5); + K = tan(M_PI * bass[biqs_freq]); + norm = 1.0 / (1.0 + K / (bass[biqs_reso]*1.93185165) + K * K); + bass[biqs_a0] = K / (bass[biqs_reso]*1.93185165) * norm; + bass[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + bass[biqs_b2] = (1.0 - K / (bass[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (bass[biqs_reso]*0.70710678) + K * K); + bass[biqs_c0] = K / (bass[biqs_reso]*0.70710678) * norm; + bass[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + bass[biqs_d2] = (1.0 - K / (bass[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (bass[biqs_reso]*0.51763809) + K * K); + bass[biqs_e0] = K / (bass[biqs_reso]*0.51763809) * norm; + bass[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + bass[biqs_f2] = (1.0 - K / (bass[biqs_reso]*0.51763809) + K * K) * norm; + //bass + + double refdB = (DSC*70.0)+70.0; double topdB = 0.000000075 * pow(10.0,refdB/20.0) * overallscale; - panA = panB; panB = G*1.57079633; - inTrimA = inTrimB; inTrimB = H*2.0; + panA = panB; panB = PAN*1.57079633; + inTrimA = inTrimB; inTrimB = FAD*2.0; while (--sampleFrames >= 0) { @@ -68,59 +235,262 @@ void ConsoleXBuss::processReplacing(float **inputs, float **outputs, VstInt32 sa double inputSampleR = *in2; if (fabs(inputSampleL)<1.18e-23) inputSampleL = fpdL * 1.18e-17; if (fabs(inputSampleR)<1.18e-23) inputSampleR = fpdR * 1.18e-17; - double drySampleL = inputSampleL; - double drySampleR = inputSampleR; - if (biquad[biq_freq] < 0.5) { - double nlBiq = fabs(biquad[biq_a0]*(1.0+(inputSampleL*0.25))); if (nlBiq > 1.0) nlBiq = 1.0; - double tmp = (inputSampleL * nlBiq) + biquad[biq_sL1]; - biquad[biq_sL1] = (inputSampleL * biquad[biq_a1]) - (tmp * biquad[biq_b1]) + biquad[biq_sL2]; - biquad[biq_sL2] = (inputSampleL * nlBiq) - (tmp * biquad[biq_b2]); - inputSampleL = tmp; - nlBiq = fabs(biquad[biq_a0]*(1.0+(inputSampleR*0.25))); if (nlBiq > 1.0) nlBiq = 1.0; - tmp = (inputSampleR * nlBiq) + biquad[biq_sR1]; - biquad[biq_sR1] = (inputSampleR * biquad[biq_a1]) - (tmp * biquad[biq_b1]) + biquad[biq_sR2]; - biquad[biq_sR2] = (inputSampleR * nlBiq) - (tmp * biquad[biq_b2]); - inputSampleR = tmp; - //ultrasonic filter before anything else is done - } + double temp = (double)sampleFrames/inFramesToProcess; + highpass[hilp_a0] = (highpass[hilp_aA0]*temp)+(highpass[hilp_aB0]*(1.0-temp)); + highpass[hilp_a1] = (highpass[hilp_aA1]*temp)+(highpass[hilp_aB1]*(1.0-temp)); + highpass[hilp_b1] = (highpass[hilp_bA1]*temp)+(highpass[hilp_bB1]*(1.0-temp)); + highpass[hilp_b2] = (highpass[hilp_bA2]*temp)+(highpass[hilp_bB2]*(1.0-temp)); + highpass[hilp_c0] = (highpass[hilp_cA0]*temp)+(highpass[hilp_cB0]*(1.0-temp)); + highpass[hilp_c1] = (highpass[hilp_cA1]*temp)+(highpass[hilp_cB1]*(1.0-temp)); + highpass[hilp_d1] = (highpass[hilp_dA1]*temp)+(highpass[hilp_dB1]*(1.0-temp)); + highpass[hilp_d2] = (highpass[hilp_dA2]*temp)+(highpass[hilp_dB2]*(1.0-temp)); + highpass[hilp_e0] = (highpass[hilp_eA0]*temp)+(highpass[hilp_eB0]*(1.0-temp)); + highpass[hilp_e1] = (highpass[hilp_eA1]*temp)+(highpass[hilp_eB1]*(1.0-temp)); + highpass[hilp_f1] = (highpass[hilp_fA1]*temp)+(highpass[hilp_fB1]*(1.0-temp)); + highpass[hilp_f2] = (highpass[hilp_fA2]*temp)+(highpass[hilp_fB2]*(1.0-temp)); + lowpass[hilp_a0] = (lowpass[hilp_aA0]*temp)+(lowpass[hilp_aB0]*(1.0-temp)); + lowpass[hilp_a1] = (lowpass[hilp_aA1]*temp)+(lowpass[hilp_aB1]*(1.0-temp)); + lowpass[hilp_b1] = (lowpass[hilp_bA1]*temp)+(lowpass[hilp_bB1]*(1.0-temp)); + lowpass[hilp_b2] = (lowpass[hilp_bA2]*temp)+(lowpass[hilp_bB2]*(1.0-temp)); + lowpass[hilp_c0] = (lowpass[hilp_cA0]*temp)+(lowpass[hilp_cB0]*(1.0-temp)); + lowpass[hilp_c1] = (lowpass[hilp_cA1]*temp)+(lowpass[hilp_cB1]*(1.0-temp)); + lowpass[hilp_d1] = (lowpass[hilp_dA1]*temp)+(lowpass[hilp_dB1]*(1.0-temp)); + lowpass[hilp_d2] = (lowpass[hilp_dA2]*temp)+(lowpass[hilp_dB2]*(1.0-temp)); + lowpass[hilp_e0] = (lowpass[hilp_eA0]*temp)+(lowpass[hilp_eB0]*(1.0-temp)); + lowpass[hilp_e1] = (lowpass[hilp_eA1]*temp)+(lowpass[hilp_eB1]*(1.0-temp)); + lowpass[hilp_f1] = (lowpass[hilp_fA1]*temp)+(lowpass[hilp_fB1]*(1.0-temp)); + lowpass[hilp_f2] = (lowpass[hilp_fA2]*temp)+(lowpass[hilp_fB2]*(1.0-temp)); + double gainR = (panA*temp)+(panB*(1.0-temp)); + double gainL = 1.57079633-gainR; + gainR = sin(gainR); gainL = sin(gainL); + double gain = (inTrimA*temp)+(inTrimB*(1.0-temp)); + if (gain > 1.0) gain *= gain; + if (gain < 1.0) gain = 1.0-pow(1.0-gain,2); + gain *= 1.527864045000421; + double airGain = (airGainA*temp)+(airGainB*(1.0-temp)); + double fireGain = (fireGainA*temp)+(fireGainB*(1.0-temp)); + double stoneGain = (stoneGainA*temp)+(stoneGainB*(1.0-temp)); + //set up smoothed gain controls + + if (highpassEngage) { //distributed Highpass + highpass[hilp_temp] = (inputSampleL*highpass[hilp_a0])+highpass[hilp_aL1]; + highpass[hilp_aL1] = (inputSampleL*highpass[hilp_a1])-(highpass[hilp_temp]*highpass[hilp_b1])+highpass[hilp_aL2]; + highpass[hilp_aL2] = (inputSampleL*highpass[hilp_a0])-(highpass[hilp_temp]*highpass[hilp_b2]); inputSampleL = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleR*highpass[hilp_a0])+highpass[hilp_aR1]; + highpass[hilp_aR1] = (inputSampleR*highpass[hilp_a1])-(highpass[hilp_temp]*highpass[hilp_b1])+highpass[hilp_aR2]; + highpass[hilp_aR2] = (inputSampleR*highpass[hilp_a0])-(highpass[hilp_temp]*highpass[hilp_b2]); inputSampleR = highpass[hilp_temp]; + } else highpass[hilp_aR1] = highpass[hilp_aR2] = highpass[hilp_aL1] = highpass[hilp_aL2] = 0.0; + if (lowpassEngage) { //distributed Lowpass + lowpass[hilp_temp] = (inputSampleL*lowpass[hilp_a0])+lowpass[hilp_aL1]; + lowpass[hilp_aL1] = (inputSampleL*lowpass[hilp_a1])-(lowpass[hilp_temp]*lowpass[hilp_b1])+lowpass[hilp_aL2]; + lowpass[hilp_aL2] = (inputSampleL*lowpass[hilp_a0])-(lowpass[hilp_temp]*lowpass[hilp_b2]); inputSampleL = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleR*lowpass[hilp_a0])+lowpass[hilp_aR1]; + lowpass[hilp_aR1] = (inputSampleR*lowpass[hilp_a1])-(lowpass[hilp_temp]*lowpass[hilp_b1])+lowpass[hilp_aR2]; + lowpass[hilp_aR2] = (inputSampleR*lowpass[hilp_a0])-(lowpass[hilp_temp]*lowpass[hilp_b2]); inputSampleR = lowpass[hilp_temp]; + } else lowpass[hilp_aR1] = lowpass[hilp_aR2] = lowpass[hilp_aL1] = lowpass[hilp_aL2] = 0.0; + //first Highpass/Lowpass blocks aliasing before the nonlinearity of ConsoleXBuss and Parametric + //ConsoleXBuss after initial Highpass/Lowpass stages if (inputSampleL > 1.0) inputSampleL = 1.0; else if (inputSampleL > 0.0) inputSampleL = -expm1((log1p(-inputSampleL) * 0.6180339887498949)); if (inputSampleL < -1.0) inputSampleL = -1.0; else if (inputSampleL < 0.0) inputSampleL = expm1((log1p(inputSampleL) * 0.6180339887498949)); inputSampleL *= 1.6180339887498949; - if (inputSampleR > 1.0) inputSampleR = 1.0; else if (inputSampleR > 0.0) inputSampleR = -expm1((log1p(-inputSampleR) * 0.6180339887498949)); if (inputSampleR < -1.0) inputSampleR = -1.0; else if (inputSampleR < 0.0) inputSampleR = expm1((log1p(inputSampleR) * 0.6180339887498949)); inputSampleR *= 1.6180339887498949; + //ConsoleXBuss after initial Highpass/Lowpass stages - double temp = (double)sampleFrames/inFramesToProcess; - double trebleGain = (trebleGainA*temp)+(trebleGainB*(1.0-temp)); - if (trebleGain > 1.0) trebleGain = pow(trebleGain,3.0+sqrt(overallscale)); - if (trebleGain < 1.0) trebleGain = 1.0-pow(1.0-trebleGain,2); + //get all Parametric bands before any other processing is done + //begin Stacked Biquad With Reversed Neutron Flow L + high[biqs_outL] = inputSampleL * fabs(high[biqs_level]); + high[biqs_dis] = fabs(high[biqs_a0] * (1.0+(high[biqs_outL]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outL] * high[biqs_dis]) + high[biqs_aL1]; + high[biqs_aL1] = high[biqs_aL2] - (high[biqs_temp]*high[biqs_b1]); + high[biqs_aL2] = (high[biqs_outL] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_b2]); + high[biqs_outL] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_c0] * (1.0+(high[biqs_outL]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outL] * high[biqs_dis]) + high[biqs_cL1]; + high[biqs_cL1] = high[biqs_cL2] - (high[biqs_temp]*high[biqs_d1]); + high[biqs_cL2] = (high[biqs_outL] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_d2]); + high[biqs_outL] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_e0] * (1.0+(high[biqs_outL]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outL] * high[biqs_dis]) + high[biqs_eL1]; + high[biqs_eL1] = high[biqs_eL2] - (high[biqs_temp]*high[biqs_f1]); + high[biqs_eL2] = (high[biqs_outL] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_f2]); + high[biqs_outL] = high[biqs_temp]; high[biqs_outL] *= high[biqs_level]; + if (high[biqs_level] > 1.0) high[biqs_outL] *= high[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L - double midGain = (midGainA*temp)+(midGainB*(1.0-temp)); - if (midGain > 1.0) midGain = 1.0; - if (midGain < 1.0) midGain = 1.0-pow(1.0-midGain,2); - double mPeak = pow((mPeakA*temp)+(mPeakB*(1.0-temp)),2); + //begin Stacked Biquad With Reversed Neutron Flow L + hmid[biqs_outL] = inputSampleL * fabs(hmid[biqs_level]); + hmid[biqs_dis] = fabs(hmid[biqs_a0] * (1.0+(hmid[biqs_outL]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outL] * hmid[biqs_dis]) + hmid[biqs_aL1]; + hmid[biqs_aL1] = hmid[biqs_aL2] - (hmid[biqs_temp]*hmid[biqs_b1]); + hmid[biqs_aL2] = (hmid[biqs_outL] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_b2]); + hmid[biqs_outL] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_c0] * (1.0+(hmid[biqs_outL]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outL] * hmid[biqs_dis]) + hmid[biqs_cL1]; + hmid[biqs_cL1] = hmid[biqs_cL2] - (hmid[biqs_temp]*hmid[biqs_d1]); + hmid[biqs_cL2] = (hmid[biqs_outL] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_d2]); + hmid[biqs_outL] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_e0] * (1.0+(hmid[biqs_outL]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outL] * hmid[biqs_dis]) + hmid[biqs_eL1]; + hmid[biqs_eL1] = hmid[biqs_eL2] - (hmid[biqs_temp]*hmid[biqs_f1]); + hmid[biqs_eL2] = (hmid[biqs_outL] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_f2]); + hmid[biqs_outL] = hmid[biqs_temp]; hmid[biqs_outL] *= hmid[biqs_level]; + if (hmid[biqs_level] > 1.0) hmid[biqs_outL] *= hmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L - double bassGain = (bassGainA*temp)+(bassGainB*(1.0-temp)); - if (bassGain > 1.0) bassGain *= bassGain; - if (bassGain < 1.0) bassGain = 1.0-pow(1.0-bassGain,2); + //begin Stacked Biquad With Reversed Neutron Flow L + lmid[biqs_outL] = inputSampleL * fabs(lmid[biqs_level]); + lmid[biqs_dis] = fabs(lmid[biqs_a0] * (1.0+(lmid[biqs_outL]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outL] * lmid[biqs_dis]) + lmid[biqs_aL1]; + lmid[biqs_aL1] = lmid[biqs_aL2] - (lmid[biqs_temp]*lmid[biqs_b1]); + lmid[biqs_aL2] = (lmid[biqs_outL] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_b2]); + lmid[biqs_outL] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_c0] * (1.0+(lmid[biqs_outL]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outL] * lmid[biqs_dis]) + lmid[biqs_cL1]; + lmid[biqs_cL1] = lmid[biqs_cL2] - (lmid[biqs_temp]*lmid[biqs_d1]); + lmid[biqs_cL2] = (lmid[biqs_outL] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_d2]); + lmid[biqs_outL] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_e0] * (1.0+(lmid[biqs_outL]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outL] * lmid[biqs_dis]) + lmid[biqs_eL1]; + lmid[biqs_eL1] = lmid[biqs_eL2] - (lmid[biqs_temp]*lmid[biqs_f1]); + lmid[biqs_eL2] = (lmid[biqs_outL] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_f2]); + lmid[biqs_outL] = lmid[biqs_temp]; lmid[biqs_outL] *= lmid[biqs_level]; + if (lmid[biqs_level] > 1.0) lmid[biqs_outL] *= lmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L - double gainR = (panA*temp)+(panB*(1.0-temp)); - double gainL = 1.57079633-gainR; - gainR = sin(gainR); gainL = sin(gainL); + //begin Stacked Biquad With Reversed Neutron Flow L + bass[biqs_outL] = inputSampleL * fabs(bass[biqs_level]); + bass[biqs_dis] = fabs(bass[biqs_a0] * (1.0+(bass[biqs_outL]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outL] * bass[biqs_dis]) + bass[biqs_aL1]; + bass[biqs_aL1] = bass[biqs_aL2] - (bass[biqs_temp]*bass[biqs_b1]); + bass[biqs_aL2] = (bass[biqs_outL] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_b2]); + bass[biqs_outL] = bass[biqs_temp]; + bass[biqs_dis] = fabs(bass[biqs_c0] * (1.0+(bass[biqs_outL]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outL] * bass[biqs_dis]) + bass[biqs_cL1]; + bass[biqs_cL1] = bass[biqs_cL2] - (bass[biqs_temp]*bass[biqs_d1]); + bass[biqs_cL2] = (bass[biqs_outL] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_d2]); + bass[biqs_outL] = bass[biqs_temp]; + bass[biqs_dis] = fabs(bass[biqs_e0] * (1.0+(bass[biqs_outL]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outL] * bass[biqs_dis]) + bass[biqs_eL1]; + bass[biqs_eL1] = bass[biqs_eL2] - (bass[biqs_temp]*bass[biqs_f1]); + bass[biqs_eL2] = (bass[biqs_outL] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_f2]); + bass[biqs_outL] = bass[biqs_temp]; bass[biqs_outL] *= bass[biqs_level]; + if (bass[biqs_level] > 1.0) bass[biqs_outL] *= bass[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L - double gain = (inTrimA*temp)+(inTrimB*(1.0-temp)); - if (gain > 1.0) gain *= gain; - if (gain < 1.0) gain = 1.0-pow(1.0-gain,2); - gain *= 1.527864045000421; + //begin Stacked Biquad With Reversed Neutron Flow R + high[biqs_outR] = inputSampleR * fabs(high[biqs_level]); + high[biqs_dis] = fabs(high[biqs_a0] * (1.0+(high[biqs_outR]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outR] * high[biqs_dis]) + high[biqs_aR1]; + high[biqs_aR1] = high[biqs_aR2] - (high[biqs_temp]*high[biqs_b1]); + high[biqs_aR2] = (high[biqs_outR] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_b2]); + high[biqs_outR] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_c0] * (1.0+(high[biqs_outR]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outR] * high[biqs_dis]) + high[biqs_cR1]; + high[biqs_cR1] = high[biqs_cR2] - (high[biqs_temp]*high[biqs_d1]); + high[biqs_cR2] = (high[biqs_outR] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_d2]); + high[biqs_outR] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_e0] * (1.0+(high[biqs_outR]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outR] * high[biqs_dis]) + high[biqs_eR1]; + high[biqs_eR1] = high[biqs_eR2] - (high[biqs_temp]*high[biqs_f1]); + high[biqs_eR2] = (high[biqs_outR] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_f2]); + high[biqs_outR] = high[biqs_temp]; high[biqs_outR] *= high[biqs_level]; + if (high[biqs_level] > 1.0) high[biqs_outR] *= high[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R + + //begin Stacked Biquad With Reversed Neutron Flow R + hmid[biqs_outR] = inputSampleR * fabs(hmid[biqs_level]); + hmid[biqs_dis] = fabs(hmid[biqs_a0] * (1.0+(hmid[biqs_outR]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outR] * hmid[biqs_dis]) + hmid[biqs_aR1]; + hmid[biqs_aR1] = hmid[biqs_aR2] - (hmid[biqs_temp]*hmid[biqs_b1]); + hmid[biqs_aR2] = (hmid[biqs_outR] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_b2]); + hmid[biqs_outR] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_c0] * (1.0+(hmid[biqs_outR]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outR] * hmid[biqs_dis]) + hmid[biqs_cR1]; + hmid[biqs_cR1] = hmid[biqs_cR2] - (hmid[biqs_temp]*hmid[biqs_d1]); + hmid[biqs_cR2] = (hmid[biqs_outR] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_d2]); + hmid[biqs_outR] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_e0] * (1.0+(hmid[biqs_outR]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outR] * hmid[biqs_dis]) + hmid[biqs_eR1]; + hmid[biqs_eR1] = hmid[biqs_eR2] - (hmid[biqs_temp]*hmid[biqs_f1]); + hmid[biqs_eR2] = (hmid[biqs_outR] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_f2]); + hmid[biqs_outR] = hmid[biqs_temp]; hmid[biqs_outR] *= hmid[biqs_level]; + if (hmid[biqs_level] > 1.0) hmid[biqs_outR] *= hmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R + + //begin Stacked Biquad With Reversed Neutron Flow R + lmid[biqs_outR] = inputSampleR * fabs(lmid[biqs_level]); + lmid[biqs_dis] = fabs(lmid[biqs_a0] * (1.0+(lmid[biqs_outR]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outR] * lmid[biqs_dis]) + lmid[biqs_aR1]; + lmid[biqs_aR1] = lmid[biqs_aR2] - (lmid[biqs_temp]*lmid[biqs_b1]); + lmid[biqs_aR2] = (lmid[biqs_outR] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_b2]); + lmid[biqs_outR] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_c0] * (1.0+(lmid[biqs_outR]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outR] * lmid[biqs_dis]) + lmid[biqs_cR1]; + lmid[biqs_cR1] = lmid[biqs_cR2] - (lmid[biqs_temp]*lmid[biqs_d1]); + lmid[biqs_cR2] = (lmid[biqs_outR] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_d2]); + lmid[biqs_outR] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_e0] * (1.0+(lmid[biqs_outR]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outR] * lmid[biqs_dis]) + lmid[biqs_eR1]; + lmid[biqs_eR1] = lmid[biqs_eR2] - (lmid[biqs_temp]*lmid[biqs_f1]); + lmid[biqs_eR2] = (lmid[biqs_outR] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_f2]); + lmid[biqs_outR] = lmid[biqs_temp]; lmid[biqs_outR] *= lmid[biqs_level]; + if (lmid[biqs_level] > 1.0) lmid[biqs_outR] *= lmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R + + //begin Stacked Biquad With Reversed Neutron Flow R + bass[biqs_outR] = inputSampleR * fabs(bass[biqs_level]); + bass[biqs_dis] = fabs(bass[biqs_a0] * (1.0+(bass[biqs_outR]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outR] * bass[biqs_dis]) + bass[biqs_aR1]; + bass[biqs_aR1] = bass[biqs_aR2] - (bass[biqs_temp]*bass[biqs_b1]); + bass[biqs_aR2] = (bass[biqs_outR] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_b2]); + bass[biqs_outR] = bass[biqs_temp]; + bass[biqs_dis] = fabs(bass[biqs_c0] * (1.0+(bass[biqs_outR]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outR] * bass[biqs_dis]) + bass[biqs_cR1]; + bass[biqs_cR1] = bass[biqs_cR2] - (bass[biqs_temp]*bass[biqs_d1]); + bass[biqs_cR2] = (bass[biqs_outR] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_d2]); + bass[biqs_outR] = bass[biqs_temp]; + bass[biqs_dis] = fabs(bass[biqs_e0] * (1.0+(bass[biqs_outR]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outR] * bass[biqs_dis]) + bass[biqs_eR1]; + bass[biqs_eR1] = bass[biqs_eR2] - (bass[biqs_temp]*bass[biqs_f1]); + bass[biqs_eR2] = (bass[biqs_outR] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_f2]); + bass[biqs_outR] = bass[biqs_temp]; bass[biqs_outR] *= bass[biqs_level]; + if (bass[biqs_level] > 1.0) bass[biqs_outR] *= bass[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R //begin Air3L + double drySampleL = inputSampleL; air[pvSL4] = air[pvAL4] - air[pvAL3]; air[pvSL3] = air[pvAL3] - air[pvAL2]; air[pvSL2] = air[pvAL2] - air[pvAL1]; air[pvSL1] = air[pvAL1] - inputSampleL; air[accSL3] = air[pvSL4] - air[pvSL3]; air[accSL2] = air[pvSL3] - air[pvSL2]; @@ -131,13 +501,13 @@ void ConsoleXBuss::processReplacing(float **inputs, float **outputs, VstInt32 sa if (air[gainAL] > 0.3*sqrt(overallscale)) air[gainAL] = 0.3*sqrt(overallscale); air[pvAL4] = air[pvAL3]; air[pvAL3] = air[pvAL2]; air[pvAL2] = air[pvAL1]; air[pvAL1] = (air[gainAL] * air[outAL]) + drySampleL; - double midL = drySampleL - ((air[outAL]*0.5)+(drySampleL*(0.457-(0.017*overallscale)))); - temp = (midL + air[gndavgL])*0.5; air[gndavgL] = midL; midL = temp; - double trebleL = drySampleL-midL; - inputSampleL = midL; + double fireL = drySampleL - ((air[outAL]*0.5)+(drySampleL*(0.457-(0.017*overallscale)))); + temp = (fireL + air[gndavgL])*0.5; air[gndavgL] = fireL; fireL = temp; + double airL = drySampleL-fireL; + inputSampleL = fireL; //end Air3L - //begin Air3R + double drySampleR = inputSampleR; air[pvSR4] = air[pvAR4] - air[pvAR3]; air[pvSR3] = air[pvAR3] - air[pvAR2]; air[pvSR2] = air[pvAR2] - air[pvAR1]; air[pvSR1] = air[pvAR1] - inputSampleR; air[accSR3] = air[pvSR4] - air[pvSR3]; air[accSR2] = air[pvSR3] - air[pvSR2]; @@ -148,15 +518,14 @@ void ConsoleXBuss::processReplacing(float **inputs, float **outputs, VstInt32 sa if (air[gainAR] > 0.3*sqrt(overallscale)) air[gainAR] = 0.3*sqrt(overallscale); air[pvAR4] = air[pvAR3]; air[pvAR3] = air[pvAR2]; air[pvAR2] = air[pvAR1]; air[pvAR1] = (air[gainAR] * air[outAR]) + drySampleR; - double midR = drySampleR - ((air[outAR]*0.5)+(drySampleR*(0.457-(0.017*overallscale)))); - temp = (midR + air[gndavgR])*0.5; air[gndavgR] = midR; midR = temp; - double trebleR = drySampleR-midR; - inputSampleR = midR; + double fireR = drySampleR - ((air[outAR]*0.5)+(drySampleR*(0.457-(0.017*overallscale)))); + temp = (fireR + air[gndavgR])*0.5; air[gndavgR] = fireR; fireR = temp; + double airR = drySampleR-fireR; + inputSampleR = fireR; //end Air3R - //begin KalmanL - temp = inputSampleL = inputSampleL*(1.0-kalman)*0.777; - inputSampleL *= (1.0-kalman); + temp = inputSampleL = inputSampleL*(1.0-kalmanRange)*0.777; + inputSampleL *= (1.0-kalmanRange); //set up gain levels to control the beast kal[prevSlewL3] += kal[prevSampL3] - kal[prevSampL2]; kal[prevSlewL3] *= 0.5; kal[prevSlewL2] += kal[prevSampL2] - kal[prevSampL1]; kal[prevSlewL2] *= 0.5; @@ -169,23 +538,22 @@ void ConsoleXBuss::processReplacing(float **inputs, float **outputs, VstInt32 sa //entering the abyss, what even is this kal[kalOutL] += kal[prevSampL1] + kal[prevSlewL2] + kal[accSlewL3]; kal[kalOutL] *= 0.5; //resynthesizing predicted result (all iir smoothed) - kal[kalGainL] += fabs(temp-kal[kalOutL])*kalman*8.0; kal[kalGainL] *= 0.5; + kal[kalGainL] += fabs(temp-kal[kalOutL])*kalmanRange*8.0; kal[kalGainL] *= 0.5; //madness takes its toll. Kalman Gain: how much dry to retain - if (kal[kalGainL] > kalman*0.5) kal[kalGainL] = kalman*0.5; + if (kal[kalGainL] > kalmanRange*0.5) kal[kalGainL] = kalmanRange*0.5; //attempts to avoid explosions - kal[kalOutL] += (temp*(1.0-(0.68+(kalman*0.157)))); + kal[kalOutL] += (temp*(1.0-(0.68+(kalmanRange*0.157)))); //this is for tuning a really complete cancellation up around Nyquist kal[prevSampL3] = kal[prevSampL2]; kal[prevSampL2] = kal[prevSampL1]; kal[prevSampL1] = (kal[kalGainL] * kal[kalOutL]) + ((1.0-kal[kalGainL])*temp); //feed the chain of previous samples if (kal[prevSampL1] > 1.0) kal[prevSampL1] = 1.0; if (kal[prevSampL1] < -1.0) kal[prevSampL1] = -1.0; - double bassL = kal[kalOutL]*0.777; - midL -= bassL; + double stoneL = kal[kalOutL]*0.777; + fireL -= stoneL; //end KalmanL - //begin KalmanR - temp = inputSampleR = inputSampleR*(1.0-kalman)*0.777; - inputSampleR *= (1.0-kalman); + temp = inputSampleR = inputSampleR*(1.0-kalmanRange)*0.777; + inputSampleR *= (1.0-kalmanRange); //set up gain levels to control the beast kal[prevSlewR3] += kal[prevSampR3] - kal[prevSampR2]; kal[prevSlewR3] *= 0.5; kal[prevSlewR2] += kal[prevSampR2] - kal[prevSampR1]; kal[prevSlewR2] *= 0.5; @@ -198,60 +566,106 @@ void ConsoleXBuss::processReplacing(float **inputs, float **outputs, VstInt32 sa //entering the abyss, what even is this kal[kalOutR] += kal[prevSampR1] + kal[prevSlewR2] + kal[accSlewR3]; kal[kalOutR] *= 0.5; //resynthesizing predicted result (all iir smoothed) - kal[kalGainR] += fabs(temp-kal[kalOutR])*kalman*8.0; kal[kalGainR] *= 0.5; + kal[kalGainR] += fabs(temp-kal[kalOutR])*kalmanRange*8.0; kal[kalGainR] *= 0.5; //madness takes its toll. Kalman Gain: how much dry to retain - if (kal[kalGainR] > kalman*0.5) kal[kalGainR] = kalman*0.5; + if (kal[kalGainR] > kalmanRange*0.5) kal[kalGainR] = kalmanRange*0.5; //attempts to avoid explosions - kal[kalOutR] += (temp*(1.0-(0.68+(kalman*0.157)))); + kal[kalOutR] += (temp*(1.0-(0.68+(kalmanRange*0.157)))); //this is for tuning a really complete cancellation up around Nyquist kal[prevSampR3] = kal[prevSampR2]; kal[prevSampR2] = kal[prevSampR1]; kal[prevSampR1] = (kal[kalGainR] * kal[kalOutR]) + ((1.0-kal[kalGainR])*temp); //feed the chain of previous samples if (kal[prevSampR1] > 1.0) kal[prevSampR1] = 1.0; if (kal[prevSampR1] < -1.0) kal[prevSampR1] = -1.0; - double bassR = kal[kalOutR]*0.777; - midR -= bassR; + double stoneR = kal[kalOutR]*0.777; + fireR -= stoneR; //end KalmanR + //fire dynamics + if (fabs(fireL) > compFThresh) { //compression L + fireCompL -= (fireCompL * compFAttack); + fireCompL += ((compFThresh / fabs(fireL))*compFAttack); + } else fireCompL = (fireCompL*(1.0-compFRelease))+compFRelease; + if (fireCompL < 0.0) fireCompL = 0.0; + if (fabs(fireR) > compFThresh) { //compression R + fireCompR -= (fireCompR * compFAttack); + fireCompR += ((compFThresh / fabs(fireR))*compFAttack); + } else fireCompR = (fireCompR*(1.0-compFRelease))+compFRelease; + if (fireCompR < 0.0) fireCompR = 0.0; + if (fireCompL > fireCompR) fireCompL -= (fireCompL * compFAttack); + if (fireCompR > fireCompL) fireCompR -= (fireCompR * compFAttack); + if (fabs(fireL) > gateFThresh) fireGate = gateFSustain; + else if (fabs(fireR) > gateFThresh) fireGate = gateFSustain; + else fireGate *= (1.0-gateFRelease); + if (fireGate < 0.0) fireGate = 0.0; + if (fireCompL < 1.0) fireL *= ((1.0-compFRatio)+(fireCompL*compFRatio)); + if (fireCompR < 1.0) fireR *= ((1.0-compFRatio)+(fireCompR*compFRatio)); + if (fireGate < M_PI_2) { + temp = ((1.0-gateFRatio)+(sin(fireGate)*gateFRatio)); + airL *= temp; + airR *= temp; + fireL *= temp; + fireR *= temp; + high[biqs_outL] *= temp; + high[biqs_outR] *= temp; + hmid[biqs_outL] *= temp; //if Fire gating, gate Air, high and hmid + hmid[biqs_outR] *= temp; //note that we aren't compressing these + } + //stone dynamics + if (fabs(stoneL) > compSThresh) { //compression L + stoneCompL -= (stoneCompL * compSAttack); + stoneCompL += ((compSThresh / fabs(stoneL))*compSAttack); + } else stoneCompL = (stoneCompL*(1.0-compSRelease))+compSRelease; + if (stoneCompL < 0.0) stoneCompL = 0.0; + if (fabs(stoneR) > compSThresh) { //compression R + stoneCompR -= (stoneCompR * compSAttack); + stoneCompR += ((compSThresh / fabs(stoneR))*compSAttack); + } else stoneCompR = (stoneCompR*(1.0-compSRelease))+compSRelease; + if (stoneCompR < 0.0) stoneCompR = 0.0; + if (stoneCompL > stoneCompR) stoneCompL -= (stoneCompL * compSAttack); + if (stoneCompR > stoneCompL) stoneCompR -= (stoneCompR * compSAttack); + if (fabs(stoneL) > gateSThresh) stoneGate = gateSSustain; + else if (fabs(stoneR) > gateSThresh) stoneGate = gateSSustain; + else stoneGate *= (1.0-gateSRelease); + if (stoneGate < 0.0) stoneGate = 0.0; + if (stoneCompL < 1.0) stoneL *= ((1.0-compSRatio)+(stoneCompL*compSRatio)); + if (stoneCompR < 1.0) stoneR *= ((1.0-compSRatio)+(stoneCompR*compSRatio)); + if (stoneGate < M_PI_2) { + temp = ((1.0-gateSRatio)+(sin(stoneGate)*gateSRatio)); + stoneL *= temp; + stoneR *= temp; + lmid[biqs_outL] *= temp; + lmid[biqs_outR] *= temp; + bass[biqs_outL] *= temp; //if Stone gating, gate lmid and bass + bass[biqs_outR] *= temp; //note that we aren't compressing these + } + inputSampleL = (stoneL*stoneGain) + (fireL*fireGain) + (airL*airGain); + inputSampleR = (stoneR*stoneGain) + (fireR*fireGain) + (airR*airGain); + //create Stonefire output + + if (highpassEngage) { //distributed Highpass + highpass[hilp_temp] = (inputSampleL*highpass[hilp_c0])+highpass[hilp_cL1]; + highpass[hilp_cL1] = (inputSampleL*highpass[hilp_c1])-(highpass[hilp_temp]*highpass[hilp_d1])+highpass[hilp_cL2]; + highpass[hilp_cL2] = (inputSampleL*highpass[hilp_c0])-(highpass[hilp_temp]*highpass[hilp_d2]); inputSampleL = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleR*highpass[hilp_c0])+highpass[hilp_cR1]; + highpass[hilp_cR1] = (inputSampleR*highpass[hilp_c1])-(highpass[hilp_temp]*highpass[hilp_d1])+highpass[hilp_cR2]; + highpass[hilp_cR2] = (inputSampleR*highpass[hilp_c0])-(highpass[hilp_temp]*highpass[hilp_d2]); inputSampleR = highpass[hilp_temp]; + } else highpass[hilp_cR1] = highpass[hilp_cR2] = highpass[hilp_cL1] = highpass[hilp_cL2] = 0.0; + if (lowpassEngage) { //distributed Lowpass + lowpass[hilp_temp] = (inputSampleL*lowpass[hilp_c0])+lowpass[hilp_cL1]; + lowpass[hilp_cL1] = (inputSampleL*lowpass[hilp_c1])-(lowpass[hilp_temp]*lowpass[hilp_d1])+lowpass[hilp_cL2]; + lowpass[hilp_cL2] = (inputSampleL*lowpass[hilp_c0])-(lowpass[hilp_temp]*lowpass[hilp_d2]); inputSampleL = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleR*lowpass[hilp_c0])+lowpass[hilp_cR1]; + lowpass[hilp_cR1] = (inputSampleR*lowpass[hilp_c1])-(lowpass[hilp_temp]*lowpass[hilp_d1])+lowpass[hilp_cR2]; + lowpass[hilp_cR2] = (inputSampleR*lowpass[hilp_c0])-(lowpass[hilp_temp]*lowpass[hilp_d2]); inputSampleR = lowpass[hilp_temp]; + } else lowpass[hilp_cR1] = lowpass[hilp_cR2] = lowpass[hilp_cL1] = lowpass[hilp_cL2] = 0.0; + //another stage of Highpass/Lowpass before bringing in the parametric bands + + inputSampleL += (high[biqs_outL] + hmid[biqs_outL] + lmid[biqs_outL] + bass[biqs_outL]); + inputSampleR += (high[biqs_outR] + hmid[biqs_outR] + lmid[biqs_outR] + bass[biqs_outR]); + //add parametric boosts or cuts: clean as possible for maximal rawness and sonority - //begin ResEQ2 Mid Boost - mpc++; if (mpc < 1 || mpc > 2001) mpc = 1; - mpkL[mpc] = midL; - mpkR[mpc] = midR; - double midPeakL = 0.0; - double midPeakR = 0.0; - for (int x = 0; x < maxMPeak; x++) { - int y = x*cycleEnd; - switch (cycleEnd) - { - case 1: - midPeakL += (mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x]); - midPeakR += (mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x]); break; - case 2: - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.5); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.5); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.5); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.5); break; - case 3: - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); break; - case 4: - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); //break - } - }//end ResEQ2 Mid Boost creating - - inputSampleL = ((bassL*bassGain) + (midL*midGain) + (midPeakL*mPeak) + (trebleL*trebleGain)) * gainL; - inputSampleR = ((bassR*bassGain) + (midR*midGain) + (midPeakR*mPeak) + (trebleR*trebleGain)) * gainR; - //applies BitShiftPan pan section, and smoothed fader gain + inputSampleL = inputSampleL * gainL * gain; + inputSampleR = inputSampleR * gainR * gain; + //applies pan section, and smoothed fader gain inputSampleL *= topdB; if (inputSampleL < -0.222) inputSampleL = -0.222; if (inputSampleL > 0.222) inputSampleL = 0.222; @@ -273,8 +687,24 @@ void ConsoleXBuss::processReplacing(float **inputs, float **outputs, VstInt32 sa inputSampleR /= topdB; //top dB processing for distributed discontinuity modeling air nonlinearity - inputSampleL *= gain; - inputSampleR *= gain; + if (highpassEngage) { //distributed Highpass + highpass[hilp_temp] = (inputSampleL*highpass[hilp_e0])+highpass[hilp_eL1]; + highpass[hilp_eL1] = (inputSampleL*highpass[hilp_e1])-(highpass[hilp_temp]*highpass[hilp_f1])+highpass[hilp_eL2]; + highpass[hilp_eL2] = (inputSampleL*highpass[hilp_e0])-(highpass[hilp_temp]*highpass[hilp_f2]); inputSampleL = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleR*highpass[hilp_e0])+highpass[hilp_eR1]; + highpass[hilp_eR1] = (inputSampleR*highpass[hilp_e1])-(highpass[hilp_temp]*highpass[hilp_f1])+highpass[hilp_eR2]; + highpass[hilp_eR2] = (inputSampleR*highpass[hilp_e0])-(highpass[hilp_temp]*highpass[hilp_f2]); inputSampleR = highpass[hilp_temp]; + } else highpass[hilp_eR1] = highpass[hilp_eR2] = highpass[hilp_eL1] = highpass[hilp_eL2] = 0.0; + if (lowpassEngage) { //distributed Lowpass + lowpass[hilp_temp] = (inputSampleL*lowpass[hilp_e0])+lowpass[hilp_eL1]; + lowpass[hilp_eL1] = (inputSampleL*lowpass[hilp_e1])-(lowpass[hilp_temp]*lowpass[hilp_f1])+lowpass[hilp_eL2]; + lowpass[hilp_eL2] = (inputSampleL*lowpass[hilp_e0])-(lowpass[hilp_temp]*lowpass[hilp_f2]); inputSampleL = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleR*lowpass[hilp_e0])+lowpass[hilp_eR1]; + lowpass[hilp_eR1] = (inputSampleR*lowpass[hilp_e1])-(lowpass[hilp_temp]*lowpass[hilp_f1])+lowpass[hilp_eR2]; + lowpass[hilp_eR2] = (inputSampleR*lowpass[hilp_e0])-(lowpass[hilp_temp]*lowpass[hilp_f2]); inputSampleR = lowpass[hilp_temp]; + } else lowpass[hilp_eR1] = lowpass[hilp_eR2] = lowpass[hilp_eL1] = lowpass[hilp_eL2] = 0.0; + //final Highpass/Lowpass continues to address aliasing + //final stacked biquad section is the softest Q for smoothness //begin 32 bit stereo floating point dither int expon; frexpf((float)inputSampleL, &expon); @@ -306,48 +736,215 @@ void ConsoleXBuss::processDoubleReplacing(double **inputs, double **outputs, Vst double overallscale = 1.0; overallscale /= 44100.0; overallscale *= getSampleRate(); - int cycleEnd = floor(overallscale); - if (cycleEnd < 1) cycleEnd = 1; - if (cycleEnd > 3) cycleEnd = 3; - biquad[biq_freq] = 25000.0/getSampleRate(); - biquad[biq_reso] = 2.56291545; - double K = tan(M_PI * biquad[biq_freq]); - double norm = 1.0 / (1.0 + K / biquad[biq_reso] + K * K); - biquad[biq_a0] = K * K * norm; - biquad[biq_a1] = 2.0 * biquad[biq_a0]; - biquad[biq_a2] = biquad[biq_a0]; - biquad[biq_b1] = 2.0 * (K * K - 1.0) * norm; - biquad[biq_b2] = (1.0 - K / biquad[biq_reso] + K * K) * norm; - //ultrasonic nonlinear filter + highpass[hilp_freq] = ((pow(HIP,3)*24000.0)+10.0)/getSampleRate(); + if (highpass[hilp_freq] > 0.495) highpass[hilp_freq] = 0.495; + bool highpassEngage = true; if (HIP == 0.0) highpassEngage = false; - trebleGainA = trebleGainB; trebleGainB = A*2.0; - midGainA = midGainB; midGainB = B*2.0; - bassGainA = bassGainB; bassGainB = C*2.0; - //simple three band to adjust + lowpass[hilp_freq] = ((pow(1.0-LOP,3)*24000.0)+10.0)/getSampleRate(); + if (lowpass[hilp_freq] > 0.495) lowpass[hilp_freq] = 0.495; + bool lowpassEngage = true; if (LOP == 0.0) lowpassEngage = false; - //begin ResEQ2 Mid Boost - double freqMPeak = pow(D+0.16,3); - mPeakA = mPeakB; mPeakB = fabs(midGainB-1.0); //amount of mid peak leak through (or boost) - if (midGainB < 1.0) mPeakB *= 0.5; - int maxMPeak = (24.0*(2.0-freqMPeak))+16; - if ((freqMPeak != prevfreqMPeak)||(mPeakB != prevamountMPeak)) { - for (int x = 0; x < maxMPeak; x++) { - if (((double)x*freqMPeak) < M_PI_4) f[x] = sin(((double)x*freqMPeak)*4.0)*freqMPeak*sin(((double)(maxMPeak-x)/(double)maxMPeak)*M_PI_2); - else f[x] = cos((double)x*freqMPeak)*freqMPeak*sin(((double)(maxMPeak-x)/(double)maxMPeak)*M_PI_2); - } - prevfreqMPeak = freqMPeak; prevamountMPeak = mPeakB; - }//end ResEQ2 Mid Boost - //mid peak for either retaining during mid cut, or adding during mid boost + highpass[hilp_aA0] = highpass[hilp_aB0]; + highpass[hilp_aA1] = highpass[hilp_aB1]; + highpass[hilp_bA1] = highpass[hilp_bB1]; + highpass[hilp_bA2] = highpass[hilp_bB2]; + highpass[hilp_cA0] = highpass[hilp_cB0]; + highpass[hilp_cA1] = highpass[hilp_cB1]; + highpass[hilp_dA1] = highpass[hilp_dB1]; + highpass[hilp_dA2] = highpass[hilp_dB2]; + highpass[hilp_eA0] = highpass[hilp_eB0]; + highpass[hilp_eA1] = highpass[hilp_eB1]; + highpass[hilp_fA1] = highpass[hilp_fB1]; + highpass[hilp_fA2] = highpass[hilp_fB2]; + lowpass[hilp_aA0] = lowpass[hilp_aB0]; + lowpass[hilp_aA1] = lowpass[hilp_aB1]; + lowpass[hilp_bA1] = lowpass[hilp_bB1]; + lowpass[hilp_bA2] = lowpass[hilp_bB2]; + lowpass[hilp_cA0] = lowpass[hilp_cB0]; + lowpass[hilp_cA1] = lowpass[hilp_cB1]; + lowpass[hilp_dA1] = lowpass[hilp_dB1]; + lowpass[hilp_dA2] = lowpass[hilp_dB2]; + lowpass[hilp_eA0] = lowpass[hilp_eB0]; + lowpass[hilp_eA1] = lowpass[hilp_eB1]; + lowpass[hilp_fA1] = lowpass[hilp_fB1]; + lowpass[hilp_fA2] = lowpass[hilp_fB2]; + //previous run through the buffer is still in the filter, so we move it + //to the A section and now it's the new starting point. + + double K = tan(M_PI * highpass[hilp_freq]); //highpass + double norm = 1.0 / (1.0 + K / 1.93185165 + K * K); + highpass[hilp_aB0] = norm; + highpass[hilp_aB1] = -2.0 * highpass[hilp_aB0]; + highpass[hilp_bB1] = 2.0 * (K * K - 1.0) * norm; + highpass[hilp_bB2] = (1.0 - K / 1.93185165 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.70710678 + K * K); + highpass[hilp_cB0] = norm; + highpass[hilp_cB1] = -2.0 * highpass[hilp_cB0]; + highpass[hilp_dB1] = 2.0 * (K * K - 1.0) * norm; + highpass[hilp_dB2] = (1.0 - K / 0.70710678 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.51763809 + K * K); + highpass[hilp_eB0] = norm; + highpass[hilp_eB1] = -2.0 * highpass[hilp_eB0]; + highpass[hilp_fB1] = 2.0 * (K * K - 1.0) * norm; + highpass[hilp_fB2] = (1.0 - K / 0.51763809 + K * K) * norm; - double kalman = 1.0-pow(E,2); + K = tan(M_PI * lowpass[hilp_freq]); //lowpass + norm = 1.0 / (1.0 + K / 1.93185165 + K * K); + lowpass[hilp_aB0] = K * K * norm; + lowpass[hilp_aB1] = 2.0 * lowpass[hilp_aB0]; + lowpass[hilp_bB1] = 2.0 * (K * K - 1.0) * norm; + lowpass[hilp_bB2] = (1.0 - K / 1.93185165 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.70710678 + K * K); + lowpass[hilp_cB0] = K * K * norm; + lowpass[hilp_cB1] = 2.0 * lowpass[hilp_cB0]; + lowpass[hilp_dB1] = 2.0 * (K * K - 1.0) * norm; + lowpass[hilp_dB2] = (1.0 - K / 0.70710678 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.51763809 + K * K); + lowpass[hilp_eB0] = K * K * norm; + lowpass[hilp_eB1] = 2.0 * lowpass[hilp_eB0]; + lowpass[hilp_fB1] = 2.0 * (K * K - 1.0) * norm; + lowpass[hilp_fB2] = (1.0 - K / 0.51763809 + K * K) * norm; + + if (highpass[hilp_aA0] == 0.0) { // if we have just started, start directly with raw info + highpass[hilp_aA0] = highpass[hilp_aB0]; + highpass[hilp_aA1] = highpass[hilp_aB1]; + highpass[hilp_bA1] = highpass[hilp_bB1]; + highpass[hilp_bA2] = highpass[hilp_bB2]; + highpass[hilp_cA0] = highpass[hilp_cB0]; + highpass[hilp_cA1] = highpass[hilp_cB1]; + highpass[hilp_dA1] = highpass[hilp_dB1]; + highpass[hilp_dA2] = highpass[hilp_dB2]; + highpass[hilp_eA0] = highpass[hilp_eB0]; + highpass[hilp_eA1] = highpass[hilp_eB1]; + highpass[hilp_fA1] = highpass[hilp_fB1]; + highpass[hilp_fA2] = highpass[hilp_fB2]; + lowpass[hilp_aA0] = lowpass[hilp_aB0]; + lowpass[hilp_aA1] = lowpass[hilp_aB1]; + lowpass[hilp_bA1] = lowpass[hilp_bB1]; + lowpass[hilp_bA2] = lowpass[hilp_bB2]; + lowpass[hilp_cA0] = lowpass[hilp_cB0]; + lowpass[hilp_cA1] = lowpass[hilp_cB1]; + lowpass[hilp_dA1] = lowpass[hilp_dB1]; + lowpass[hilp_dA2] = lowpass[hilp_dB2]; + lowpass[hilp_eA0] = lowpass[hilp_eB0]; + lowpass[hilp_eA1] = lowpass[hilp_eB1]; + lowpass[hilp_fA1] = lowpass[hilp_fB1]; + lowpass[hilp_fA2] = lowpass[hilp_fB2]; + } + airGainA = airGainB; airGainB = AIR *2.0; + fireGainA = fireGainB; fireGainB = FIR *2.0; + stoneGainA = stoneGainB; stoneGainB = STO *2.0; + //simple three band to adjust + double kalmanRange = 1.0-pow(RNG,2); //crossover frequency between mid/bass - double refdB = (F*70.0)+70.0; + double compFThresh = pow(FCT,4); + double compSThresh = pow(SCT,4); + double compFRatio = 1.0-pow(1.0-FCR,2); + double compSRatio = 1.0-pow(1.0-SCR,2); + double compFAttack = 1.0/(((pow(FCA,3)*5000.0)+500.0)*overallscale); + double compSAttack = 1.0/(((pow(SCA,3)*5000.0)+500.0)*overallscale); + double compFRelease = 1.0/(((pow(FCL,5)*50000.0)+500.0)*overallscale); + double compSRelease = 1.0/(((pow(SCL,5)*50000.0)+500.0)*overallscale); + double gateFThresh = pow(FGT,4); + double gateSThresh = pow(SGT,4); + double gateFRatio = 1.0-pow(1.0-FGR,2); + double gateSRatio = 1.0-pow(1.0-SGR,2); + double gateFSustain = M_PI_2 * pow(FGS+1.0,4.0); + double gateSSustain = M_PI_2 * pow(SGS+1.0,4.0); + double gateFRelease = 1.0/(((pow(FGL,5)*500000.0)+500.0)*overallscale); + double gateSRelease = 1.0/(((pow(SGL,5)*500000.0)+500.0)*overallscale); + + high[biqs_freq] = (((pow(TRF,3)*14500.0)+1500.0)/getSampleRate()); + if (high[biqs_freq] < 0.0001) high[biqs_freq] = 0.0001; + high[biqs_nonlin] = TRG; + high[biqs_level] = (high[biqs_nonlin]*2.0)-1.0; + if (high[biqs_level] > 0.0) high[biqs_level] *= 2.0; + high[biqs_reso] = ((0.5+(high[biqs_nonlin]*0.5)+sqrt(high[biqs_freq]))-(1.0-pow(1.0-TRR,2.0)))+0.5+(high[biqs_nonlin]*0.5); + K = tan(M_PI * high[biqs_freq]); + norm = 1.0 / (1.0 + K / (high[biqs_reso]*1.93185165) + K * K); + high[biqs_a0] = K / (high[biqs_reso]*1.93185165) * norm; + high[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + high[biqs_b2] = (1.0 - K / (high[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (high[biqs_reso]*0.70710678) + K * K); + high[biqs_c0] = K / (high[biqs_reso]*0.70710678) * norm; + high[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + high[biqs_d2] = (1.0 - K / (high[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (high[biqs_reso]*0.51763809) + K * K); + high[biqs_e0] = K / (high[biqs_reso]*0.51763809) * norm; + high[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + high[biqs_f2] = (1.0 - K / (high[biqs_reso]*0.51763809) + K * K) * norm; + //high + + hmid[biqs_freq] = (((pow(HMF,3)*6400.0)+600.0)/getSampleRate()); + if (hmid[biqs_freq] < 0.0001) hmid[biqs_freq] = 0.0001; + hmid[biqs_nonlin] = HMG; + hmid[biqs_level] = (hmid[biqs_nonlin]*2.0)-1.0; + if (hmid[biqs_level] > 0.0) hmid[biqs_level] *= 2.0; + hmid[biqs_reso] = ((0.5+(hmid[biqs_nonlin]*0.5)+sqrt(hmid[biqs_freq]))-(1.0-pow(1.0-HMR,2.0)))+0.5+(hmid[biqs_nonlin]*0.5); + K = tan(M_PI * hmid[biqs_freq]); + norm = 1.0 / (1.0 + K / (hmid[biqs_reso]*1.93185165) + K * K); + hmid[biqs_a0] = K / (hmid[biqs_reso]*1.93185165) * norm; + hmid[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + hmid[biqs_b2] = (1.0 - K / (hmid[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (hmid[biqs_reso]*0.70710678) + K * K); + hmid[biqs_c0] = K / (hmid[biqs_reso]*0.70710678) * norm; + hmid[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + hmid[biqs_d2] = (1.0 - K / (hmid[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (hmid[biqs_reso]*0.51763809) + K * K); + hmid[biqs_e0] = K / (hmid[biqs_reso]*0.51763809) * norm; + hmid[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + hmid[biqs_f2] = (1.0 - K / (hmid[biqs_reso]*0.51763809) + K * K) * norm; + //hmid + + lmid[biqs_freq] = (((pow(LMF,3)*2200.0)+200.0)/getSampleRate()); + if (lmid[biqs_freq] < 0.0001) lmid[biqs_freq] = 0.0001; + lmid[biqs_nonlin] = LMG; + lmid[biqs_level] = (lmid[biqs_nonlin]*2.0)-1.0; + if (lmid[biqs_level] > 0.0) lmid[biqs_level] *= 2.0; + lmid[biqs_reso] = ((0.5+(lmid[biqs_nonlin]*0.5)+sqrt(lmid[biqs_freq]))-(1.0-pow(1.0-LMR,2.0)))+0.5+(lmid[biqs_nonlin]*0.5); + K = tan(M_PI * lmid[biqs_freq]); + norm = 1.0 / (1.0 + K / (lmid[biqs_reso]*1.93185165) + K * K); + lmid[biqs_a0] = K / (lmid[biqs_reso]*1.93185165) * norm; + lmid[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + lmid[biqs_b2] = (1.0 - K / (lmid[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (lmid[biqs_reso]*0.70710678) + K * K); + lmid[biqs_c0] = K / (lmid[biqs_reso]*0.70710678) * norm; + lmid[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + lmid[biqs_d2] = (1.0 - K / (lmid[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (lmid[biqs_reso]*0.51763809) + K * K); + lmid[biqs_e0] = K / (lmid[biqs_reso]*0.51763809) * norm; + lmid[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + lmid[biqs_f2] = (1.0 - K / (lmid[biqs_reso]*0.51763809) + K * K) * norm; + //lmid + + bass[biqs_freq] = (((pow(BSF,3)*570.0)+30.0)/getSampleRate()); + if (bass[biqs_freq] < 0.0001) bass[biqs_freq] = 0.0001; + bass[biqs_nonlin] = BSG; + bass[biqs_level] = (bass[biqs_nonlin]*2.0)-1.0; + if (bass[biqs_level] > 0.0) bass[biqs_level] *= 2.0; + bass[biqs_reso] = ((0.5+(bass[biqs_nonlin]*0.5)+sqrt(bass[biqs_freq]))-(1.0-pow(1.0-BSR,2.0)))+0.5+(bass[biqs_nonlin]*0.5); + K = tan(M_PI * bass[biqs_freq]); + norm = 1.0 / (1.0 + K / (bass[biqs_reso]*1.93185165) + K * K); + bass[biqs_a0] = K / (bass[biqs_reso]*1.93185165) * norm; + bass[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + bass[biqs_b2] = (1.0 - K / (bass[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (bass[biqs_reso]*0.70710678) + K * K); + bass[biqs_c0] = K / (bass[biqs_reso]*0.70710678) * norm; + bass[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + bass[biqs_d2] = (1.0 - K / (bass[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (bass[biqs_reso]*0.51763809) + K * K); + bass[biqs_e0] = K / (bass[biqs_reso]*0.51763809) * norm; + bass[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + bass[biqs_f2] = (1.0 - K / (bass[biqs_reso]*0.51763809) + K * K) * norm; + //bass + + double refdB = (DSC*70.0)+70.0; double topdB = 0.000000075 * pow(10.0,refdB/20.0) * overallscale; - panA = panB; panB = G*1.57079633; - inTrimA = inTrimB; inTrimB = H*2.0; + panA = panB; panB = PAN*1.57079633; + inTrimA = inTrimB; inTrimB = FAD*2.0; while (--sampleFrames >= 0) { @@ -355,59 +952,262 @@ void ConsoleXBuss::processDoubleReplacing(double **inputs, double **outputs, Vst double inputSampleR = *in2; if (fabs(inputSampleL)<1.18e-23) inputSampleL = fpdL * 1.18e-17; if (fabs(inputSampleR)<1.18e-23) inputSampleR = fpdR * 1.18e-17; - double drySampleL = inputSampleL; - double drySampleR = inputSampleR; - if (biquad[biq_freq] < 0.5) { - double nlBiq = fabs(biquad[biq_a0]*(1.0+(inputSampleL*0.25))); if (nlBiq > 1.0) nlBiq = 1.0; - double tmp = (inputSampleL * nlBiq) + biquad[biq_sL1]; - biquad[biq_sL1] = (inputSampleL * biquad[biq_a1]) - (tmp * biquad[biq_b1]) + biquad[biq_sL2]; - biquad[biq_sL2] = (inputSampleL * nlBiq) - (tmp * biquad[biq_b2]); - inputSampleL = tmp; - nlBiq = fabs(biquad[biq_a0]*(1.0+(inputSampleR*0.25))); if (nlBiq > 1.0) nlBiq = 1.0; - tmp = (inputSampleR * nlBiq) + biquad[biq_sR1]; - biquad[biq_sR1] = (inputSampleR * biquad[biq_a1]) - (tmp * biquad[biq_b1]) + biquad[biq_sR2]; - biquad[biq_sR2] = (inputSampleR * nlBiq) - (tmp * biquad[biq_b2]); - inputSampleR = tmp; - //ultrasonic filter before anything else is done - } + double temp = (double)sampleFrames/inFramesToProcess; + highpass[hilp_a0] = (highpass[hilp_aA0]*temp)+(highpass[hilp_aB0]*(1.0-temp)); + highpass[hilp_a1] = (highpass[hilp_aA1]*temp)+(highpass[hilp_aB1]*(1.0-temp)); + highpass[hilp_b1] = (highpass[hilp_bA1]*temp)+(highpass[hilp_bB1]*(1.0-temp)); + highpass[hilp_b2] = (highpass[hilp_bA2]*temp)+(highpass[hilp_bB2]*(1.0-temp)); + highpass[hilp_c0] = (highpass[hilp_cA0]*temp)+(highpass[hilp_cB0]*(1.0-temp)); + highpass[hilp_c1] = (highpass[hilp_cA1]*temp)+(highpass[hilp_cB1]*(1.0-temp)); + highpass[hilp_d1] = (highpass[hilp_dA1]*temp)+(highpass[hilp_dB1]*(1.0-temp)); + highpass[hilp_d2] = (highpass[hilp_dA2]*temp)+(highpass[hilp_dB2]*(1.0-temp)); + highpass[hilp_e0] = (highpass[hilp_eA0]*temp)+(highpass[hilp_eB0]*(1.0-temp)); + highpass[hilp_e1] = (highpass[hilp_eA1]*temp)+(highpass[hilp_eB1]*(1.0-temp)); + highpass[hilp_f1] = (highpass[hilp_fA1]*temp)+(highpass[hilp_fB1]*(1.0-temp)); + highpass[hilp_f2] = (highpass[hilp_fA2]*temp)+(highpass[hilp_fB2]*(1.0-temp)); + lowpass[hilp_a0] = (lowpass[hilp_aA0]*temp)+(lowpass[hilp_aB0]*(1.0-temp)); + lowpass[hilp_a1] = (lowpass[hilp_aA1]*temp)+(lowpass[hilp_aB1]*(1.0-temp)); + lowpass[hilp_b1] = (lowpass[hilp_bA1]*temp)+(lowpass[hilp_bB1]*(1.0-temp)); + lowpass[hilp_b2] = (lowpass[hilp_bA2]*temp)+(lowpass[hilp_bB2]*(1.0-temp)); + lowpass[hilp_c0] = (lowpass[hilp_cA0]*temp)+(lowpass[hilp_cB0]*(1.0-temp)); + lowpass[hilp_c1] = (lowpass[hilp_cA1]*temp)+(lowpass[hilp_cB1]*(1.0-temp)); + lowpass[hilp_d1] = (lowpass[hilp_dA1]*temp)+(lowpass[hilp_dB1]*(1.0-temp)); + lowpass[hilp_d2] = (lowpass[hilp_dA2]*temp)+(lowpass[hilp_dB2]*(1.0-temp)); + lowpass[hilp_e0] = (lowpass[hilp_eA0]*temp)+(lowpass[hilp_eB0]*(1.0-temp)); + lowpass[hilp_e1] = (lowpass[hilp_eA1]*temp)+(lowpass[hilp_eB1]*(1.0-temp)); + lowpass[hilp_f1] = (lowpass[hilp_fA1]*temp)+(lowpass[hilp_fB1]*(1.0-temp)); + lowpass[hilp_f2] = (lowpass[hilp_fA2]*temp)+(lowpass[hilp_fB2]*(1.0-temp)); + double gainR = (panA*temp)+(panB*(1.0-temp)); + double gainL = 1.57079633-gainR; + gainR = sin(gainR); gainL = sin(gainL); + double gain = (inTrimA*temp)+(inTrimB*(1.0-temp)); + if (gain > 1.0) gain *= gain; + if (gain < 1.0) gain = 1.0-pow(1.0-gain,2); + gain *= 1.527864045000421; + double airGain = (airGainA*temp)+(airGainB*(1.0-temp)); + double fireGain = (fireGainA*temp)+(fireGainB*(1.0-temp)); + double stoneGain = (stoneGainA*temp)+(stoneGainB*(1.0-temp)); + //set up smoothed gain controls + + if (highpassEngage) { //distributed Highpass + highpass[hilp_temp] = (inputSampleL*highpass[hilp_a0])+highpass[hilp_aL1]; + highpass[hilp_aL1] = (inputSampleL*highpass[hilp_a1])-(highpass[hilp_temp]*highpass[hilp_b1])+highpass[hilp_aL2]; + highpass[hilp_aL2] = (inputSampleL*highpass[hilp_a0])-(highpass[hilp_temp]*highpass[hilp_b2]); inputSampleL = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleR*highpass[hilp_a0])+highpass[hilp_aR1]; + highpass[hilp_aR1] = (inputSampleR*highpass[hilp_a1])-(highpass[hilp_temp]*highpass[hilp_b1])+highpass[hilp_aR2]; + highpass[hilp_aR2] = (inputSampleR*highpass[hilp_a0])-(highpass[hilp_temp]*highpass[hilp_b2]); inputSampleR = highpass[hilp_temp]; + } else highpass[hilp_aR1] = highpass[hilp_aR2] = highpass[hilp_aL1] = highpass[hilp_aL2] = 0.0; + if (lowpassEngage) { //distributed Lowpass + lowpass[hilp_temp] = (inputSampleL*lowpass[hilp_a0])+lowpass[hilp_aL1]; + lowpass[hilp_aL1] = (inputSampleL*lowpass[hilp_a1])-(lowpass[hilp_temp]*lowpass[hilp_b1])+lowpass[hilp_aL2]; + lowpass[hilp_aL2] = (inputSampleL*lowpass[hilp_a0])-(lowpass[hilp_temp]*lowpass[hilp_b2]); inputSampleL = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleR*lowpass[hilp_a0])+lowpass[hilp_aR1]; + lowpass[hilp_aR1] = (inputSampleR*lowpass[hilp_a1])-(lowpass[hilp_temp]*lowpass[hilp_b1])+lowpass[hilp_aR2]; + lowpass[hilp_aR2] = (inputSampleR*lowpass[hilp_a0])-(lowpass[hilp_temp]*lowpass[hilp_b2]); inputSampleR = lowpass[hilp_temp]; + } else lowpass[hilp_aR1] = lowpass[hilp_aR2] = lowpass[hilp_aL1] = lowpass[hilp_aL2] = 0.0; + //first Highpass/Lowpass blocks aliasing before the nonlinearity of ConsoleXBuss and Parametric + //ConsoleXBuss after initial Highpass/Lowpass stages if (inputSampleL > 1.0) inputSampleL = 1.0; else if (inputSampleL > 0.0) inputSampleL = -expm1((log1p(-inputSampleL) * 0.6180339887498949)); if (inputSampleL < -1.0) inputSampleL = -1.0; else if (inputSampleL < 0.0) inputSampleL = expm1((log1p(inputSampleL) * 0.6180339887498949)); inputSampleL *= 1.6180339887498949; - if (inputSampleR > 1.0) inputSampleR = 1.0; else if (inputSampleR > 0.0) inputSampleR = -expm1((log1p(-inputSampleR) * 0.6180339887498949)); if (inputSampleR < -1.0) inputSampleR = -1.0; else if (inputSampleR < 0.0) inputSampleR = expm1((log1p(inputSampleR) * 0.6180339887498949)); inputSampleR *= 1.6180339887498949; + //ConsoleXBuss after initial Highpass/Lowpass stages - double temp = (double)sampleFrames/inFramesToProcess; - double trebleGain = (trebleGainA*temp)+(trebleGainB*(1.0-temp)); - if (trebleGain > 1.0) trebleGain = pow(trebleGain,3.0+sqrt(overallscale)); - if (trebleGain < 1.0) trebleGain = 1.0-pow(1.0-trebleGain,2); + //get all Parametric bands before any other processing is done + //begin Stacked Biquad With Reversed Neutron Flow L + high[biqs_outL] = inputSampleL * fabs(high[biqs_level]); + high[biqs_dis] = fabs(high[biqs_a0] * (1.0+(high[biqs_outL]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outL] * high[biqs_dis]) + high[biqs_aL1]; + high[biqs_aL1] = high[biqs_aL2] - (high[biqs_temp]*high[biqs_b1]); + high[biqs_aL2] = (high[biqs_outL] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_b2]); + high[biqs_outL] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_c0] * (1.0+(high[biqs_outL]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outL] * high[biqs_dis]) + high[biqs_cL1]; + high[biqs_cL1] = high[biqs_cL2] - (high[biqs_temp]*high[biqs_d1]); + high[biqs_cL2] = (high[biqs_outL] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_d2]); + high[biqs_outL] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_e0] * (1.0+(high[biqs_outL]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outL] * high[biqs_dis]) + high[biqs_eL1]; + high[biqs_eL1] = high[biqs_eL2] - (high[biqs_temp]*high[biqs_f1]); + high[biqs_eL2] = (high[biqs_outL] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_f2]); + high[biqs_outL] = high[biqs_temp]; high[biqs_outL] *= high[biqs_level]; + if (high[biqs_level] > 1.0) high[biqs_outL] *= high[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L - double midGain = (midGainA*temp)+(midGainB*(1.0-temp)); - if (midGain > 1.0) midGain = 1.0; - if (midGain < 1.0) midGain = 1.0-pow(1.0-midGain,2); - double mPeak = pow((mPeakA*temp)+(mPeakB*(1.0-temp)),2); + //begin Stacked Biquad With Reversed Neutron Flow L + hmid[biqs_outL] = inputSampleL * fabs(hmid[biqs_level]); + hmid[biqs_dis] = fabs(hmid[biqs_a0] * (1.0+(hmid[biqs_outL]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outL] * hmid[biqs_dis]) + hmid[biqs_aL1]; + hmid[biqs_aL1] = hmid[biqs_aL2] - (hmid[biqs_temp]*hmid[biqs_b1]); + hmid[biqs_aL2] = (hmid[biqs_outL] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_b2]); + hmid[biqs_outL] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_c0] * (1.0+(hmid[biqs_outL]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outL] * hmid[biqs_dis]) + hmid[biqs_cL1]; + hmid[biqs_cL1] = hmid[biqs_cL2] - (hmid[biqs_temp]*hmid[biqs_d1]); + hmid[biqs_cL2] = (hmid[biqs_outL] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_d2]); + hmid[biqs_outL] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_e0] * (1.0+(hmid[biqs_outL]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outL] * hmid[biqs_dis]) + hmid[biqs_eL1]; + hmid[biqs_eL1] = hmid[biqs_eL2] - (hmid[biqs_temp]*hmid[biqs_f1]); + hmid[biqs_eL2] = (hmid[biqs_outL] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_f2]); + hmid[biqs_outL] = hmid[biqs_temp]; hmid[biqs_outL] *= hmid[biqs_level]; + if (hmid[biqs_level] > 1.0) hmid[biqs_outL] *= hmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L - double bassGain = (bassGainA*temp)+(bassGainB*(1.0-temp)); - if (bassGain > 1.0) bassGain *= bassGain; - if (bassGain < 1.0) bassGain = 1.0-pow(1.0-bassGain,2); + //begin Stacked Biquad With Reversed Neutron Flow L + lmid[biqs_outL] = inputSampleL * fabs(lmid[biqs_level]); + lmid[biqs_dis] = fabs(lmid[biqs_a0] * (1.0+(lmid[biqs_outL]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outL] * lmid[biqs_dis]) + lmid[biqs_aL1]; + lmid[biqs_aL1] = lmid[biqs_aL2] - (lmid[biqs_temp]*lmid[biqs_b1]); + lmid[biqs_aL2] = (lmid[biqs_outL] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_b2]); + lmid[biqs_outL] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_c0] * (1.0+(lmid[biqs_outL]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outL] * lmid[biqs_dis]) + lmid[biqs_cL1]; + lmid[biqs_cL1] = lmid[biqs_cL2] - (lmid[biqs_temp]*lmid[biqs_d1]); + lmid[biqs_cL2] = (lmid[biqs_outL] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_d2]); + lmid[biqs_outL] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_e0] * (1.0+(lmid[biqs_outL]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outL] * lmid[biqs_dis]) + lmid[biqs_eL1]; + lmid[biqs_eL1] = lmid[biqs_eL2] - (lmid[biqs_temp]*lmid[biqs_f1]); + lmid[biqs_eL2] = (lmid[biqs_outL] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_f2]); + lmid[biqs_outL] = lmid[biqs_temp]; lmid[biqs_outL] *= lmid[biqs_level]; + if (lmid[biqs_level] > 1.0) lmid[biqs_outL] *= lmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L - double gainR = (panA*temp)+(panB*(1.0-temp)); - double gainL = 1.57079633-gainR; - gainR = sin(gainR); gainL = sin(gainL); + //begin Stacked Biquad With Reversed Neutron Flow L + bass[biqs_outL] = inputSampleL * fabs(bass[biqs_level]); + bass[biqs_dis] = fabs(bass[biqs_a0] * (1.0+(bass[biqs_outL]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outL] * bass[biqs_dis]) + bass[biqs_aL1]; + bass[biqs_aL1] = bass[biqs_aL2] - (bass[biqs_temp]*bass[biqs_b1]); + bass[biqs_aL2] = (bass[biqs_outL] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_b2]); + bass[biqs_outL] = bass[biqs_temp]; + bass[biqs_dis] = fabs(bass[biqs_c0] * (1.0+(bass[biqs_outL]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outL] * bass[biqs_dis]) + bass[biqs_cL1]; + bass[biqs_cL1] = bass[biqs_cL2] - (bass[biqs_temp]*bass[biqs_d1]); + bass[biqs_cL2] = (bass[biqs_outL] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_d2]); + bass[biqs_outL] = bass[biqs_temp]; + bass[biqs_dis] = fabs(bass[biqs_e0] * (1.0+(bass[biqs_outL]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outL] * bass[biqs_dis]) + bass[biqs_eL1]; + bass[biqs_eL1] = bass[biqs_eL2] - (bass[biqs_temp]*bass[biqs_f1]); + bass[biqs_eL2] = (bass[biqs_outL] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_f2]); + bass[biqs_outL] = bass[biqs_temp]; bass[biqs_outL] *= bass[biqs_level]; + if (bass[biqs_level] > 1.0) bass[biqs_outL] *= bass[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L - double gain = (inTrimA*temp)+(inTrimB*(1.0-temp)); - if (gain > 1.0) gain *= gain; - if (gain < 1.0) gain = 1.0-pow(1.0-gain,2); - gain *= 1.527864045000421; + //begin Stacked Biquad With Reversed Neutron Flow R + high[biqs_outR] = inputSampleR * fabs(high[biqs_level]); + high[biqs_dis] = fabs(high[biqs_a0] * (1.0+(high[biqs_outR]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outR] * high[biqs_dis]) + high[biqs_aR1]; + high[biqs_aR1] = high[biqs_aR2] - (high[biqs_temp]*high[biqs_b1]); + high[biqs_aR2] = (high[biqs_outR] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_b2]); + high[biqs_outR] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_c0] * (1.0+(high[biqs_outR]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outR] * high[biqs_dis]) + high[biqs_cR1]; + high[biqs_cR1] = high[biqs_cR2] - (high[biqs_temp]*high[biqs_d1]); + high[biqs_cR2] = (high[biqs_outR] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_d2]); + high[biqs_outR] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_e0] * (1.0+(high[biqs_outR]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outR] * high[biqs_dis]) + high[biqs_eR1]; + high[biqs_eR1] = high[biqs_eR2] - (high[biqs_temp]*high[biqs_f1]); + high[biqs_eR2] = (high[biqs_outR] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_f2]); + high[biqs_outR] = high[biqs_temp]; high[biqs_outR] *= high[biqs_level]; + if (high[biqs_level] > 1.0) high[biqs_outR] *= high[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R + + //begin Stacked Biquad With Reversed Neutron Flow R + hmid[biqs_outR] = inputSampleR * fabs(hmid[biqs_level]); + hmid[biqs_dis] = fabs(hmid[biqs_a0] * (1.0+(hmid[biqs_outR]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outR] * hmid[biqs_dis]) + hmid[biqs_aR1]; + hmid[biqs_aR1] = hmid[biqs_aR2] - (hmid[biqs_temp]*hmid[biqs_b1]); + hmid[biqs_aR2] = (hmid[biqs_outR] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_b2]); + hmid[biqs_outR] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_c0] * (1.0+(hmid[biqs_outR]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outR] * hmid[biqs_dis]) + hmid[biqs_cR1]; + hmid[biqs_cR1] = hmid[biqs_cR2] - (hmid[biqs_temp]*hmid[biqs_d1]); + hmid[biqs_cR2] = (hmid[biqs_outR] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_d2]); + hmid[biqs_outR] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_e0] * (1.0+(hmid[biqs_outR]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outR] * hmid[biqs_dis]) + hmid[biqs_eR1]; + hmid[biqs_eR1] = hmid[biqs_eR2] - (hmid[biqs_temp]*hmid[biqs_f1]); + hmid[biqs_eR2] = (hmid[biqs_outR] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_f2]); + hmid[biqs_outR] = hmid[biqs_temp]; hmid[biqs_outR] *= hmid[biqs_level]; + if (hmid[biqs_level] > 1.0) hmid[biqs_outR] *= hmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R + + //begin Stacked Biquad With Reversed Neutron Flow R + lmid[biqs_outR] = inputSampleR * fabs(lmid[biqs_level]); + lmid[biqs_dis] = fabs(lmid[biqs_a0] * (1.0+(lmid[biqs_outR]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outR] * lmid[biqs_dis]) + lmid[biqs_aR1]; + lmid[biqs_aR1] = lmid[biqs_aR2] - (lmid[biqs_temp]*lmid[biqs_b1]); + lmid[biqs_aR2] = (lmid[biqs_outR] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_b2]); + lmid[biqs_outR] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_c0] * (1.0+(lmid[biqs_outR]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outR] * lmid[biqs_dis]) + lmid[biqs_cR1]; + lmid[biqs_cR1] = lmid[biqs_cR2] - (lmid[biqs_temp]*lmid[biqs_d1]); + lmid[biqs_cR2] = (lmid[biqs_outR] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_d2]); + lmid[biqs_outR] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_e0] * (1.0+(lmid[biqs_outR]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outR] * lmid[biqs_dis]) + lmid[biqs_eR1]; + lmid[biqs_eR1] = lmid[biqs_eR2] - (lmid[biqs_temp]*lmid[biqs_f1]); + lmid[biqs_eR2] = (lmid[biqs_outR] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_f2]); + lmid[biqs_outR] = lmid[biqs_temp]; lmid[biqs_outR] *= lmid[biqs_level]; + if (lmid[biqs_level] > 1.0) lmid[biqs_outR] *= lmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R + + //begin Stacked Biquad With Reversed Neutron Flow R + bass[biqs_outR] = inputSampleR * fabs(bass[biqs_level]); + bass[biqs_dis] = fabs(bass[biqs_a0] * (1.0+(bass[biqs_outR]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outR] * bass[biqs_dis]) + bass[biqs_aR1]; + bass[biqs_aR1] = bass[biqs_aR2] - (bass[biqs_temp]*bass[biqs_b1]); + bass[biqs_aR2] = (bass[biqs_outR] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_b2]); + bass[biqs_outR] = bass[biqs_temp]; + bass[biqs_dis] = fabs(bass[biqs_c0] * (1.0+(bass[biqs_outR]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outR] * bass[biqs_dis]) + bass[biqs_cR1]; + bass[biqs_cR1] = bass[biqs_cR2] - (bass[biqs_temp]*bass[biqs_d1]); + bass[biqs_cR2] = (bass[biqs_outR] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_d2]); + bass[biqs_outR] = bass[biqs_temp]; + bass[biqs_dis] = fabs(bass[biqs_e0] * (1.0+(bass[biqs_outR]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outR] * bass[biqs_dis]) + bass[biqs_eR1]; + bass[biqs_eR1] = bass[biqs_eR2] - (bass[biqs_temp]*bass[biqs_f1]); + bass[biqs_eR2] = (bass[biqs_outR] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_f2]); + bass[biqs_outR] = bass[biqs_temp]; bass[biqs_outR] *= bass[biqs_level]; + if (bass[biqs_level] > 1.0) bass[biqs_outR] *= bass[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R //begin Air3L + double drySampleL = inputSampleL; air[pvSL4] = air[pvAL4] - air[pvAL3]; air[pvSL3] = air[pvAL3] - air[pvAL2]; air[pvSL2] = air[pvAL2] - air[pvAL1]; air[pvSL1] = air[pvAL1] - inputSampleL; air[accSL3] = air[pvSL4] - air[pvSL3]; air[accSL2] = air[pvSL3] - air[pvSL2]; @@ -418,13 +1218,13 @@ void ConsoleXBuss::processDoubleReplacing(double **inputs, double **outputs, Vst if (air[gainAL] > 0.3*sqrt(overallscale)) air[gainAL] = 0.3*sqrt(overallscale); air[pvAL4] = air[pvAL3]; air[pvAL3] = air[pvAL2]; air[pvAL2] = air[pvAL1]; air[pvAL1] = (air[gainAL] * air[outAL]) + drySampleL; - double midL = drySampleL - ((air[outAL]*0.5)+(drySampleL*(0.457-(0.017*overallscale)))); - temp = (midL + air[gndavgL])*0.5; air[gndavgL] = midL; midL = temp; - double trebleL = drySampleL-midL; - inputSampleL = midL; + double fireL = drySampleL - ((air[outAL]*0.5)+(drySampleL*(0.457-(0.017*overallscale)))); + temp = (fireL + air[gndavgL])*0.5; air[gndavgL] = fireL; fireL = temp; + double airL = drySampleL-fireL; + inputSampleL = fireL; //end Air3L - //begin Air3R + double drySampleR = inputSampleR; air[pvSR4] = air[pvAR4] - air[pvAR3]; air[pvSR3] = air[pvAR3] - air[pvAR2]; air[pvSR2] = air[pvAR2] - air[pvAR1]; air[pvSR1] = air[pvAR1] - inputSampleR; air[accSR3] = air[pvSR4] - air[pvSR3]; air[accSR2] = air[pvSR3] - air[pvSR2]; @@ -435,15 +1235,14 @@ void ConsoleXBuss::processDoubleReplacing(double **inputs, double **outputs, Vst if (air[gainAR] > 0.3*sqrt(overallscale)) air[gainAR] = 0.3*sqrt(overallscale); air[pvAR4] = air[pvAR3]; air[pvAR3] = air[pvAR2]; air[pvAR2] = air[pvAR1]; air[pvAR1] = (air[gainAR] * air[outAR]) + drySampleR; - double midR = drySampleR - ((air[outAR]*0.5)+(drySampleR*(0.457-(0.017*overallscale)))); - temp = (midR + air[gndavgR])*0.5; air[gndavgR] = midR; midR = temp; - double trebleR = drySampleR-midR; - inputSampleR = midR; + double fireR = drySampleR - ((air[outAR]*0.5)+(drySampleR*(0.457-(0.017*overallscale)))); + temp = (fireR + air[gndavgR])*0.5; air[gndavgR] = fireR; fireR = temp; + double airR = drySampleR-fireR; + inputSampleR = fireR; //end Air3R - //begin KalmanL - temp = inputSampleL = inputSampleL*(1.0-kalman)*0.777; - inputSampleL *= (1.0-kalman); + temp = inputSampleL = inputSampleL*(1.0-kalmanRange)*0.777; + inputSampleL *= (1.0-kalmanRange); //set up gain levels to control the beast kal[prevSlewL3] += kal[prevSampL3] - kal[prevSampL2]; kal[prevSlewL3] *= 0.5; kal[prevSlewL2] += kal[prevSampL2] - kal[prevSampL1]; kal[prevSlewL2] *= 0.5; @@ -456,23 +1255,22 @@ void ConsoleXBuss::processDoubleReplacing(double **inputs, double **outputs, Vst //entering the abyss, what even is this kal[kalOutL] += kal[prevSampL1] + kal[prevSlewL2] + kal[accSlewL3]; kal[kalOutL] *= 0.5; //resynthesizing predicted result (all iir smoothed) - kal[kalGainL] += fabs(temp-kal[kalOutL])*kalman*8.0; kal[kalGainL] *= 0.5; + kal[kalGainL] += fabs(temp-kal[kalOutL])*kalmanRange*8.0; kal[kalGainL] *= 0.5; //madness takes its toll. Kalman Gain: how much dry to retain - if (kal[kalGainL] > kalman*0.5) kal[kalGainL] = kalman*0.5; + if (kal[kalGainL] > kalmanRange*0.5) kal[kalGainL] = kalmanRange*0.5; //attempts to avoid explosions - kal[kalOutL] += (temp*(1.0-(0.68+(kalman*0.157)))); + kal[kalOutL] += (temp*(1.0-(0.68+(kalmanRange*0.157)))); //this is for tuning a really complete cancellation up around Nyquist kal[prevSampL3] = kal[prevSampL2]; kal[prevSampL2] = kal[prevSampL1]; kal[prevSampL1] = (kal[kalGainL] * kal[kalOutL]) + ((1.0-kal[kalGainL])*temp); //feed the chain of previous samples if (kal[prevSampL1] > 1.0) kal[prevSampL1] = 1.0; if (kal[prevSampL1] < -1.0) kal[prevSampL1] = -1.0; - double bassL = kal[kalOutL]*0.777; - midL -= bassL; + double stoneL = kal[kalOutL]*0.777; + fireL -= stoneL; //end KalmanL - //begin KalmanR - temp = inputSampleR = inputSampleR*(1.0-kalman)*0.777; - inputSampleR *= (1.0-kalman); + temp = inputSampleR = inputSampleR*(1.0-kalmanRange)*0.777; + inputSampleR *= (1.0-kalmanRange); //set up gain levels to control the beast kal[prevSlewR3] += kal[prevSampR3] - kal[prevSampR2]; kal[prevSlewR3] *= 0.5; kal[prevSlewR2] += kal[prevSampR2] - kal[prevSampR1]; kal[prevSlewR2] *= 0.5; @@ -485,60 +1283,106 @@ void ConsoleXBuss::processDoubleReplacing(double **inputs, double **outputs, Vst //entering the abyss, what even is this kal[kalOutR] += kal[prevSampR1] + kal[prevSlewR2] + kal[accSlewR3]; kal[kalOutR] *= 0.5; //resynthesizing predicted result (all iir smoothed) - kal[kalGainR] += fabs(temp-kal[kalOutR])*kalman*8.0; kal[kalGainR] *= 0.5; + kal[kalGainR] += fabs(temp-kal[kalOutR])*kalmanRange*8.0; kal[kalGainR] *= 0.5; //madness takes its toll. Kalman Gain: how much dry to retain - if (kal[kalGainR] > kalman*0.5) kal[kalGainR] = kalman*0.5; + if (kal[kalGainR] > kalmanRange*0.5) kal[kalGainR] = kalmanRange*0.5; //attempts to avoid explosions - kal[kalOutR] += (temp*(1.0-(0.68+(kalman*0.157)))); + kal[kalOutR] += (temp*(1.0-(0.68+(kalmanRange*0.157)))); //this is for tuning a really complete cancellation up around Nyquist kal[prevSampR3] = kal[prevSampR2]; kal[prevSampR2] = kal[prevSampR1]; kal[prevSampR1] = (kal[kalGainR] * kal[kalOutR]) + ((1.0-kal[kalGainR])*temp); //feed the chain of previous samples if (kal[prevSampR1] > 1.0) kal[prevSampR1] = 1.0; if (kal[prevSampR1] < -1.0) kal[prevSampR1] = -1.0; - double bassR = kal[kalOutR]*0.777; - midR -= bassR; + double stoneR = kal[kalOutR]*0.777; + fireR -= stoneR; //end KalmanR + //fire dynamics + if (fabs(fireL) > compFThresh) { //compression L + fireCompL -= (fireCompL * compFAttack); + fireCompL += ((compFThresh / fabs(fireL))*compFAttack); + } else fireCompL = (fireCompL*(1.0-compFRelease))+compFRelease; + if (fireCompL < 0.0) fireCompL = 0.0; + if (fabs(fireR) > compFThresh) { //compression R + fireCompR -= (fireCompR * compFAttack); + fireCompR += ((compFThresh / fabs(fireR))*compFAttack); + } else fireCompR = (fireCompR*(1.0-compFRelease))+compFRelease; + if (fireCompR < 0.0) fireCompR = 0.0; + if (fireCompL > fireCompR) fireCompL -= (fireCompL * compFAttack); + if (fireCompR > fireCompL) fireCompR -= (fireCompR * compFAttack); + if (fabs(fireL) > gateFThresh) fireGate = gateFSustain; + else if (fabs(fireR) > gateFThresh) fireGate = gateFSustain; + else fireGate *= (1.0-gateFRelease); + if (fireGate < 0.0) fireGate = 0.0; + if (fireCompL < 1.0) fireL *= ((1.0-compFRatio)+(fireCompL*compFRatio)); + if (fireCompR < 1.0) fireR *= ((1.0-compFRatio)+(fireCompR*compFRatio)); + if (fireGate < M_PI_2) { + temp = ((1.0-gateFRatio)+(sin(fireGate)*gateFRatio)); + airL *= temp; + airR *= temp; + fireL *= temp; + fireR *= temp; + high[biqs_outL] *= temp; + high[biqs_outR] *= temp; + hmid[biqs_outL] *= temp; //if Fire gating, gate Air, high and hmid + hmid[biqs_outR] *= temp; //note that we aren't compressing these + } + //stone dynamics + if (fabs(stoneL) > compSThresh) { //compression L + stoneCompL -= (stoneCompL * compSAttack); + stoneCompL += ((compSThresh / fabs(stoneL))*compSAttack); + } else stoneCompL = (stoneCompL*(1.0-compSRelease))+compSRelease; + if (stoneCompL < 0.0) stoneCompL = 0.0; + if (fabs(stoneR) > compSThresh) { //compression R + stoneCompR -= (stoneCompR * compSAttack); + stoneCompR += ((compSThresh / fabs(stoneR))*compSAttack); + } else stoneCompR = (stoneCompR*(1.0-compSRelease))+compSRelease; + if (stoneCompR < 0.0) stoneCompR = 0.0; + if (stoneCompL > stoneCompR) stoneCompL -= (stoneCompL * compSAttack); + if (stoneCompR > stoneCompL) stoneCompR -= (stoneCompR * compSAttack); + if (fabs(stoneL) > gateSThresh) stoneGate = gateSSustain; + else if (fabs(stoneR) > gateSThresh) stoneGate = gateSSustain; + else stoneGate *= (1.0-gateSRelease); + if (stoneGate < 0.0) stoneGate = 0.0; + if (stoneCompL < 1.0) stoneL *= ((1.0-compSRatio)+(stoneCompL*compSRatio)); + if (stoneCompR < 1.0) stoneR *= ((1.0-compSRatio)+(stoneCompR*compSRatio)); + if (stoneGate < M_PI_2) { + temp = ((1.0-gateSRatio)+(sin(stoneGate)*gateSRatio)); + stoneL *= temp; + stoneR *= temp; + lmid[biqs_outL] *= temp; + lmid[biqs_outR] *= temp; + bass[biqs_outL] *= temp; //if Stone gating, gate lmid and bass + bass[biqs_outR] *= temp; //note that we aren't compressing these + } + inputSampleL = (stoneL*stoneGain) + (fireL*fireGain) + (airL*airGain); + inputSampleR = (stoneR*stoneGain) + (fireR*fireGain) + (airR*airGain); + //create Stonefire output + + if (highpassEngage) { //distributed Highpass + highpass[hilp_temp] = (inputSampleL*highpass[hilp_c0])+highpass[hilp_cL1]; + highpass[hilp_cL1] = (inputSampleL*highpass[hilp_c1])-(highpass[hilp_temp]*highpass[hilp_d1])+highpass[hilp_cL2]; + highpass[hilp_cL2] = (inputSampleL*highpass[hilp_c0])-(highpass[hilp_temp]*highpass[hilp_d2]); inputSampleL = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleR*highpass[hilp_c0])+highpass[hilp_cR1]; + highpass[hilp_cR1] = (inputSampleR*highpass[hilp_c1])-(highpass[hilp_temp]*highpass[hilp_d1])+highpass[hilp_cR2]; + highpass[hilp_cR2] = (inputSampleR*highpass[hilp_c0])-(highpass[hilp_temp]*highpass[hilp_d2]); inputSampleR = highpass[hilp_temp]; + } else highpass[hilp_cR1] = highpass[hilp_cR2] = highpass[hilp_cL1] = highpass[hilp_cL2] = 0.0; + if (lowpassEngage) { //distributed Lowpass + lowpass[hilp_temp] = (inputSampleL*lowpass[hilp_c0])+lowpass[hilp_cL1]; + lowpass[hilp_cL1] = (inputSampleL*lowpass[hilp_c1])-(lowpass[hilp_temp]*lowpass[hilp_d1])+lowpass[hilp_cL2]; + lowpass[hilp_cL2] = (inputSampleL*lowpass[hilp_c0])-(lowpass[hilp_temp]*lowpass[hilp_d2]); inputSampleL = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleR*lowpass[hilp_c0])+lowpass[hilp_cR1]; + lowpass[hilp_cR1] = (inputSampleR*lowpass[hilp_c1])-(lowpass[hilp_temp]*lowpass[hilp_d1])+lowpass[hilp_cR2]; + lowpass[hilp_cR2] = (inputSampleR*lowpass[hilp_c0])-(lowpass[hilp_temp]*lowpass[hilp_d2]); inputSampleR = lowpass[hilp_temp]; + } else lowpass[hilp_cR1] = lowpass[hilp_cR2] = lowpass[hilp_cL1] = lowpass[hilp_cL2] = 0.0; + //another stage of Highpass/Lowpass before bringing in the parametric bands + + inputSampleL += (high[biqs_outL] + hmid[biqs_outL] + lmid[biqs_outL] + bass[biqs_outL]); + inputSampleR += (high[biqs_outR] + hmid[biqs_outR] + lmid[biqs_outR] + bass[biqs_outR]); + //add parametric boosts or cuts: clean as possible for maximal rawness and sonority - //begin ResEQ2 Mid Boost - mpc++; if (mpc < 1 || mpc > 2001) mpc = 1; - mpkL[mpc] = midL; - mpkR[mpc] = midR; - double midPeakL = 0.0; - double midPeakR = 0.0; - for (int x = 0; x < maxMPeak; x++) { - int y = x*cycleEnd; - switch (cycleEnd) - { - case 1: - midPeakL += (mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x]); - midPeakR += (mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x]); break; - case 2: - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.5); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.5); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.5); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.5); break; - case 3: - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); break; - case 4: - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); //break - } - }//end ResEQ2 Mid Boost creating - - inputSampleL = ((bassL*bassGain) + (midL*midGain) + (midPeakL*mPeak) + (trebleL*trebleGain)) * gainL; - inputSampleR = ((bassR*bassGain) + (midR*midGain) + (midPeakR*mPeak) + (trebleR*trebleGain)) * gainR; - //applies BitShiftPan pan section, and smoothed fader gain + inputSampleL = inputSampleL * gainL * gain; + inputSampleR = inputSampleR * gainR * gain; + //applies pan section, and smoothed fader gain inputSampleL *= topdB; if (inputSampleL < -0.222) inputSampleL = -0.222; if (inputSampleL > 0.222) inputSampleL = 0.222; @@ -560,8 +1404,24 @@ void ConsoleXBuss::processDoubleReplacing(double **inputs, double **outputs, Vst inputSampleR /= topdB; //top dB processing for distributed discontinuity modeling air nonlinearity - inputSampleL *= gain; - inputSampleR *= gain; + if (highpassEngage) { //distributed Highpass + highpass[hilp_temp] = (inputSampleL*highpass[hilp_e0])+highpass[hilp_eL1]; + highpass[hilp_eL1] = (inputSampleL*highpass[hilp_e1])-(highpass[hilp_temp]*highpass[hilp_f1])+highpass[hilp_eL2]; + highpass[hilp_eL2] = (inputSampleL*highpass[hilp_e0])-(highpass[hilp_temp]*highpass[hilp_f2]); inputSampleL = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleR*highpass[hilp_e0])+highpass[hilp_eR1]; + highpass[hilp_eR1] = (inputSampleR*highpass[hilp_e1])-(highpass[hilp_temp]*highpass[hilp_f1])+highpass[hilp_eR2]; + highpass[hilp_eR2] = (inputSampleR*highpass[hilp_e0])-(highpass[hilp_temp]*highpass[hilp_f2]); inputSampleR = highpass[hilp_temp]; + } else highpass[hilp_eR1] = highpass[hilp_eR2] = highpass[hilp_eL1] = highpass[hilp_eL2] = 0.0; + if (lowpassEngage) { //distributed Lowpass + lowpass[hilp_temp] = (inputSampleL*lowpass[hilp_e0])+lowpass[hilp_eL1]; + lowpass[hilp_eL1] = (inputSampleL*lowpass[hilp_e1])-(lowpass[hilp_temp]*lowpass[hilp_f1])+lowpass[hilp_eL2]; + lowpass[hilp_eL2] = (inputSampleL*lowpass[hilp_e0])-(lowpass[hilp_temp]*lowpass[hilp_f2]); inputSampleL = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleR*lowpass[hilp_e0])+lowpass[hilp_eR1]; + lowpass[hilp_eR1] = (inputSampleR*lowpass[hilp_e1])-(lowpass[hilp_temp]*lowpass[hilp_f1])+lowpass[hilp_eR2]; + lowpass[hilp_eR2] = (inputSampleR*lowpass[hilp_e0])-(lowpass[hilp_temp]*lowpass[hilp_f2]); inputSampleR = lowpass[hilp_temp]; + } else lowpass[hilp_eR1] = lowpass[hilp_eR2] = lowpass[hilp_eL1] = lowpass[hilp_eL2] = 0.0; + //final Highpass/Lowpass continues to address aliasing + //final stacked biquad section is the softest Q for smoothness //begin 64 bit stereo floating point dither //int expon; frexp((double)inputSampleL, &expon); diff --git a/src/autogen_airwin/ConsoleXChannel.cpp b/src/autogen_airwin/ConsoleXChannel.cpp index 66801ea..4ad0b71 100644 --- a/src/autogen_airwin/ConsoleXChannel.cpp +++ b/src/autogen_airwin/ConsoleXChannel.cpp @@ -15,24 +15,64 @@ AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new C ConsoleXChannel::ConsoleXChannel(audioMasterCallback audioMaster) : AudioEffectX(audioMaster, kNumPrograms, kNumParameters) { - A = 0.5; - B = 0.5; - C = 0.5; - D = 0.5; - E = 0.5; - F = 0.5; - G = 0.5; - H = 0.5; + HIP = 0.0; + LOP = 0.0; + AIR = 0.5; + FIR = 0.5; + STO = 0.5; + RNG = 0.5; + FCT = 1.0; + SCT = 1.0; + FCR = 1.0; + SCR = 1.0; + FCA = 0.5; + SCA = 0.5; + FCL = 0.5; + SCL = 0.5; + FGT = 0.0; + SGT = 0.0; + FGR = 1.0; + SGR = 1.0; + FGS = 0.5; + SGS = 0.5; + FGL = 0.5; + SGL = 0.5; + TRF = 0.5; + TRG = 0.5; + TRR = 0.5; + HMF = 0.5; + HMG = 0.5; + HMR = 0.5; + LMF = 0.5; + LMG = 0.5; + LMR = 0.5; + BSF = 0.5; + BSG = 0.5; + BSR = 0.5; + DSC = 0.5; + PAN = 0.5; + FAD = 0.5; + + for (int x = 0; x < hilp_total; x++) { + highpass[x] = 0.0; + lowpass[x] = 0.0; + } - for (int x = 0; x < biq_total; x++) {biquad[x] = 0.0;} for (int x = 0; x < air_total; x++) air[x] = 0.0; for (int x = 0; x < kal_total; x++) kal[x] = 0.0; + fireCompL = 1.0; + fireCompR = 1.0; + fireGate = 1.0; + stoneCompL = 1.0; + stoneCompR = 1.0; + stoneGate = 1.0; - for(int count = 0; count < 2004; count++) {mpkL[count] = 0.0; mpkR[count] = 0.0;} - for(int count = 0; count < 65; count++) {f[count] = 0.0;} - prevfreqMPeak = -1; - prevamountMPeak = -1; - mpc = 1; + for (int x = 0; x < biqs_total; x++) { + high[x] = 0.0; + hmid[x] = 0.0; + lmid[x] = 0.0; + bass[x] = 0.0; + } for(int count = 0; count < dscBuf+2; count++) { dBaL[count] = 0.0; @@ -43,12 +83,12 @@ ConsoleXChannel::ConsoleXChannel(audioMasterCallback audioMaster) : dBaXL = 1; dBaXR = 1; - trebleGainA = 1.0; trebleGainB = 1.0; - midGainA = 1.0; midGainB = 1.0; - mPeakA = 1.0; mPeakB = 1.0; - bassGainA = 1.0; bassGainB = 1.0; + airGainA = 0.5; airGainB = 0.5; + fireGainA = 0.5; fireGainB = 0.5; + stoneGainA = 0.5; stoneGainB = 0.5; panA = 0.5; panB = 0.5; - inTrimA = 1.0; inTrimB = 1.0; + inTrimA = 1.0; inTrimB = 1.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. @@ -81,70 +121,215 @@ static float pinParameter(float data) void ConsoleXChannel::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; - case kParamF: F = value; break; - case kParamG: G = value; break; - case kParamH: H = value; break; + case kParamHIP: HIP = value; break; + case kParamLOP: LOP = value; break; + case kParamAIR: AIR = value; break; + case kParamFIR: FIR = value; break; + case kParamSTO: STO = value; break; + case kParamRNG: RNG = value; break; + case kParamFCT: FCT = value; break; + case kParamSCT: SCT = value; break; + case kParamFCR: FCR = value; break; + case kParamSCR: SCR = value; break; + case kParamFCA: FCA = value; break; + case kParamSCA: SCA = value; break; + case kParamFCL: FCL = value; break; + case kParamSCL: SCL = value; break; + case kParamFGT: FGT = value; break; + case kParamSGT: SGT = value; break; + case kParamFGR: FGR = value; break; + case kParamSGR: SGR = value; break; + case kParamFGS: FGS = value; break; + case kParamSGS: SGS = value; break; + case kParamFGL: FGL = value; break; + case kParamSGL: SGL = value; break; + case kParamTRF: TRF = value; break; + case kParamTRG: TRG = value; break; + case kParamTRR: TRR = value; break; + case kParamHMF: HMF = value; break; + case kParamHMG: HMG = value; break; + case kParamHMR: HMR = value; break; + case kParamLMF: LMF = value; break; + case kParamLMG: LMG = value; break; + case kParamLMR: LMR = value; break; + case kParamBSF: BSF = value; break; + case kParamBSG: BSG = value; break; + case kParamBSR: BSR = value; break; + case kParamDSC: DSC = value; break; + case kParamPAN: PAN = value; break; + case kParamFAD: FAD = value; break; default: break; // unknown parameter, shouldn't happen! } } float ConsoleXChannel::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; - case kParamF: return F; break; - case kParamG: return G; break; - case kParamH: return H; break; + case kParamHIP: return HIP; break; + case kParamLOP: return LOP; break; + case kParamAIR: return AIR; break; + case kParamFIR: return FIR; break; + case kParamSTO: return STO; break; + case kParamRNG: return RNG; break; + case kParamFCT: return FCT; break; + case kParamSCT: return SCT; break; + case kParamFCR: return FCR; break; + case kParamSCR: return SCR; break; + case kParamFCA: return FCA; break; + case kParamSCA: return SCA; break; + case kParamFCL: return FCL; break; + case kParamSCL: return SCL; break; + case kParamFGT: return FGT; break; + case kParamSGT: return SGT; break; + case kParamFGR: return FGR; break; + case kParamSGR: return SGR; break; + case kParamFGS: return FGS; break; + case kParamSGS: return SGS; break; + case kParamFGL: return FGL; break; + case kParamSGL: return SGL; break; + case kParamTRF: return TRF; break; + case kParamTRG: return TRG; break; + case kParamTRR: return TRR; break; + case kParamHMF: return HMF; break; + case kParamHMG: return HMG; break; + case kParamHMR: return HMR; break; + case kParamLMF: return LMF; break; + case kParamLMG: return LMG; break; + case kParamLMR: return LMR; break; + case kParamBSF: return BSF; break; + case kParamBSG: return BSG; break; + case kParamBSR: return BSR; break; + case kParamDSC: return DSC; break; + case kParamPAN: return PAN; break; + case kParamFAD: return FAD; 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 ConsoleXChannel::getParameterName(VstInt32 index, char *text) { switch (index) { - case kParamA: vst_strncpy (text, "Air", kVstMaxParamStrLen); break; - case kParamB: vst_strncpy (text, "Fire", kVstMaxParamStrLen); break; - case kParamC: vst_strncpy (text, "Stone", kVstMaxParamStrLen); break; - case kParamD: vst_strncpy (text, "Reso", kVstMaxParamStrLen); break; - case kParamE: vst_strncpy (text, "Range", kVstMaxParamStrLen); break; - case kParamF: vst_strncpy (text, "Top dB", kVstMaxParamStrLen); break; - case kParamG: vst_strncpy (text, "Pan", kVstMaxParamStrLen); break; - case kParamH: vst_strncpy (text, "Fader", kVstMaxParamStrLen); break; + case kParamHIP: vst_strncpy (text, "Highpas", kVstMaxParamStrLen); break; + case kParamLOP: vst_strncpy (text, "Lowpass", kVstMaxParamStrLen); break; + case kParamAIR: vst_strncpy (text, "Air", kVstMaxParamStrLen); break; + case kParamFIR: vst_strncpy (text, "Fire", kVstMaxParamStrLen); break; + case kParamSTO: vst_strncpy (text, "Stone", kVstMaxParamStrLen); break; + case kParamRNG: vst_strncpy (text, "Range", kVstMaxParamStrLen); break; + case kParamFCT: vst_strncpy (text, "FC Thrs", kVstMaxParamStrLen); break; + case kParamSCT: vst_strncpy (text, "SC Thrs", kVstMaxParamStrLen); break; + case kParamFCR: vst_strncpy (text, "FC Rati", kVstMaxParamStrLen); break; + case kParamSCR: vst_strncpy (text, "SC Rati", kVstMaxParamStrLen); break; + case kParamFCA: vst_strncpy (text, "FC Atk", kVstMaxParamStrLen); break; + case kParamSCA: vst_strncpy (text, "SC Atk", kVstMaxParamStrLen); break; + case kParamFCL: vst_strncpy (text, "FC Rls", kVstMaxParamStrLen); break; + case kParamSCL: vst_strncpy (text, "SC Rls", kVstMaxParamStrLen); break; + case kParamFGT: vst_strncpy (text, "FG Thrs", kVstMaxParamStrLen); break; + case kParamSGT: vst_strncpy (text, "SG Thrs", kVstMaxParamStrLen); break; + case kParamFGR: vst_strncpy (text, "FG Rati", kVstMaxParamStrLen); break; + case kParamSGR: vst_strncpy (text, "SG Rati", kVstMaxParamStrLen); break; + case kParamFGS: vst_strncpy (text, "FG Sust", kVstMaxParamStrLen); break; + case kParamSGS: vst_strncpy (text, "SG Sust", kVstMaxParamStrLen); break; + case kParamFGL: vst_strncpy (text, "FG Rls", kVstMaxParamStrLen); break; + case kParamSGL: vst_strncpy (text, "SG Rls", kVstMaxParamStrLen); break; + case kParamTRF: vst_strncpy (text, "Tr Freq", kVstMaxParamStrLen); break; + case kParamTRG: vst_strncpy (text, "Treble", kVstMaxParamStrLen); break; + case kParamTRR: vst_strncpy (text, "Tr Reso", kVstMaxParamStrLen); break; + case kParamHMF: vst_strncpy (text, "HM Freq", kVstMaxParamStrLen); break; + case kParamHMG: vst_strncpy (text, "HighMid", kVstMaxParamStrLen); break; + case kParamHMR: vst_strncpy (text, "HM Reso", kVstMaxParamStrLen); break; + case kParamLMF: vst_strncpy (text, "LM Freq", kVstMaxParamStrLen); break; + case kParamLMG: vst_strncpy (text, "LowMid", kVstMaxParamStrLen); break; + case kParamLMR: vst_strncpy (text, "LM Reso", kVstMaxParamStrLen); break; + case kParamBSF: vst_strncpy (text, "Bs Freq", kVstMaxParamStrLen); break; + case kParamBSG: vst_strncpy (text, "Bass", kVstMaxParamStrLen); break; + case kParamBSR: vst_strncpy (text, "Bs Reso", kVstMaxParamStrLen); break; + case kParamDSC: vst_strncpy (text, "Top dB", kVstMaxParamStrLen); break; + case kParamPAN: vst_strncpy (text, "Pan", kVstMaxParamStrLen); break; + case kParamFAD: vst_strncpy (text, "Fader", kVstMaxParamStrLen); break; default: break; // unknown parameter, shouldn't happen! } //this is our labels for displaying in the VST host } void ConsoleXChannel::getParameterDisplay(VstInt32 index, char *text) { switch (index) { - case kParamA: float2string (A, text, kVstMaxParamStrLen); break; - case kParamB: float2string (B, text, kVstMaxParamStrLen); break; - case kParamC: float2string (C, text, kVstMaxParamStrLen); break; - case kParamD: float2string (D, text, kVstMaxParamStrLen); break; - case kParamE: float2string (E, text, kVstMaxParamStrLen); break; - case kParamF: float2string ((F*70.0)+70.0, text, kVstMaxParamStrLen); break; - case kParamG: float2string (G, text, kVstMaxParamStrLen); break; - case kParamH: float2string (H, text, kVstMaxParamStrLen); break; + case kParamHIP: float2string (HIP, text, kVstMaxParamStrLen); break; + case kParamLOP: float2string (LOP, text, kVstMaxParamStrLen); break; + case kParamAIR: float2string (AIR, text, kVstMaxParamStrLen); break; + case kParamFIR: float2string (FIR, text, kVstMaxParamStrLen); break; + case kParamSTO: float2string (STO, text, kVstMaxParamStrLen); break; + case kParamRNG: float2string (RNG, text, kVstMaxParamStrLen); break; + case kParamFCT: float2string (FCT, text, kVstMaxParamStrLen); break; + case kParamSCT: float2string (SCT, text, kVstMaxParamStrLen); break; + case kParamFCR: float2string (FCR, text, kVstMaxParamStrLen); break; + case kParamSCR: float2string (SCR, text, kVstMaxParamStrLen); break; + case kParamFCA: float2string (FCA, text, kVstMaxParamStrLen); break; + case kParamSCA: float2string (SCA, text, kVstMaxParamStrLen); break; + case kParamFCL: float2string (FCL, text, kVstMaxParamStrLen); break; + case kParamSCL: float2string (SCL, text, kVstMaxParamStrLen); break; + case kParamFGT: float2string (FGT, text, kVstMaxParamStrLen); break; + case kParamSGT: float2string (SGT, text, kVstMaxParamStrLen); break; + case kParamFGR: float2string (FGR, text, kVstMaxParamStrLen); break; + case kParamSGR: float2string (SGR, text, kVstMaxParamStrLen); break; + case kParamFGS: float2string (FGS, text, kVstMaxParamStrLen); break; + case kParamSGS: float2string (SGS, text, kVstMaxParamStrLen); break; + case kParamFGL: float2string (FGL, text, kVstMaxParamStrLen); break; + case kParamSGL: float2string (SGL, text, kVstMaxParamStrLen); break; + case kParamTRF: float2string (TRF, text, kVstMaxParamStrLen); break; + case kParamTRG: float2string (TRG, text, kVstMaxParamStrLen); break; + case kParamTRR: float2string (TRR, text, kVstMaxParamStrLen); break; + case kParamHMF: float2string (HMF, text, kVstMaxParamStrLen); break; + case kParamHMG: float2string (HMG, text, kVstMaxParamStrLen); break; + case kParamHMR: float2string (HMR, text, kVstMaxParamStrLen); break; + case kParamLMF: float2string (LMF, text, kVstMaxParamStrLen); break; + case kParamLMG: float2string (LMG, text, kVstMaxParamStrLen); break; + case kParamLMR: float2string (LMR, text, kVstMaxParamStrLen); break; + case kParamBSF: float2string (BSF, text, kVstMaxParamStrLen); break; + case kParamBSG: float2string (BSG, text, kVstMaxParamStrLen); break; + case kParamBSR: float2string (BSR, text, kVstMaxParamStrLen); break; + case kParamDSC: float2string ((DSC*70.0)+70.0, text, kVstMaxParamStrLen); break; + case kParamPAN: float2string (PAN, text, kVstMaxParamStrLen); break; + case kParamFAD: float2string (FAD, text, kVstMaxParamStrLen); break; default: break; // unknown parameter, shouldn't happen! } //this displays the values and handles 'popups' where it's discrete choices } void ConsoleXChannel::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; - case kParamF: vst_strncpy (text, "dB", kVstMaxParamStrLen); break; - case kParamG: vst_strncpy (text, "", kVstMaxParamStrLen); break; - case kParamH: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamHIP: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamLOP: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamAIR: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamFIR: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamSTO: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamRNG: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamFCT: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamSCT: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamFCR: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamSCR: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamFCA: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamSCA: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamFCL: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamSCL: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamFGT: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamSGT: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamFGR: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamSGR: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamFGS: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamSGS: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamFGL: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamSGL: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamTRF: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamTRG: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamTRR: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamHMF: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamHMG: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamHMR: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamLMF: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamLMG: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamLMR: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamBSF: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamBSG: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamBSR: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamDSC: vst_strncpy (text, "dB", kVstMaxParamStrLen); break; + case kParamPAN: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamFAD: vst_strncpy (text, "", kVstMaxParamStrLen); break; default: break; // unknown parameter, shouldn't happen! } } @@ -167,28 +352,86 @@ bool ConsoleXChannel::getVendorString(char* text) { } bool ConsoleXChannel::parameterTextToValue(VstInt32 index, const char *text, float &value) { switch(index) { - case kParamA: { auto b = string2float(text, value); return b; break; } - case kParamB: { auto b = string2float(text, value); return b; break; } - case kParamC: { auto b = string2float(text, value); return b; break; } - case kParamD: { auto b = string2float(text, value); return b; break; } - case kParamE: { auto b = string2float(text, value); return b; break; } - case kParamF: { auto b = string2float(text, value); if (b) { value = (value - 70.0) / (70.0); } return b; break; } - case kParamG: { auto b = string2float(text, value); return b; break; } - case kParamH: { auto b = string2float(text, value); return b; break; } + case kParamHIP: { auto b = string2float(text, value); return b; break; } + case kParamLOP: { auto b = string2float(text, value); return b; break; } + case kParamAIR: { auto b = string2float(text, value); return b; break; } + case kParamFIR: { auto b = string2float(text, value); return b; break; } + case kParamSTO: { auto b = string2float(text, value); return b; break; } + case kParamRNG: { auto b = string2float(text, value); return b; break; } + case kParamFCT: { auto b = string2float(text, value); return b; break; } + case kParamSCT: { auto b = string2float(text, value); return b; break; } + case kParamFCR: { auto b = string2float(text, value); return b; break; } + case kParamSCR: { auto b = string2float(text, value); return b; break; } + case kParamFCA: { auto b = string2float(text, value); return b; break; } + case kParamSCA: { auto b = string2float(text, value); return b; break; } + case kParamFCL: { auto b = string2float(text, value); return b; break; } + case kParamSCL: { auto b = string2float(text, value); return b; break; } + case kParamFGT: { auto b = string2float(text, value); return b; break; } + case kParamSGT: { auto b = string2float(text, value); return b; break; } + case kParamFGR: { auto b = string2float(text, value); return b; break; } + case kParamSGR: { auto b = string2float(text, value); return b; break; } + case kParamFGS: { auto b = string2float(text, value); return b; break; } + case kParamSGS: { auto b = string2float(text, value); return b; break; } + case kParamFGL: { auto b = string2float(text, value); return b; break; } + case kParamSGL: { auto b = string2float(text, value); return b; break; } + case kParamTRF: { auto b = string2float(text, value); return b; break; } + case kParamTRG: { auto b = string2float(text, value); return b; break; } + case kParamTRR: { auto b = string2float(text, value); return b; break; } + case kParamHMF: { auto b = string2float(text, value); return b; break; } + case kParamHMG: { auto b = string2float(text, value); return b; break; } + case kParamHMR: { auto b = string2float(text, value); return b; break; } + case kParamLMF: { auto b = string2float(text, value); return b; break; } + case kParamLMG: { auto b = string2float(text, value); return b; break; } + case kParamLMR: { auto b = string2float(text, value); return b; break; } + case kParamBSF: { auto b = string2float(text, value); return b; break; } + case kParamBSG: { auto b = string2float(text, value); return b; break; } + case kParamBSR: { auto b = string2float(text, value); return b; break; } + case kParamDSC: { auto b = string2float(text, value); if (b) { value = (value - 70.0) / (70.0); } return b; break; } + case kParamPAN: { auto b = string2float(text, value); return b; break; } + case kParamFAD: { auto b = string2float(text, value); return b; break; } } return false; } bool ConsoleXChannel::canConvertParameterTextToValue(VstInt32 index) { switch(index) { - case kParamA: return true; - case kParamB: return true; - case kParamC: return true; - case kParamD: return true; - case kParamE: return true; - case kParamF: return true; - case kParamG: return true; - case kParamH: return true; + case kParamHIP: return true; + case kParamLOP: return true; + case kParamAIR: return true; + case kParamFIR: return true; + case kParamSTO: return true; + case kParamRNG: return true; + case kParamFCT: return true; + case kParamSCT: return true; + case kParamFCR: return true; + case kParamSCR: return true; + case kParamFCA: return true; + case kParamSCA: return true; + case kParamFCL: return true; + case kParamSCL: return true; + case kParamFGT: return true; + case kParamSGT: return true; + case kParamFGR: return true; + case kParamSGR: return true; + case kParamFGS: return true; + case kParamSGS: return true; + case kParamFGL: return true; + case kParamSGL: return true; + case kParamTRF: return true; + case kParamTRG: return true; + case kParamTRR: return true; + case kParamHMF: return true; + case kParamHMG: return true; + case kParamHMR: return true; + case kParamLMF: return true; + case kParamLMG: return true; + case kParamLMR: return true; + case kParamBSF: return true; + case kParamBSG: return true; + case kParamBSR: return true; + case kParamDSC: return true; + case kParamPAN: return true; + case kParamFAD: return true; } return false; diff --git a/src/autogen_airwin/ConsoleXChannel.h b/src/autogen_airwin/ConsoleXChannel.h index eb0e90f..300c0bd 100644 --- a/src/autogen_airwin/ConsoleXChannel.h +++ b/src/autogen_airwin/ConsoleXChannel.h @@ -17,15 +17,44 @@ namespace airwinconsolidated::ConsoleXChannel { enum { - kParamA = 0, - kParamB = 1, - kParamC = 2, - kParamD = 3, - kParamE = 4, - kParamF = 5, - kParamG = 6, - kParamH = 7, - kNumParameters = 8 + kParamHIP = 0, + kParamLOP = 1, + kParamAIR = 2, + kParamFIR = 3, + kParamSTO = 4, + kParamRNG = 5, + kParamFCT = 6, + kParamSCT = 7, + kParamFCR = 8, + kParamSCR = 9, + kParamFCA = 10, + kParamSCA = 11, + kParamFCL = 12, + kParamSCL = 13, + kParamFGT = 14, + kParamSGT = 15, + kParamFGR = 16, + kParamSGR = 17, + kParamFGS = 18, + kParamSGS = 19, + kParamFGL = 20, + kParamSGL = 21, + kParamTRF = 22, + kParamTRG = 23, + kParamTRR = 24, + kParamHMF = 25, + kParamHMG = 26, + kParamHMR = 27, + kParamLMF = 28, + kParamLMG = 29, + kParamLMR = 30, + kParamBSF = 31, + kParamBSG = 32, + kParamBSR = 33, + kParamDSC = 34, + kParamPAN = 35, + kParamFAD = 36, + kNumParameters = 37 }; // const int dscBuf = 90; @@ -62,96 +91,112 @@ class ConsoleXChannel : char _programName[kVstMaxProgNameLen + 1]; std::set< std::string > _canDo; - uint32_t fpdL; - uint32_t fpdR; - //default stuff - + float HIP; + float LOP; + float AIR; + float FIR; + float STO; + float RNG; + float FCT; + float SCT; + float FCR; + float SCR; + float FCA; + float SCA; + float FCL; + float SCL; + float FGT; + float SGT; + float FGR; + float SGR; + float FGS; + float SGS; + float FGL; + float SGL; + float TRF; + float TRG; + float TRR; + float HMF; + float HMG; + float HMR; + float LMF; + float LMG; + float LMR; + float BSF; + float BSG; + float BSR; + float DSC; + float PAN; + float FAD; + enum { - biq_freq, - biq_reso, - biq_a0, - biq_a1, - biq_a2, - biq_b1, - biq_b2, - biq_sL1, - biq_sL2, - biq_sR1, - biq_sR2, - biq_total + hilp_freq, hilp_temp, + hilp_a0, hilp_a1, hilp_b1, hilp_b2, + hilp_c0, hilp_c1, hilp_d1, hilp_d2, + hilp_e0, hilp_e1, hilp_f1, hilp_f2, + hilp_aL1, hilp_aL2, hilp_aR1, hilp_aR2, + hilp_cL1, hilp_cL2, hilp_cR1, hilp_cR2, + hilp_eL1, hilp_eL2, hilp_eR1, hilp_eR2, + hilp_total }; - double biquad[biq_total]; + double highpass[hilp_total]; + double lowpass[hilp_total]; enum { - pvAL1, - pvSL1, - accSL1, - acc2SL1, - pvAL2, - pvSL2, - accSL2, - acc2SL2, - pvAL3, - pvSL3, - accSL3, - pvAL4, - pvSL4, - gndavgL, - outAL, - gainAL, - pvAR1, - pvSR1, - accSR1, - acc2SR1, - pvAR2, - pvSR2, - accSR2, - acc2SR2, - pvAR3, - pvSR3, - accSR3, - pvAR4, - pvSR4, - gndavgR, - outAR, - gainAR, + pvAL1, pvSL1, accSL1, acc2SL1, + pvAL2, pvSL2, accSL2, acc2SL2, + pvAL3, pvSL3, accSL3, + pvAL4, pvSL4, + gndavgL, outAL, gainAL, + pvAR1, pvSR1, accSR1, acc2SR1, + pvAR2, pvSR2, accSR2, acc2SR2, + pvAR3, pvSR3, accSR3, + pvAR4, pvSR4, + gndavgR, outAR, gainAR, air_total }; double air[air_total]; enum { - prevSampL1, - prevSlewL1, - accSlewL1, - prevSampL2, - prevSlewL2, - accSlewL2, - prevSampL3, - prevSlewL3, - accSlewL3, - kalGainL, - kalOutL, - prevSampR1, - prevSlewR1, - accSlewR1, - prevSampR2, - prevSlewR2, - accSlewR2, - prevSampR3, - prevSlewR3, - accSlewR3, - kalGainR, - kalOutR, + prevSampL1, prevSlewL1, accSlewL1, + prevSampL2, prevSlewL2, accSlewL2, + prevSampL3, prevSlewL3, accSlewL3, + kalGainL, kalOutL, + prevSampR1, prevSlewR1, accSlewR1, + prevSampR2, prevSlewR2, accSlewR2, + prevSampR3, prevSlewR3, accSlewR3, + kalGainR, kalOutR, kal_total }; double kal[kal_total]; + double fireCompL; + double fireCompR; + double fireGate; + double stoneCompL; + double stoneCompR; + double stoneGate; + double airGainA; + double airGainB; + double fireGainA; + double fireGainB; + double stoneGainA; + double stoneGainB; - double mpkL[2005]; - double mpkR[2005]; - double f[66]; - double prevfreqMPeak; - double prevamountMPeak; - int mpc; + enum { + biqs_freq, biqs_reso, biqs_level, + biqs_nonlin, biqs_temp, biqs_dis, + biqs_a0, biqs_a1, biqs_b1, biqs_b2, + biqs_c0, biqs_c1, biqs_d1, biqs_d2, + biqs_e0, biqs_e1, biqs_f1, biqs_f2, + biqs_aL1, biqs_aL2, biqs_aR1, biqs_aR2, + biqs_cL1, biqs_cL2, biqs_cR1, biqs_cR2, + biqs_eL1, biqs_eL2, biqs_eR1, biqs_eR2, + biqs_outL, biqs_outR, biqs_total + }; + double high[biqs_total]; + double hmid[biqs_total]; + double lmid[biqs_total]; + double bass[biqs_total]; double dBaL[dscBuf+5]; double dBaR[dscBuf+5]; @@ -160,27 +205,14 @@ class ConsoleXChannel : int dBaXL; int dBaXR; - double trebleGainA; - double trebleGainB; - double midGainA; - double midGainB; - double mPeakA; - double mPeakB; - double bassGainA; - double bassGainB; double panA; double panB; double inTrimA; double inTrimB; - - float A; - float B; - float C; - float D; - float E; - float F; - float G; - float H; + + uint32_t fpdL; + uint32_t fpdR; + //default stuff }; #endif diff --git a/src/autogen_airwin/ConsoleXChannelProc.cpp b/src/autogen_airwin/ConsoleXChannelProc.cpp index 2e01c0c..d4e1f3f 100644 --- a/src/autogen_airwin/ConsoleXChannelProc.cpp +++ b/src/autogen_airwin/ConsoleXChannelProc.cpp @@ -19,48 +19,160 @@ void ConsoleXChannel::processReplacing(float **inputs, float **outputs, VstInt32 double overallscale = 1.0; overallscale /= 44100.0; overallscale *= getSampleRate(); - int cycleEnd = floor(overallscale); - if (cycleEnd < 1) cycleEnd = 1; - if (cycleEnd > 3) cycleEnd = 3; - biquad[biq_freq] = 25000.0/getSampleRate(); - biquad[biq_reso] = 0.50979558; - double K = tan(M_PI * biquad[biq_freq]); - double norm = 1.0 / (1.0 + K / biquad[biq_reso] + K * K); - biquad[biq_a0] = K * K * norm; - biquad[biq_a1] = 2.0 * biquad[biq_a0]; - biquad[biq_a2] = biquad[biq_a0]; - biquad[biq_b1] = 2.0 * (K * K - 1.0) * norm; - biquad[biq_b2] = (1.0 - K / biquad[biq_reso] + K * K) * norm; - //ultrasonic nonlinear filter + highpass[hilp_freq] = ((HIP*330.0)+20.0)/getSampleRate(); + bool highpassEngage = true; if (HIP == 0.0) highpassEngage = false; - trebleGainA = trebleGainB; trebleGainB = A*2.0; - midGainA = midGainB; midGainB = B*2.0; - bassGainA = bassGainB; bassGainB = C*2.0; - //simple three band to adjust + lowpass[hilp_freq] = ((pow(1.0-LOP,2)*17000.0)+3000.0)/getSampleRate(); + bool lowpassEngage = true; if (LOP == 0.0) lowpassEngage = false; - //begin ResEQ2 Mid Boost - double freqMPeak = pow(D+0.16,3); - mPeakA = mPeakB; mPeakB = fabs(midGainB-1.0); //amount of mid peak leak through (or boost) - if (midGainB < 1.0) mPeakB *= 0.5; - int maxMPeak = (24.0*(2.0-freqMPeak))+16; - if ((freqMPeak != prevfreqMPeak)||(mPeakB != prevamountMPeak)) { - for (int x = 0; x < maxMPeak; x++) { - if (((double)x*freqMPeak) < M_PI_4) f[x] = sin(((double)x*freqMPeak)*4.0)*freqMPeak*sin(((double)(maxMPeak-x)/(double)maxMPeak)*M_PI_2); - else f[x] = cos((double)x*freqMPeak)*freqMPeak*sin(((double)(maxMPeak-x)/(double)maxMPeak)*M_PI_2); - } - prevfreqMPeak = freqMPeak; prevamountMPeak = mPeakB; - }//end ResEQ2 Mid Boost - //mid peak for either retaining during mid cut, or adding during mid boost + double K = tan(M_PI * highpass[hilp_freq]); //highpass + double norm = 1.0 / (1.0 + K / 1.93185165 + K * K); + highpass[hilp_a0] = norm; + highpass[hilp_a1] = -2.0 * highpass[hilp_a0]; + highpass[hilp_b1] = 2.0 * (K * K - 1.0) * norm; + highpass[hilp_b2] = (1.0 - K / 1.93185165 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.70710678 + K * K); + highpass[hilp_c0] = norm; + highpass[hilp_c1] = -2.0 * highpass[hilp_c0]; + highpass[hilp_d1] = 2.0 * (K * K - 1.0) * norm; + highpass[hilp_d2] = (1.0 - K / 0.70710678 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.51763809 + K * K); + highpass[hilp_e0] = norm; + highpass[hilp_e1] = -2.0 * highpass[hilp_e0]; + highpass[hilp_f1] = 2.0 * (K * K - 1.0) * norm; + highpass[hilp_f2] = (1.0 - K / 0.51763809 + K * K) * norm; - double kalman = 1.0-pow(E,2); + K = tan(M_PI * lowpass[hilp_freq]); //lowpass + norm = 1.0 / (1.0 + K / 1.93185165 + K * K); + lowpass[hilp_a0] = K * K * norm; + lowpass[hilp_a1] = 2.0 * lowpass[hilp_a0]; + lowpass[hilp_b1] = 2.0 * (K * K - 1.0) * norm; + lowpass[hilp_b2] = (1.0 - K / 1.93185165 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.70710678 + K * K); + lowpass[hilp_c0] = K * K * norm; + lowpass[hilp_c1] = 2.0 * lowpass[hilp_c0]; + lowpass[hilp_d1] = 2.0 * (K * K - 1.0) * norm; + lowpass[hilp_d2] = (1.0 - K / 0.70710678 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.51763809 + K * K); + lowpass[hilp_e0] = K * K * norm; + lowpass[hilp_e1] = 2.0 * lowpass[hilp_e0]; + lowpass[hilp_f1] = 2.0 * (K * K - 1.0) * norm; + lowpass[hilp_f2] = (1.0 - K / 0.51763809 + K * K) * norm; + + airGainA = airGainB; airGainB = AIR *2.0; + fireGainA = fireGainB; fireGainB = FIR *2.0; + stoneGainA = stoneGainB; stoneGainB = STO *2.0; + //simple three band to adjust + double kalmanRange = 1.0-pow(RNG,2); //crossover frequency between mid/bass - double refdB = (F*70.0)+70.0; + double compFThresh = pow(FCT,4); + double compSThresh = pow(SCT,4); + double compFRatio = 1.0-pow(1.0-FCR,2); + double compSRatio = 1.0-pow(1.0-SCR,2); + double compFAttack = 1.0/(((pow(FCA,3)*5000.0)+500.0)*overallscale); + double compSAttack = 1.0/(((pow(SCA,3)*5000.0)+500.0)*overallscale); + double compFRelease = 1.0/(((pow(FCL,5)*50000.0)+500.0)*overallscale); + double compSRelease = 1.0/(((pow(SCL,5)*50000.0)+500.0)*overallscale); + double gateFThresh = pow(FGT,4); + double gateSThresh = pow(SGT,4); + double gateFRatio = 1.0-pow(1.0-FGR,2); + double gateSRatio = 1.0-pow(1.0-SGR,2); + double gateFSustain = M_PI_2 * pow(FGS+1.0,4.0); + double gateSSustain = M_PI_2 * pow(SGS+1.0,4.0); + double gateFRelease = 1.0/(((pow(FGL,5)*500000.0)+500.0)*overallscale); + double gateSRelease = 1.0/(((pow(SGL,5)*500000.0)+500.0)*overallscale); + + high[biqs_freq] = (((pow(TRF,3)*14500.0)+1500.0)/getSampleRate()); + if (high[biqs_freq] < 0.0001) high[biqs_freq] = 0.0001; + high[biqs_nonlin] = TRG; + high[biqs_level] = (high[biqs_nonlin]*2.0)-1.0; + if (high[biqs_level] > 0.0) high[biqs_level] *= 2.0; + high[biqs_reso] = ((0.5+(high[biqs_nonlin]*0.5)+sqrt(high[biqs_freq]))-(1.0-pow(1.0-TRR,2.0)))+0.5+(high[biqs_nonlin]*0.5); + K = tan(M_PI * high[biqs_freq]); + norm = 1.0 / (1.0 + K / (high[biqs_reso]*1.93185165) + K * K); + high[biqs_a0] = K / (high[biqs_reso]*1.93185165) * norm; + high[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + high[biqs_b2] = (1.0 - K / (high[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (high[biqs_reso]*0.70710678) + K * K); + high[biqs_c0] = K / (high[biqs_reso]*0.70710678) * norm; + high[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + high[biqs_d2] = (1.0 - K / (high[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (high[biqs_reso]*0.51763809) + K * K); + high[biqs_e0] = K / (high[biqs_reso]*0.51763809) * norm; + high[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + high[biqs_f2] = (1.0 - K / (high[biqs_reso]*0.51763809) + K * K) * norm; + //high + + hmid[biqs_freq] = (((pow(HMF,3)*6400.0)+600.0)/getSampleRate()); + if (hmid[biqs_freq] < 0.0001) hmid[biqs_freq] = 0.0001; + hmid[biqs_nonlin] = HMG; + hmid[biqs_level] = (hmid[biqs_nonlin]*2.0)-1.0; + if (hmid[biqs_level] > 0.0) hmid[biqs_level] *= 2.0; + hmid[biqs_reso] = ((0.5+(hmid[biqs_nonlin]*0.5)+sqrt(hmid[biqs_freq]))-(1.0-pow(1.0-HMR,2.0)))+0.5+(hmid[biqs_nonlin]*0.5); + K = tan(M_PI * hmid[biqs_freq]); + norm = 1.0 / (1.0 + K / (hmid[biqs_reso]*1.93185165) + K * K); + hmid[biqs_a0] = K / (hmid[biqs_reso]*1.93185165) * norm; + hmid[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + hmid[biqs_b2] = (1.0 - K / (hmid[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (hmid[biqs_reso]*0.70710678) + K * K); + hmid[biqs_c0] = K / (hmid[biqs_reso]*0.70710678) * norm; + hmid[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + hmid[biqs_d2] = (1.0 - K / (hmid[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (hmid[biqs_reso]*0.51763809) + K * K); + hmid[biqs_e0] = K / (hmid[biqs_reso]*0.51763809) * norm; + hmid[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + hmid[biqs_f2] = (1.0 - K / (hmid[biqs_reso]*0.51763809) + K * K) * norm; + //hmid + + lmid[biqs_freq] = (((pow(LMF,3)*2200.0)+200.0)/getSampleRate()); + if (lmid[biqs_freq] < 0.0001) lmid[biqs_freq] = 0.0001; + lmid[biqs_nonlin] = LMG; + lmid[biqs_level] = (lmid[biqs_nonlin]*2.0)-1.0; + if (lmid[biqs_level] > 0.0) lmid[biqs_level] *= 2.0; + lmid[biqs_reso] = ((0.5+(lmid[biqs_nonlin]*0.5)+sqrt(lmid[biqs_freq]))-(1.0-pow(1.0-LMR,2.0)))+0.5+(lmid[biqs_nonlin]*0.5); + K = tan(M_PI * lmid[biqs_freq]); + norm = 1.0 / (1.0 + K / (lmid[biqs_reso]*1.93185165) + K * K); + lmid[biqs_a0] = K / (lmid[biqs_reso]*1.93185165) * norm; + lmid[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + lmid[biqs_b2] = (1.0 - K / (lmid[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (lmid[biqs_reso]*0.70710678) + K * K); + lmid[biqs_c0] = K / (lmid[biqs_reso]*0.70710678) * norm; + lmid[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + lmid[biqs_d2] = (1.0 - K / (lmid[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (lmid[biqs_reso]*0.51763809) + K * K); + lmid[biqs_e0] = K / (lmid[biqs_reso]*0.51763809) * norm; + lmid[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + lmid[biqs_f2] = (1.0 - K / (lmid[biqs_reso]*0.51763809) + K * K) * norm; + //lmid + + bass[biqs_freq] = (((pow(BSF,3)*570.0)+30.0)/getSampleRate()); + if (bass[biqs_freq] < 0.0001) bass[biqs_freq] = 0.0001; + bass[biqs_nonlin] = BSG; + bass[biqs_level] = (bass[biqs_nonlin]*2.0)-1.0; + if (bass[biqs_level] > 0.0) bass[biqs_level] *= 2.0; + bass[biqs_reso] = ((0.5+(bass[biqs_nonlin]*0.5)+sqrt(bass[biqs_freq]))-(1.0-pow(1.0-BSR,2.0)))+0.5+(bass[biqs_nonlin]*0.5); + K = tan(M_PI * bass[biqs_freq]); + norm = 1.0 / (1.0 + K / (bass[biqs_reso]*1.93185165) + K * K); + bass[biqs_a0] = K / (bass[biqs_reso]*1.93185165) * norm; + bass[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + bass[biqs_b2] = (1.0 - K / (bass[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (bass[biqs_reso]*0.70710678) + K * K); + bass[biqs_c0] = K / (bass[biqs_reso]*0.70710678) * norm; + bass[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + bass[biqs_d2] = (1.0 - K / (bass[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (bass[biqs_reso]*0.51763809) + K * K); + bass[biqs_e0] = K / (bass[biqs_reso]*0.51763809) * norm; + bass[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + bass[biqs_f2] = (1.0 - K / (bass[biqs_reso]*0.51763809) + K * K) * norm; + //bass + + double refdB = (DSC*70.0)+70.0; double topdB = 0.000000075 * pow(10.0,refdB/20.0) * overallscale; - panA = panB; panB = G*1.57079633; - inTrimA = inTrimB; inTrimB = H*2.0; + panA = panB; panB = PAN*1.57079633; + inTrimA = inTrimB; inTrimB = FAD*2.0; while (--sampleFrames >= 0) { @@ -68,47 +180,225 @@ void ConsoleXChannel::processReplacing(float **inputs, float **outputs, VstInt32 double inputSampleR = *in2; if (fabs(inputSampleL)<1.18e-23) inputSampleL = fpdL * 1.18e-17; if (fabs(inputSampleR)<1.18e-23) inputSampleR = fpdR * 1.18e-17; - double drySampleL = inputSampleL; - double drySampleR = inputSampleR; - if (biquad[biq_freq] < 0.5) { - double nlBiq = fabs(biquad[biq_a0]*(1.0+(inputSampleL*0.25))); if (nlBiq > 1.0) nlBiq = 1.0; - double tmp = (inputSampleL * nlBiq) + biquad[biq_sL1]; - biquad[biq_sL1] = (inputSampleL * biquad[biq_a1]) - (tmp * biquad[biq_b1]) + biquad[biq_sL2]; - biquad[biq_sL2] = (inputSampleL * nlBiq) - (tmp * biquad[biq_b2]); - inputSampleL = tmp; - nlBiq = fabs(biquad[biq_a0]*(1.0+(inputSampleR*0.25))); if (nlBiq > 1.0) nlBiq = 1.0; - tmp = (inputSampleR * nlBiq) + biquad[biq_sR1]; - biquad[biq_sR1] = (inputSampleR * biquad[biq_a1]) - (tmp * biquad[biq_b1]) + biquad[biq_sR2]; - biquad[biq_sR2] = (inputSampleR * nlBiq) - (tmp * biquad[biq_b2]); - inputSampleR = tmp; - //ultrasonic filter before anything else is done - } + if (highpassEngage) { //distributed Highpass + highpass[hilp_temp] = (inputSampleL*highpass[hilp_a0])+highpass[hilp_aL1]; + highpass[hilp_aL1] = (inputSampleL*highpass[hilp_a1])-(highpass[hilp_temp]*highpass[hilp_b1])+highpass[hilp_aL2]; + highpass[hilp_aL2] = (inputSampleL*highpass[hilp_a0])-(highpass[hilp_temp]*highpass[hilp_b2]); inputSampleL = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleR*highpass[hilp_a0])+highpass[hilp_aR1]; + highpass[hilp_aR1] = (inputSampleR*highpass[hilp_a1])-(highpass[hilp_temp]*highpass[hilp_b1])+highpass[hilp_aR2]; + highpass[hilp_aR2] = (inputSampleR*highpass[hilp_a0])-(highpass[hilp_temp]*highpass[hilp_b2]); inputSampleR = highpass[hilp_temp]; + } else highpass[hilp_aR1] = highpass[hilp_aR2] = highpass[hilp_aL1] = highpass[hilp_aL2] = 0.0; + if (lowpassEngage) { //distributed Lowpass + lowpass[hilp_temp] = (inputSampleL*lowpass[hilp_a0])+lowpass[hilp_aL1]; + lowpass[hilp_aL1] = (inputSampleL*lowpass[hilp_a1])-(lowpass[hilp_temp]*lowpass[hilp_b1])+lowpass[hilp_aL2]; + lowpass[hilp_aL2] = (inputSampleL*lowpass[hilp_a0])-(lowpass[hilp_temp]*lowpass[hilp_b2]); inputSampleL = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleR*lowpass[hilp_a0])+lowpass[hilp_aR1]; + lowpass[hilp_aR1] = (inputSampleR*lowpass[hilp_a1])-(lowpass[hilp_temp]*lowpass[hilp_b1])+lowpass[hilp_aR2]; + lowpass[hilp_aR2] = (inputSampleR*lowpass[hilp_a0])-(lowpass[hilp_temp]*lowpass[hilp_b2]); inputSampleR = lowpass[hilp_temp]; + } else lowpass[hilp_aR1] = lowpass[hilp_aR2] = lowpass[hilp_aL1] = lowpass[hilp_aL2] = 0.0; + //first Highpass/Lowpass blocks aliasing before the nonlinearity of ConsoleXBuss and Parametric + + //get all Parametric bands before any other processing is done + //begin Stacked Biquad With Reversed Neutron Flow L + high[biqs_outL] = inputSampleL * fabs(high[biqs_level]); + high[biqs_dis] = fabs(high[biqs_a0] * (1.0+(high[biqs_outL]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outL] * high[biqs_dis]) + high[biqs_aL1]; + high[biqs_aL1] = high[biqs_aL2] - (high[biqs_temp]*high[biqs_b1]); + high[biqs_aL2] = (high[biqs_outL] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_b2]); + high[biqs_outL] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_c0] * (1.0+(high[biqs_outL]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outL] * high[biqs_dis]) + high[biqs_cL1]; + high[biqs_cL1] = high[biqs_cL2] - (high[biqs_temp]*high[biqs_d1]); + high[biqs_cL2] = (high[biqs_outL] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_d2]); + high[biqs_outL] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_e0] * (1.0+(high[biqs_outL]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outL] * high[biqs_dis]) + high[biqs_eL1]; + high[biqs_eL1] = high[biqs_eL2] - (high[biqs_temp]*high[biqs_f1]); + high[biqs_eL2] = (high[biqs_outL] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_f2]); + high[biqs_outL] = high[biqs_temp]; high[biqs_outL] *= high[biqs_level]; + if (high[biqs_level] > 1.0) high[biqs_outL] *= high[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L - double temp = (double)sampleFrames/inFramesToProcess; - double trebleGain = (trebleGainA*temp)+(trebleGainB*(1.0-temp)); - if (trebleGain > 1.0) trebleGain = pow(trebleGain,3.0+sqrt(overallscale)); - if (trebleGain < 1.0) trebleGain = 1.0-pow(1.0-trebleGain,2); + //begin Stacked Biquad With Reversed Neutron Flow L + hmid[biqs_outL] = inputSampleL * fabs(hmid[biqs_level]); + hmid[biqs_dis] = fabs(hmid[biqs_a0] * (1.0+(hmid[biqs_outL]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outL] * hmid[biqs_dis]) + hmid[biqs_aL1]; + hmid[biqs_aL1] = hmid[biqs_aL2] - (hmid[biqs_temp]*hmid[biqs_b1]); + hmid[biqs_aL2] = (hmid[biqs_outL] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_b2]); + hmid[biqs_outL] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_c0] * (1.0+(hmid[biqs_outL]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outL] * hmid[biqs_dis]) + hmid[biqs_cL1]; + hmid[biqs_cL1] = hmid[biqs_cL2] - (hmid[biqs_temp]*hmid[biqs_d1]); + hmid[biqs_cL2] = (hmid[biqs_outL] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_d2]); + hmid[biqs_outL] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_e0] * (1.0+(hmid[biqs_outL]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outL] * hmid[biqs_dis]) + hmid[biqs_eL1]; + hmid[biqs_eL1] = hmid[biqs_eL2] - (hmid[biqs_temp]*hmid[biqs_f1]); + hmid[biqs_eL2] = (hmid[biqs_outL] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_f2]); + hmid[biqs_outL] = hmid[biqs_temp]; hmid[biqs_outL] *= hmid[biqs_level]; + if (hmid[biqs_level] > 1.0) hmid[biqs_outL] *= hmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L + + //begin Stacked Biquad With Reversed Neutron Flow L + lmid[biqs_outL] = inputSampleL * fabs(lmid[biqs_level]); + lmid[biqs_dis] = fabs(lmid[biqs_a0] * (1.0+(lmid[biqs_outL]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outL] * lmid[biqs_dis]) + lmid[biqs_aL1]; + lmid[biqs_aL1] = lmid[biqs_aL2] - (lmid[biqs_temp]*lmid[biqs_b1]); + lmid[biqs_aL2] = (lmid[biqs_outL] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_b2]); + lmid[biqs_outL] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_c0] * (1.0+(lmid[biqs_outL]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outL] * lmid[biqs_dis]) + lmid[biqs_cL1]; + lmid[biqs_cL1] = lmid[biqs_cL2] - (lmid[biqs_temp]*lmid[biqs_d1]); + lmid[biqs_cL2] = (lmid[biqs_outL] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_d2]); + lmid[biqs_outL] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_e0] * (1.0+(lmid[biqs_outL]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outL] * lmid[biqs_dis]) + lmid[biqs_eL1]; + lmid[biqs_eL1] = lmid[biqs_eL2] - (lmid[biqs_temp]*lmid[biqs_f1]); + lmid[biqs_eL2] = (lmid[biqs_outL] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_f2]); + lmid[biqs_outL] = lmid[biqs_temp]; lmid[biqs_outL] *= lmid[biqs_level]; + if (lmid[biqs_level] > 1.0) lmid[biqs_outL] *= lmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L + + //begin Stacked Biquad With Reversed Neutron Flow L + bass[biqs_outL] = inputSampleL * fabs(bass[biqs_level]); + bass[biqs_dis] = fabs(bass[biqs_a0] * (1.0+(bass[biqs_outL]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outL] * bass[biqs_dis]) + bass[biqs_aL1]; + bass[biqs_aL1] = bass[biqs_aL2] - (bass[biqs_temp]*bass[biqs_b1]); + bass[biqs_aL2] = (bass[biqs_outL] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_b2]); + bass[biqs_outL] = bass[biqs_temp]; + bass[biqs_dis] = fabs(bass[biqs_c0] * (1.0+(bass[biqs_outL]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outL] * bass[biqs_dis]) + bass[biqs_cL1]; + bass[biqs_cL1] = bass[biqs_cL2] - (bass[biqs_temp]*bass[biqs_d1]); + bass[biqs_cL2] = (bass[biqs_outL] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_d2]); + bass[biqs_outL] = bass[biqs_temp]; + bass[biqs_dis] = fabs(bass[biqs_e0] * (1.0+(bass[biqs_outL]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outL] * bass[biqs_dis]) + bass[biqs_eL1]; + bass[biqs_eL1] = bass[biqs_eL2] - (bass[biqs_temp]*bass[biqs_f1]); + bass[biqs_eL2] = (bass[biqs_outL] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_f2]); + bass[biqs_outL] = bass[biqs_temp]; bass[biqs_outL] *= bass[biqs_level]; + if (bass[biqs_level] > 1.0) bass[biqs_outL] *= bass[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L - double midGain = (midGainA*temp)+(midGainB*(1.0-temp)); - if (midGain > 1.0) midGain = 1.0; - if (midGain < 1.0) midGain = 1.0-pow(1.0-midGain,2); - double mPeak = pow((mPeakA*temp)+(mPeakB*(1.0-temp)),2); + //begin Stacked Biquad With Reversed Neutron Flow R + high[biqs_outR] = inputSampleR * fabs(high[biqs_level]); + high[biqs_dis] = fabs(high[biqs_a0] * (1.0+(high[biqs_outR]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outR] * high[biqs_dis]) + high[biqs_aR1]; + high[biqs_aR1] = high[biqs_aR2] - (high[biqs_temp]*high[biqs_b1]); + high[biqs_aR2] = (high[biqs_outR] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_b2]); + high[biqs_outR] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_c0] * (1.0+(high[biqs_outR]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outR] * high[biqs_dis]) + high[biqs_cR1]; + high[biqs_cR1] = high[biqs_cR2] - (high[biqs_temp]*high[biqs_d1]); + high[biqs_cR2] = (high[biqs_outR] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_d2]); + high[biqs_outR] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_e0] * (1.0+(high[biqs_outR]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outR] * high[biqs_dis]) + high[biqs_eR1]; + high[biqs_eR1] = high[biqs_eR2] - (high[biqs_temp]*high[biqs_f1]); + high[biqs_eR2] = (high[biqs_outR] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_f2]); + high[biqs_outR] = high[biqs_temp]; high[biqs_outR] *= high[biqs_level]; + if (high[biqs_level] > 1.0) high[biqs_outR] *= high[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R - double bassGain = (bassGainA*temp)+(bassGainB*(1.0-temp)); - if (bassGain > 1.0) bassGain *= bassGain; - if (bassGain < 1.0) bassGain = 1.0-pow(1.0-bassGain,2); + //begin Stacked Biquad With Reversed Neutron Flow R + hmid[biqs_outR] = inputSampleR * fabs(hmid[biqs_level]); + hmid[biqs_dis] = fabs(hmid[biqs_a0] * (1.0+(hmid[biqs_outR]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outR] * hmid[biqs_dis]) + hmid[biqs_aR1]; + hmid[biqs_aR1] = hmid[biqs_aR2] - (hmid[biqs_temp]*hmid[biqs_b1]); + hmid[biqs_aR2] = (hmid[biqs_outR] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_b2]); + hmid[biqs_outR] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_c0] * (1.0+(hmid[biqs_outR]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outR] * hmid[biqs_dis]) + hmid[biqs_cR1]; + hmid[biqs_cR1] = hmid[biqs_cR2] - (hmid[biqs_temp]*hmid[biqs_d1]); + hmid[biqs_cR2] = (hmid[biqs_outR] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_d2]); + hmid[biqs_outR] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_e0] * (1.0+(hmid[biqs_outR]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outR] * hmid[biqs_dis]) + hmid[biqs_eR1]; + hmid[biqs_eR1] = hmid[biqs_eR2] - (hmid[biqs_temp]*hmid[biqs_f1]); + hmid[biqs_eR2] = (hmid[biqs_outR] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_f2]); + hmid[biqs_outR] = hmid[biqs_temp]; hmid[biqs_outR] *= hmid[biqs_level]; + if (hmid[biqs_level] > 1.0) hmid[biqs_outR] *= hmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R + //begin Stacked Biquad With Reversed Neutron Flow R + lmid[biqs_outR] = inputSampleR * fabs(lmid[biqs_level]); + lmid[biqs_dis] = fabs(lmid[biqs_a0] * (1.0+(lmid[biqs_outR]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outR] * lmid[biqs_dis]) + lmid[biqs_aR1]; + lmid[biqs_aR1] = lmid[biqs_aR2] - (lmid[biqs_temp]*lmid[biqs_b1]); + lmid[biqs_aR2] = (lmid[biqs_outR] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_b2]); + lmid[biqs_outR] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_c0] * (1.0+(lmid[biqs_outR]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outR] * lmid[biqs_dis]) + lmid[biqs_cR1]; + lmid[biqs_cR1] = lmid[biqs_cR2] - (lmid[biqs_temp]*lmid[biqs_d1]); + lmid[biqs_cR2] = (lmid[biqs_outR] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_d2]); + lmid[biqs_outR] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_e0] * (1.0+(lmid[biqs_outR]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outR] * lmid[biqs_dis]) + lmid[biqs_eR1]; + lmid[biqs_eR1] = lmid[biqs_eR2] - (lmid[biqs_temp]*lmid[biqs_f1]); + lmid[biqs_eR2] = (lmid[biqs_outR] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_f2]); + lmid[biqs_outR] = lmid[biqs_temp]; lmid[biqs_outR] *= lmid[biqs_level]; + if (lmid[biqs_level] > 1.0) lmid[biqs_outR] *= lmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R + + //begin Stacked Biquad With Reversed Neutron Flow R + bass[biqs_outR] = inputSampleR * fabs(bass[biqs_level]); + bass[biqs_dis] = fabs(bass[biqs_a0] * (1.0+(bass[biqs_outR]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outR] * bass[biqs_dis]) + bass[biqs_aR1]; + bass[biqs_aR1] = bass[biqs_aR2] - (bass[biqs_temp]*bass[biqs_b1]); + bass[biqs_aR2] = (bass[biqs_outR] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_b2]); + bass[biqs_outR] = bass[biqs_temp]; + bass[biqs_dis] = fabs(bass[biqs_c0] * (1.0+(bass[biqs_outR]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outR] * bass[biqs_dis]) + bass[biqs_cR1]; + bass[biqs_cR1] = bass[biqs_cR2] - (bass[biqs_temp]*bass[biqs_d1]); + bass[biqs_cR2] = (bass[biqs_outR] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_d2]); + bass[biqs_outR] = bass[biqs_temp]; + bass[biqs_dis] = fabs(bass[biqs_e0] * (1.0+(bass[biqs_outR]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outR] * bass[biqs_dis]) + bass[biqs_eR1]; + bass[biqs_eR1] = bass[biqs_eR2] - (bass[biqs_temp]*bass[biqs_f1]); + bass[biqs_eR2] = (bass[biqs_outR] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_f2]); + bass[biqs_outR] = bass[biqs_temp]; bass[biqs_outR] *= bass[biqs_level]; + if (bass[biqs_level] > 1.0) bass[biqs_outR] *= bass[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R + + double temp = (double)sampleFrames/inFramesToProcess; double gainR = (panA*temp)+(panB*(1.0-temp)); double gainL = 1.57079633-gainR; gainR = sin(gainR); gainL = sin(gainL); - double gain = (inTrimA*temp)+(inTrimB*(1.0-temp)); if (gain > 1.0) gain *= gain; if (gain < 1.0) gain = 1.0-pow(1.0-gain,2); gain *= 1.527864045000421; + double airGain = (airGainA*temp)+(airGainB*(1.0-temp)); + double fireGain = (fireGainA*temp)+(fireGainB*(1.0-temp)); + double stoneGain = (stoneGainA*temp)+(stoneGainB*(1.0-temp)); + //set up smoothed gain controls //begin Air3L + double drySampleL = inputSampleL; air[pvSL4] = air[pvAL4] - air[pvAL3]; air[pvSL3] = air[pvAL3] - air[pvAL2]; air[pvSL2] = air[pvAL2] - air[pvAL1]; air[pvSL1] = air[pvAL1] - inputSampleL; air[accSL3] = air[pvSL4] - air[pvSL3]; air[accSL2] = air[pvSL3] - air[pvSL2]; @@ -119,13 +409,13 @@ void ConsoleXChannel::processReplacing(float **inputs, float **outputs, VstInt32 if (air[gainAL] > 0.3*sqrt(overallscale)) air[gainAL] = 0.3*sqrt(overallscale); air[pvAL4] = air[pvAL3]; air[pvAL3] = air[pvAL2]; air[pvAL2] = air[pvAL1]; air[pvAL1] = (air[gainAL] * air[outAL]) + drySampleL; - double midL = drySampleL - ((air[outAL]*0.5)+(drySampleL*(0.457-(0.017*overallscale)))); - temp = (midL + air[gndavgL])*0.5; air[gndavgL] = midL; midL = temp; - double trebleL = drySampleL-midL; - inputSampleL = midL; + double fireL = drySampleL - ((air[outAL]*0.5)+(drySampleL*(0.457-(0.017*overallscale)))); + temp = (fireL + air[gndavgL])*0.5; air[gndavgL] = fireL; fireL = temp; + double airL = drySampleL-fireL; + inputSampleL = fireL; //end Air3L - //begin Air3R + double drySampleR = inputSampleR; air[pvSR4] = air[pvAR4] - air[pvAR3]; air[pvSR3] = air[pvAR3] - air[pvAR2]; air[pvSR2] = air[pvAR2] - air[pvAR1]; air[pvSR1] = air[pvAR1] - inputSampleR; air[accSR3] = air[pvSR4] - air[pvSR3]; air[accSR2] = air[pvSR3] - air[pvSR2]; @@ -136,15 +426,14 @@ void ConsoleXChannel::processReplacing(float **inputs, float **outputs, VstInt32 if (air[gainAR] > 0.3*sqrt(overallscale)) air[gainAR] = 0.3*sqrt(overallscale); air[pvAR4] = air[pvAR3]; air[pvAR3] = air[pvAR2]; air[pvAR2] = air[pvAR1]; air[pvAR1] = (air[gainAR] * air[outAR]) + drySampleR; - double midR = drySampleR - ((air[outAR]*0.5)+(drySampleR*(0.457-(0.017*overallscale)))); - temp = (midR + air[gndavgR])*0.5; air[gndavgR] = midR; midR = temp; - double trebleR = drySampleR-midR; - inputSampleR = midR; + double fireR = drySampleR - ((air[outAR]*0.5)+(drySampleR*(0.457-(0.017*overallscale)))); + temp = (fireR + air[gndavgR])*0.5; air[gndavgR] = fireR; fireR = temp; + double airR = drySampleR-fireR; + inputSampleR = fireR; //end Air3R - //begin KalmanL - temp = inputSampleL = inputSampleL*(1.0-kalman)*0.777; - inputSampleL *= (1.0-kalman); + temp = inputSampleL = inputSampleL*(1.0-kalmanRange)*0.777; + inputSampleL *= (1.0-kalmanRange); //set up gain levels to control the beast kal[prevSlewL3] += kal[prevSampL3] - kal[prevSampL2]; kal[prevSlewL3] *= 0.5; kal[prevSlewL2] += kal[prevSampL2] - kal[prevSampL1]; kal[prevSlewL2] *= 0.5; @@ -157,23 +446,22 @@ void ConsoleXChannel::processReplacing(float **inputs, float **outputs, VstInt32 //entering the abyss, what even is this kal[kalOutL] += kal[prevSampL1] + kal[prevSlewL2] + kal[accSlewL3]; kal[kalOutL] *= 0.5; //resynthesizing predicted result (all iir smoothed) - kal[kalGainL] += fabs(temp-kal[kalOutL])*kalman*8.0; kal[kalGainL] *= 0.5; + kal[kalGainL] += fabs(temp-kal[kalOutL])*kalmanRange*8.0; kal[kalGainL] *= 0.5; //madness takes its toll. Kalman Gain: how much dry to retain - if (kal[kalGainL] > kalman*0.5) kal[kalGainL] = kalman*0.5; + if (kal[kalGainL] > kalmanRange*0.5) kal[kalGainL] = kalmanRange*0.5; //attempts to avoid explosions - kal[kalOutL] += (temp*(1.0-(0.68+(kalman*0.157)))); + kal[kalOutL] += (temp*(1.0-(0.68+(kalmanRange*0.157)))); //this is for tuning a really complete cancellation up around Nyquist kal[prevSampL3] = kal[prevSampL2]; kal[prevSampL2] = kal[prevSampL1]; kal[prevSampL1] = (kal[kalGainL] * kal[kalOutL]) + ((1.0-kal[kalGainL])*temp); //feed the chain of previous samples if (kal[prevSampL1] > 1.0) kal[prevSampL1] = 1.0; if (kal[prevSampL1] < -1.0) kal[prevSampL1] = -1.0; - double bassL = kal[kalOutL]*0.777; - midL -= bassL; + double stoneL = kal[kalOutL]*0.777; + fireL -= stoneL; //end KalmanL - //begin KalmanR - temp = inputSampleR = inputSampleR*(1.0-kalman)*0.777; - inputSampleR *= (1.0-kalman); + temp = inputSampleR = inputSampleR*(1.0-kalmanRange)*0.777; + inputSampleR *= (1.0-kalmanRange); //set up gain levels to control the beast kal[prevSlewR3] += kal[prevSampR3] - kal[prevSampR2]; kal[prevSlewR3] *= 0.5; kal[prevSlewR2] += kal[prevSampR2] - kal[prevSampR1]; kal[prevSlewR2] *= 0.5; @@ -186,59 +474,105 @@ void ConsoleXChannel::processReplacing(float **inputs, float **outputs, VstInt32 //entering the abyss, what even is this kal[kalOutR] += kal[prevSampR1] + kal[prevSlewR2] + kal[accSlewR3]; kal[kalOutR] *= 0.5; //resynthesizing predicted result (all iir smoothed) - kal[kalGainR] += fabs(temp-kal[kalOutR])*kalman*8.0; kal[kalGainR] *= 0.5; + kal[kalGainR] += fabs(temp-kal[kalOutR])*kalmanRange*8.0; kal[kalGainR] *= 0.5; //madness takes its toll. Kalman Gain: how much dry to retain - if (kal[kalGainR] > kalman*0.5) kal[kalGainR] = kalman*0.5; + if (kal[kalGainR] > kalmanRange*0.5) kal[kalGainR] = kalmanRange*0.5; //attempts to avoid explosions - kal[kalOutR] += (temp*(1.0-(0.68+(kalman*0.157)))); + kal[kalOutR] += (temp*(1.0-(0.68+(kalmanRange*0.157)))); //this is for tuning a really complete cancellation up around Nyquist kal[prevSampR3] = kal[prevSampR2]; kal[prevSampR2] = kal[prevSampR1]; kal[prevSampR1] = (kal[kalGainR] * kal[kalOutR]) + ((1.0-kal[kalGainR])*temp); //feed the chain of previous samples if (kal[prevSampR1] > 1.0) kal[prevSampR1] = 1.0; if (kal[prevSampR1] < -1.0) kal[prevSampR1] = -1.0; - double bassR = kal[kalOutR]*0.777; - midR -= bassR; + double stoneR = kal[kalOutR]*0.777; + fireR -= stoneR; //end KalmanR + //fire dynamics + if (fabs(fireL) > compFThresh) { //compression L + fireCompL -= (fireCompL * compFAttack); + fireCompL += ((compFThresh / fabs(fireL))*compFAttack); + } else fireCompL = (fireCompL*(1.0-compFRelease))+compFRelease; + if (fireCompL < 0.0) fireCompL = 0.0; + if (fabs(fireR) > compFThresh) { //compression R + fireCompR -= (fireCompR * compFAttack); + fireCompR += ((compFThresh / fabs(fireR))*compFAttack); + } else fireCompR = (fireCompR*(1.0-compFRelease))+compFRelease; + if (fireCompR < 0.0) fireCompR = 0.0; + if (fireCompL > fireCompR) fireCompL -= (fireCompL * compFAttack); + if (fireCompR > fireCompL) fireCompR -= (fireCompR * compFAttack); + if (fabs(fireL) > gateFThresh) fireGate = gateFSustain; + else if (fabs(fireR) > gateFThresh) fireGate = gateFSustain; + else fireGate *= (1.0-gateFRelease); + if (fireGate < 0.0) fireGate = 0.0; + if (fireCompL < 1.0) fireL *= ((1.0-compFRatio)+(fireCompL*compFRatio)); + if (fireCompR < 1.0) fireR *= ((1.0-compFRatio)+(fireCompR*compFRatio)); + if (fireGate < M_PI_2) { + temp = ((1.0-gateFRatio)+(sin(fireGate)*gateFRatio)); + airL *= temp; + airR *= temp; + fireL *= temp; + fireR *= temp; + high[biqs_outL] *= temp; + high[biqs_outR] *= temp; + hmid[biqs_outL] *= temp; //if Fire gating, gate Air, high and hmid + hmid[biqs_outR] *= temp; //note that we aren't compressing these + } + //stone dynamics + if (fabs(stoneL) > compSThresh) { //compression L + stoneCompL -= (stoneCompL * compSAttack); + stoneCompL += ((compSThresh / fabs(stoneL))*compSAttack); + } else stoneCompL = (stoneCompL*(1.0-compSRelease))+compSRelease; + if (stoneCompL < 0.0) stoneCompL = 0.0; + if (fabs(stoneR) > compSThresh) { //compression R + stoneCompR -= (stoneCompR * compSAttack); + stoneCompR += ((compSThresh / fabs(stoneR))*compSAttack); + } else stoneCompR = (stoneCompR*(1.0-compSRelease))+compSRelease; + if (stoneCompR < 0.0) stoneCompR = 0.0; + if (stoneCompL > stoneCompR) stoneCompL -= (stoneCompL * compSAttack); + if (stoneCompR > stoneCompL) stoneCompR -= (stoneCompR * compSAttack); + if (fabs(stoneL) > gateSThresh) stoneGate = gateSSustain; + else if (fabs(stoneR) > gateSThresh) stoneGate = gateSSustain; + else stoneGate *= (1.0-gateSRelease); + if (stoneGate < 0.0) stoneGate = 0.0; + if (stoneCompL < 1.0) stoneL *= ((1.0-compSRatio)+(stoneCompL*compSRatio)); + if (stoneCompR < 1.0) stoneR *= ((1.0-compSRatio)+(stoneCompR*compSRatio)); + if (stoneGate < M_PI_2) { + temp = ((1.0-gateSRatio)+(sin(stoneGate)*gateSRatio)); + stoneL *= temp; + stoneR *= temp; + lmid[biqs_outL] *= temp; + lmid[biqs_outR] *= temp; + bass[biqs_outL] *= temp; //if Stone gating, gate lmid and bass + bass[biqs_outR] *= temp; //note that we aren't compressing these + } + inputSampleL = (stoneL*stoneGain) + (fireL*fireGain) + (airL*airGain); + inputSampleR = (stoneR*stoneGain) + (fireR*fireGain) + (airR*airGain); + //create Stonefire output + + if (highpassEngage) { //distributed Highpass + highpass[hilp_temp] = (inputSampleL*highpass[hilp_c0])+highpass[hilp_cL1]; + highpass[hilp_cL1] = (inputSampleL*highpass[hilp_c1])-(highpass[hilp_temp]*highpass[hilp_d1])+highpass[hilp_cL2]; + highpass[hilp_cL2] = (inputSampleL*highpass[hilp_c0])-(highpass[hilp_temp]*highpass[hilp_d2]); inputSampleL = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleR*highpass[hilp_c0])+highpass[hilp_cR1]; + highpass[hilp_cR1] = (inputSampleR*highpass[hilp_c1])-(highpass[hilp_temp]*highpass[hilp_d1])+highpass[hilp_cR2]; + highpass[hilp_cR2] = (inputSampleR*highpass[hilp_c0])-(highpass[hilp_temp]*highpass[hilp_d2]); inputSampleR = highpass[hilp_temp]; + } else highpass[hilp_cR1] = highpass[hilp_cR2] = highpass[hilp_cL1] = highpass[hilp_cL2] = 0.0; + if (lowpassEngage) { //distributed Lowpass + lowpass[hilp_temp] = (inputSampleL*lowpass[hilp_c0])+lowpass[hilp_cL1]; + lowpass[hilp_cL1] = (inputSampleL*lowpass[hilp_c1])-(lowpass[hilp_temp]*lowpass[hilp_d1])+lowpass[hilp_cL2]; + lowpass[hilp_cL2] = (inputSampleL*lowpass[hilp_c0])-(lowpass[hilp_temp]*lowpass[hilp_d2]); inputSampleL = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleR*lowpass[hilp_c0])+lowpass[hilp_cR1]; + lowpass[hilp_cR1] = (inputSampleR*lowpass[hilp_c1])-(lowpass[hilp_temp]*lowpass[hilp_d1])+lowpass[hilp_cR2]; + lowpass[hilp_cR2] = (inputSampleR*lowpass[hilp_c0])-(lowpass[hilp_temp]*lowpass[hilp_d2]); inputSampleR = lowpass[hilp_temp]; + } else lowpass[hilp_cR1] = lowpass[hilp_cR2] = lowpass[hilp_cL1] = lowpass[hilp_cL2] = 0.0; + //another stage of Highpass/Lowpass before bringing in the parametric bands - //begin ResEQ2 Mid Boost - mpc++; if (mpc < 1 || mpc > 2001) mpc = 1; - mpkL[mpc] = midL; - mpkR[mpc] = midR; - double midPeakL = 0.0; - double midPeakR = 0.0; - for (int x = 0; x < maxMPeak; x++) { - int y = x*cycleEnd; - switch (cycleEnd) - { - case 1: - midPeakL += (mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x]); - midPeakR += (mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x]); break; - case 2: - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.5); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.5); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.5); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.5); break; - case 3: - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); break; - case 4: - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); //break - } - }//end ResEQ2 Mid Boost creating - - inputSampleL = ((bassL*bassGain) + (midL*midGain) + (midPeakL*mPeak) + (trebleL*trebleGain)) * gainL * gain; - inputSampleR = ((bassR*bassGain) + (midR*midGain) + (midPeakR*mPeak) + (trebleR*trebleGain)) * gainR * gain; + inputSampleL += (high[biqs_outL] + hmid[biqs_outL] + lmid[biqs_outL] + bass[biqs_outL]); + inputSampleR += (high[biqs_outR] + hmid[biqs_outR] + lmid[biqs_outR] + bass[biqs_outR]); + //add parametric boosts or cuts: clean as possible for maximal rawness and sonority + + inputSampleL = inputSampleL * gainL * gain; + inputSampleR = inputSampleR * gainR * gain; //applies pan section, and smoothed fader gain inputSampleL *= topdB; @@ -259,19 +593,39 @@ void ConsoleXChannel::processReplacing(float **inputs, float **outputs, VstInt32 dBdly++; inputSampleR += dBaR[dBaXR-dBdly +((dBaXR-dBdly < 0)?dscBuf:0)]*dBi; dBaXR++; if (dBaXR < 0 || dBaXR >= dscBuf) dBaXR = 0; inputSampleR /= topdB; - //top dB processing for distributed discontinuity modeling air nonlinearity + //top dB processing for distributed discontinuity modeling air nonlinearity + //ConsoleXChannel before final Highpass/Lowpass stages inputSampleL *= 0.618033988749895; if (inputSampleL > 1.0) inputSampleL = 1.0; else if (inputSampleL > 0.0) inputSampleL = -expm1((log1p(-inputSampleL) * 1.618033988749895)); if (inputSampleL < -1.0) inputSampleL = -1.0; else if (inputSampleL < 0.0) inputSampleL = expm1((log1p(inputSampleL) * 1.618033988749895)); - inputSampleR *= 0.618033988749895; if (inputSampleR > 1.0) inputSampleR = 1.0; else if (inputSampleR > 0.0) inputSampleR = -expm1((log1p(-inputSampleR) * 1.618033988749895)); if (inputSampleR < -1.0) inputSampleR = -1.0; else if (inputSampleR < 0.0) inputSampleR = expm1((log1p(inputSampleR) * 1.618033988749895)); + //ConsoleXChannel before final Highpass/Lowpass stages + + if (highpassEngage) { //distributed Highpass + highpass[hilp_temp] = (inputSampleL*highpass[hilp_e0])+highpass[hilp_eL1]; + highpass[hilp_eL1] = (inputSampleL*highpass[hilp_e1])-(highpass[hilp_temp]*highpass[hilp_f1])+highpass[hilp_eL2]; + highpass[hilp_eL2] = (inputSampleL*highpass[hilp_e0])-(highpass[hilp_temp]*highpass[hilp_f2]); inputSampleL = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleR*highpass[hilp_e0])+highpass[hilp_eR1]; + highpass[hilp_eR1] = (inputSampleR*highpass[hilp_e1])-(highpass[hilp_temp]*highpass[hilp_f1])+highpass[hilp_eR2]; + highpass[hilp_eR2] = (inputSampleR*highpass[hilp_e0])-(highpass[hilp_temp]*highpass[hilp_f2]); inputSampleR = highpass[hilp_temp]; + } else highpass[hilp_eR1] = highpass[hilp_eR2] = highpass[hilp_eL1] = highpass[hilp_eL2] = 0.0; + if (lowpassEngage) { //distributed Lowpass + lowpass[hilp_temp] = (inputSampleL*lowpass[hilp_e0])+lowpass[hilp_eL1]; + lowpass[hilp_eL1] = (inputSampleL*lowpass[hilp_e1])-(lowpass[hilp_temp]*lowpass[hilp_f1])+lowpass[hilp_eL2]; + lowpass[hilp_eL2] = (inputSampleL*lowpass[hilp_e0])-(lowpass[hilp_temp]*lowpass[hilp_f2]); inputSampleL = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleR*lowpass[hilp_e0])+lowpass[hilp_eR1]; + lowpass[hilp_eR1] = (inputSampleR*lowpass[hilp_e1])-(lowpass[hilp_temp]*lowpass[hilp_f1])+lowpass[hilp_eR2]; + lowpass[hilp_eR2] = (inputSampleR*lowpass[hilp_e0])-(lowpass[hilp_temp]*lowpass[hilp_f2]); inputSampleR = lowpass[hilp_temp]; + } else lowpass[hilp_eR1] = lowpass[hilp_eR2] = lowpass[hilp_eL1] = lowpass[hilp_eL2] = 0.0; + //final Highpass/Lowpass continues to address aliasing + //final stacked biquad section is the softest Q for smoothness //begin 32 bit stereo floating point dither int expon; frexpf((float)inputSampleL, &expon); @@ -303,48 +657,160 @@ void ConsoleXChannel::processDoubleReplacing(double **inputs, double **outputs, double overallscale = 1.0; overallscale /= 44100.0; overallscale *= getSampleRate(); - int cycleEnd = floor(overallscale); - if (cycleEnd < 1) cycleEnd = 1; - if (cycleEnd > 3) cycleEnd = 3; - biquad[biq_freq] = 25000.0/getSampleRate(); - biquad[biq_reso] = 0.50979558; - double K = tan(M_PI * biquad[biq_freq]); - double norm = 1.0 / (1.0 + K / biquad[biq_reso] + K * K); - biquad[biq_a0] = K * K * norm; - biquad[biq_a1] = 2.0 * biquad[biq_a0]; - biquad[biq_a2] = biquad[biq_a0]; - biquad[biq_b1] = 2.0 * (K * K - 1.0) * norm; - biquad[biq_b2] = (1.0 - K / biquad[biq_reso] + K * K) * norm; - //ultrasonic nonlinear filter + highpass[hilp_freq] = ((HIP*330.0)+20.0)/getSampleRate(); + bool highpassEngage = true; if (HIP == 0.0) highpassEngage = false; - trebleGainA = trebleGainB; trebleGainB = A*2.0; - midGainA = midGainB; midGainB = B*2.0; - bassGainA = bassGainB; bassGainB = C*2.0; - //simple three band to adjust + lowpass[hilp_freq] = ((pow(1.0-LOP,2)*17000.0)+3000.0)/getSampleRate(); + bool lowpassEngage = true; if (LOP == 0.0) lowpassEngage = false; - //begin ResEQ2 Mid Boost - double freqMPeak = pow(D+0.16,3); - mPeakA = mPeakB; mPeakB = fabs(midGainB-1.0); //amount of mid peak leak through (or boost) - if (midGainB < 1.0) mPeakB *= 0.5; - int maxMPeak = (24.0*(2.0-freqMPeak))+16; - if ((freqMPeak != prevfreqMPeak)||(mPeakB != prevamountMPeak)) { - for (int x = 0; x < maxMPeak; x++) { - if (((double)x*freqMPeak) < M_PI_4) f[x] = sin(((double)x*freqMPeak)*4.0)*freqMPeak*sin(((double)(maxMPeak-x)/(double)maxMPeak)*M_PI_2); - else f[x] = cos((double)x*freqMPeak)*freqMPeak*sin(((double)(maxMPeak-x)/(double)maxMPeak)*M_PI_2); - } - prevfreqMPeak = freqMPeak; prevamountMPeak = mPeakB; - }//end ResEQ2 Mid Boost - //mid peak for either retaining during mid cut, or adding during mid boost + double K = tan(M_PI * highpass[hilp_freq]); //highpass + double norm = 1.0 / (1.0 + K / 1.93185165 + K * K); + highpass[hilp_a0] = norm; + highpass[hilp_a1] = -2.0 * highpass[hilp_a0]; + highpass[hilp_b1] = 2.0 * (K * K - 1.0) * norm; + highpass[hilp_b2] = (1.0 - K / 1.93185165 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.70710678 + K * K); + highpass[hilp_c0] = norm; + highpass[hilp_c1] = -2.0 * highpass[hilp_c0]; + highpass[hilp_d1] = 2.0 * (K * K - 1.0) * norm; + highpass[hilp_d2] = (1.0 - K / 0.70710678 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.51763809 + K * K); + highpass[hilp_e0] = norm; + highpass[hilp_e1] = -2.0 * highpass[hilp_e0]; + highpass[hilp_f1] = 2.0 * (K * K - 1.0) * norm; + highpass[hilp_f2] = (1.0 - K / 0.51763809 + K * K) * norm; + + K = tan(M_PI * lowpass[hilp_freq]); //lowpass + norm = 1.0 / (1.0 + K / 1.93185165 + K * K); + lowpass[hilp_a0] = K * K * norm; + lowpass[hilp_a1] = 2.0 * lowpass[hilp_a0]; + lowpass[hilp_b1] = 2.0 * (K * K - 1.0) * norm; + lowpass[hilp_b2] = (1.0 - K / 1.93185165 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.70710678 + K * K); + lowpass[hilp_c0] = K * K * norm; + lowpass[hilp_c1] = 2.0 * lowpass[hilp_c0]; + lowpass[hilp_d1] = 2.0 * (K * K - 1.0) * norm; + lowpass[hilp_d2] = (1.0 - K / 0.70710678 + K * K) * norm; + norm = 1.0 / (1.0 + K / 0.51763809 + K * K); + lowpass[hilp_e0] = K * K * norm; + lowpass[hilp_e1] = 2.0 * lowpass[hilp_e0]; + lowpass[hilp_f1] = 2.0 * (K * K - 1.0) * norm; + lowpass[hilp_f2] = (1.0 - K / 0.51763809 + K * K) * norm; - double kalman = 1.0-pow(E,2); + airGainA = airGainB; airGainB = AIR *2.0; + fireGainA = fireGainB; fireGainB = FIR *2.0; + stoneGainA = stoneGainB; stoneGainB = STO *2.0; + //simple three band to adjust + double kalmanRange = 1.0-pow(RNG,2); //crossover frequency between mid/bass - double refdB = (F*70.0)+70.0; + double compFThresh = pow(FCT,4); + double compSThresh = pow(SCT,4); + double compFRatio = 1.0-pow(1.0-FCR,2); + double compSRatio = 1.0-pow(1.0-SCR,2); + double compFAttack = 1.0/(((pow(FCA,3)*5000.0)+500.0)*overallscale); + double compSAttack = 1.0/(((pow(SCA,3)*5000.0)+500.0)*overallscale); + double compFRelease = 1.0/(((pow(FCL,5)*50000.0)+500.0)*overallscale); + double compSRelease = 1.0/(((pow(SCL,5)*50000.0)+500.0)*overallscale); + double gateFThresh = pow(FGT,4); + double gateSThresh = pow(SGT,4); + double gateFRatio = 1.0-pow(1.0-FGR,2); + double gateSRatio = 1.0-pow(1.0-SGR,2); + double gateFSustain = M_PI_2 * pow(FGS+1.0,4.0); + double gateSSustain = M_PI_2 * pow(SGS+1.0,4.0); + double gateFRelease = 1.0/(((pow(FGL,5)*500000.0)+500.0)*overallscale); + double gateSRelease = 1.0/(((pow(SGL,5)*500000.0)+500.0)*overallscale); + + high[biqs_freq] = (((pow(TRF,3)*14500.0)+1500.0)/getSampleRate()); + if (high[biqs_freq] < 0.0001) high[biqs_freq] = 0.0001; + high[biqs_nonlin] = TRG; + high[biqs_level] = (high[biqs_nonlin]*2.0)-1.0; + if (high[biqs_level] > 0.0) high[biqs_level] *= 2.0; + high[biqs_reso] = ((0.5+(high[biqs_nonlin]*0.5)+sqrt(high[biqs_freq]))-(1.0-pow(1.0-TRR,2.0)))+0.5+(high[biqs_nonlin]*0.5); + K = tan(M_PI * high[biqs_freq]); + norm = 1.0 / (1.0 + K / (high[biqs_reso]*1.93185165) + K * K); + high[biqs_a0] = K / (high[biqs_reso]*1.93185165) * norm; + high[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + high[biqs_b2] = (1.0 - K / (high[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (high[biqs_reso]*0.70710678) + K * K); + high[biqs_c0] = K / (high[biqs_reso]*0.70710678) * norm; + high[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + high[biqs_d2] = (1.0 - K / (high[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (high[biqs_reso]*0.51763809) + K * K); + high[biqs_e0] = K / (high[biqs_reso]*0.51763809) * norm; + high[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + high[biqs_f2] = (1.0 - K / (high[biqs_reso]*0.51763809) + K * K) * norm; + //high + + hmid[biqs_freq] = (((pow(HMF,3)*6400.0)+600.0)/getSampleRate()); + if (hmid[biqs_freq] < 0.0001) hmid[biqs_freq] = 0.0001; + hmid[biqs_nonlin] = HMG; + hmid[biqs_level] = (hmid[biqs_nonlin]*2.0)-1.0; + if (hmid[biqs_level] > 0.0) hmid[biqs_level] *= 2.0; + hmid[biqs_reso] = ((0.5+(hmid[biqs_nonlin]*0.5)+sqrt(hmid[biqs_freq]))-(1.0-pow(1.0-HMR,2.0)))+0.5+(hmid[biqs_nonlin]*0.5); + K = tan(M_PI * hmid[biqs_freq]); + norm = 1.0 / (1.0 + K / (hmid[biqs_reso]*1.93185165) + K * K); + hmid[biqs_a0] = K / (hmid[biqs_reso]*1.93185165) * norm; + hmid[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + hmid[biqs_b2] = (1.0 - K / (hmid[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (hmid[biqs_reso]*0.70710678) + K * K); + hmid[biqs_c0] = K / (hmid[biqs_reso]*0.70710678) * norm; + hmid[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + hmid[biqs_d2] = (1.0 - K / (hmid[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (hmid[biqs_reso]*0.51763809) + K * K); + hmid[biqs_e0] = K / (hmid[biqs_reso]*0.51763809) * norm; + hmid[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + hmid[biqs_f2] = (1.0 - K / (hmid[biqs_reso]*0.51763809) + K * K) * norm; + //hmid + + lmid[biqs_freq] = (((pow(LMF,3)*2200.0)+200.0)/getSampleRate()); + if (lmid[biqs_freq] < 0.0001) lmid[biqs_freq] = 0.0001; + lmid[biqs_nonlin] = LMG; + lmid[biqs_level] = (lmid[biqs_nonlin]*2.0)-1.0; + if (lmid[biqs_level] > 0.0) lmid[biqs_level] *= 2.0; + lmid[biqs_reso] = ((0.5+(lmid[biqs_nonlin]*0.5)+sqrt(lmid[biqs_freq]))-(1.0-pow(1.0-LMR,2.0)))+0.5+(lmid[biqs_nonlin]*0.5); + K = tan(M_PI * lmid[biqs_freq]); + norm = 1.0 / (1.0 + K / (lmid[biqs_reso]*1.93185165) + K * K); + lmid[biqs_a0] = K / (lmid[biqs_reso]*1.93185165) * norm; + lmid[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + lmid[biqs_b2] = (1.0 - K / (lmid[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (lmid[biqs_reso]*0.70710678) + K * K); + lmid[biqs_c0] = K / (lmid[biqs_reso]*0.70710678) * norm; + lmid[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + lmid[biqs_d2] = (1.0 - K / (lmid[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (lmid[biqs_reso]*0.51763809) + K * K); + lmid[biqs_e0] = K / (lmid[biqs_reso]*0.51763809) * norm; + lmid[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + lmid[biqs_f2] = (1.0 - K / (lmid[biqs_reso]*0.51763809) + K * K) * norm; + //lmid + + bass[biqs_freq] = (((pow(BSF,3)*570.0)+30.0)/getSampleRate()); + if (bass[biqs_freq] < 0.0001) bass[biqs_freq] = 0.0001; + bass[biqs_nonlin] = BSG; + bass[biqs_level] = (bass[biqs_nonlin]*2.0)-1.0; + if (bass[biqs_level] > 0.0) bass[biqs_level] *= 2.0; + bass[biqs_reso] = ((0.5+(bass[biqs_nonlin]*0.5)+sqrt(bass[biqs_freq]))-(1.0-pow(1.0-BSR,2.0)))+0.5+(bass[biqs_nonlin]*0.5); + K = tan(M_PI * bass[biqs_freq]); + norm = 1.0 / (1.0 + K / (bass[biqs_reso]*1.93185165) + K * K); + bass[biqs_a0] = K / (bass[biqs_reso]*1.93185165) * norm; + bass[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + bass[biqs_b2] = (1.0 - K / (bass[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (bass[biqs_reso]*0.70710678) + K * K); + bass[biqs_c0] = K / (bass[biqs_reso]*0.70710678) * norm; + bass[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + bass[biqs_d2] = (1.0 - K / (bass[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (bass[biqs_reso]*0.51763809) + K * K); + bass[biqs_e0] = K / (bass[biqs_reso]*0.51763809) * norm; + bass[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + bass[biqs_f2] = (1.0 - K / (bass[biqs_reso]*0.51763809) + K * K) * norm; + //bass + + double refdB = (DSC*70.0)+70.0; double topdB = 0.000000075 * pow(10.0,refdB/20.0) * overallscale; - panA = panB; panB = G*1.57079633; - inTrimA = inTrimB; inTrimB = H*2.0; + panA = panB; panB = PAN*1.57079633; + inTrimA = inTrimB; inTrimB = FAD*2.0; while (--sampleFrames >= 0) { @@ -352,47 +818,225 @@ void ConsoleXChannel::processDoubleReplacing(double **inputs, double **outputs, double inputSampleR = *in2; if (fabs(inputSampleL)<1.18e-23) inputSampleL = fpdL * 1.18e-17; if (fabs(inputSampleR)<1.18e-23) inputSampleR = fpdR * 1.18e-17; - double drySampleL = inputSampleL; - double drySampleR = inputSampleR; - if (biquad[biq_freq] < 0.5) { - double nlBiq = fabs(biquad[biq_a0]*(1.0+(inputSampleL*0.25))); if (nlBiq > 1.0) nlBiq = 1.0; - double tmp = (inputSampleL * nlBiq) + biquad[biq_sL1]; - biquad[biq_sL1] = (inputSampleL * biquad[biq_a1]) - (tmp * biquad[biq_b1]) + biquad[biq_sL2]; - biquad[biq_sL2] = (inputSampleL * nlBiq) - (tmp * biquad[biq_b2]); - inputSampleL = tmp; - nlBiq = fabs(biquad[biq_a0]*(1.0+(inputSampleR*0.25))); if (nlBiq > 1.0) nlBiq = 1.0; - tmp = (inputSampleR * nlBiq) + biquad[biq_sR1]; - biquad[biq_sR1] = (inputSampleR * biquad[biq_a1]) - (tmp * biquad[biq_b1]) + biquad[biq_sR2]; - biquad[biq_sR2] = (inputSampleR * nlBiq) - (tmp * biquad[biq_b2]); - inputSampleR = tmp; - //ultrasonic filter before anything else is done - } + if (highpassEngage) { //distributed Highpass + highpass[hilp_temp] = (inputSampleL*highpass[hilp_a0])+highpass[hilp_aL1]; + highpass[hilp_aL1] = (inputSampleL*highpass[hilp_a1])-(highpass[hilp_temp]*highpass[hilp_b1])+highpass[hilp_aL2]; + highpass[hilp_aL2] = (inputSampleL*highpass[hilp_a0])-(highpass[hilp_temp]*highpass[hilp_b2]); inputSampleL = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleR*highpass[hilp_a0])+highpass[hilp_aR1]; + highpass[hilp_aR1] = (inputSampleR*highpass[hilp_a1])-(highpass[hilp_temp]*highpass[hilp_b1])+highpass[hilp_aR2]; + highpass[hilp_aR2] = (inputSampleR*highpass[hilp_a0])-(highpass[hilp_temp]*highpass[hilp_b2]); inputSampleR = highpass[hilp_temp]; + } else highpass[hilp_aR1] = highpass[hilp_aR2] = highpass[hilp_aL1] = highpass[hilp_aL2] = 0.0; + if (lowpassEngage) { //distributed Lowpass + lowpass[hilp_temp] = (inputSampleL*lowpass[hilp_a0])+lowpass[hilp_aL1]; + lowpass[hilp_aL1] = (inputSampleL*lowpass[hilp_a1])-(lowpass[hilp_temp]*lowpass[hilp_b1])+lowpass[hilp_aL2]; + lowpass[hilp_aL2] = (inputSampleL*lowpass[hilp_a0])-(lowpass[hilp_temp]*lowpass[hilp_b2]); inputSampleL = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleR*lowpass[hilp_a0])+lowpass[hilp_aR1]; + lowpass[hilp_aR1] = (inputSampleR*lowpass[hilp_a1])-(lowpass[hilp_temp]*lowpass[hilp_b1])+lowpass[hilp_aR2]; + lowpass[hilp_aR2] = (inputSampleR*lowpass[hilp_a0])-(lowpass[hilp_temp]*lowpass[hilp_b2]); inputSampleR = lowpass[hilp_temp]; + } else lowpass[hilp_aR1] = lowpass[hilp_aR2] = lowpass[hilp_aL1] = lowpass[hilp_aL2] = 0.0; + //first Highpass/Lowpass blocks aliasing before the nonlinearity of ConsoleXBuss and Parametric - double temp = (double)sampleFrames/inFramesToProcess; - double trebleGain = (trebleGainA*temp)+(trebleGainB*(1.0-temp)); - if (trebleGain > 1.0) trebleGain = pow(trebleGain,3.0+sqrt(overallscale)); - if (trebleGain < 1.0) trebleGain = 1.0-pow(1.0-trebleGain,2); + //get all Parametric bands before any other processing is done + //begin Stacked Biquad With Reversed Neutron Flow L + high[biqs_outL] = inputSampleL * fabs(high[biqs_level]); + high[biqs_dis] = fabs(high[biqs_a0] * (1.0+(high[biqs_outL]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outL] * high[biqs_dis]) + high[biqs_aL1]; + high[biqs_aL1] = high[biqs_aL2] - (high[biqs_temp]*high[biqs_b1]); + high[biqs_aL2] = (high[biqs_outL] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_b2]); + high[biqs_outL] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_c0] * (1.0+(high[biqs_outL]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outL] * high[biqs_dis]) + high[biqs_cL1]; + high[biqs_cL1] = high[biqs_cL2] - (high[biqs_temp]*high[biqs_d1]); + high[biqs_cL2] = (high[biqs_outL] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_d2]); + high[biqs_outL] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_e0] * (1.0+(high[biqs_outL]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outL] * high[biqs_dis]) + high[biqs_eL1]; + high[biqs_eL1] = high[biqs_eL2] - (high[biqs_temp]*high[biqs_f1]); + high[biqs_eL2] = (high[biqs_outL] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_f2]); + high[biqs_outL] = high[biqs_temp]; high[biqs_outL] *= high[biqs_level]; + if (high[biqs_level] > 1.0) high[biqs_outL] *= high[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L + + //begin Stacked Biquad With Reversed Neutron Flow L + hmid[biqs_outL] = inputSampleL * fabs(hmid[biqs_level]); + hmid[biqs_dis] = fabs(hmid[biqs_a0] * (1.0+(hmid[biqs_outL]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outL] * hmid[biqs_dis]) + hmid[biqs_aL1]; + hmid[biqs_aL1] = hmid[biqs_aL2] - (hmid[biqs_temp]*hmid[biqs_b1]); + hmid[biqs_aL2] = (hmid[biqs_outL] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_b2]); + hmid[biqs_outL] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_c0] * (1.0+(hmid[biqs_outL]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outL] * hmid[biqs_dis]) + hmid[biqs_cL1]; + hmid[biqs_cL1] = hmid[biqs_cL2] - (hmid[biqs_temp]*hmid[biqs_d1]); + hmid[biqs_cL2] = (hmid[biqs_outL] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_d2]); + hmid[biqs_outL] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_e0] * (1.0+(hmid[biqs_outL]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outL] * hmid[biqs_dis]) + hmid[biqs_eL1]; + hmid[biqs_eL1] = hmid[biqs_eL2] - (hmid[biqs_temp]*hmid[biqs_f1]); + hmid[biqs_eL2] = (hmid[biqs_outL] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_f2]); + hmid[biqs_outL] = hmid[biqs_temp]; hmid[biqs_outL] *= hmid[biqs_level]; + if (hmid[biqs_level] > 1.0) hmid[biqs_outL] *= hmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L + + //begin Stacked Biquad With Reversed Neutron Flow L + lmid[biqs_outL] = inputSampleL * fabs(lmid[biqs_level]); + lmid[biqs_dis] = fabs(lmid[biqs_a0] * (1.0+(lmid[biqs_outL]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outL] * lmid[biqs_dis]) + lmid[biqs_aL1]; + lmid[biqs_aL1] = lmid[biqs_aL2] - (lmid[biqs_temp]*lmid[biqs_b1]); + lmid[biqs_aL2] = (lmid[biqs_outL] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_b2]); + lmid[biqs_outL] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_c0] * (1.0+(lmid[biqs_outL]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outL] * lmid[biqs_dis]) + lmid[biqs_cL1]; + lmid[biqs_cL1] = lmid[biqs_cL2] - (lmid[biqs_temp]*lmid[biqs_d1]); + lmid[biqs_cL2] = (lmid[biqs_outL] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_d2]); + lmid[biqs_outL] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_e0] * (1.0+(lmid[biqs_outL]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outL] * lmid[biqs_dis]) + lmid[biqs_eL1]; + lmid[biqs_eL1] = lmid[biqs_eL2] - (lmid[biqs_temp]*lmid[biqs_f1]); + lmid[biqs_eL2] = (lmid[biqs_outL] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_f2]); + lmid[biqs_outL] = lmid[biqs_temp]; lmid[biqs_outL] *= lmid[biqs_level]; + if (lmid[biqs_level] > 1.0) lmid[biqs_outL] *= lmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L + + //begin Stacked Biquad With Reversed Neutron Flow L + bass[biqs_outL] = inputSampleL * fabs(bass[biqs_level]); + bass[biqs_dis] = fabs(bass[biqs_a0] * (1.0+(bass[biqs_outL]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outL] * bass[biqs_dis]) + bass[biqs_aL1]; + bass[biqs_aL1] = bass[biqs_aL2] - (bass[biqs_temp]*bass[biqs_b1]); + bass[biqs_aL2] = (bass[biqs_outL] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_b2]); + bass[biqs_outL] = bass[biqs_temp]; + bass[biqs_dis] = fabs(bass[biqs_c0] * (1.0+(bass[biqs_outL]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outL] * bass[biqs_dis]) + bass[biqs_cL1]; + bass[biqs_cL1] = bass[biqs_cL2] - (bass[biqs_temp]*bass[biqs_d1]); + bass[biqs_cL2] = (bass[biqs_outL] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_d2]); + bass[biqs_outL] = bass[biqs_temp]; + bass[biqs_dis] = fabs(bass[biqs_e0] * (1.0+(bass[biqs_outL]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outL] * bass[biqs_dis]) + bass[biqs_eL1]; + bass[biqs_eL1] = bass[biqs_eL2] - (bass[biqs_temp]*bass[biqs_f1]); + bass[biqs_eL2] = (bass[biqs_outL] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_f2]); + bass[biqs_outL] = bass[biqs_temp]; bass[biqs_outL] *= bass[biqs_level]; + if (bass[biqs_level] > 1.0) bass[biqs_outL] *= bass[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L - double midGain = (midGainA*temp)+(midGainB*(1.0-temp)); - if (midGain > 1.0) midGain = 1.0; - if (midGain < 1.0) midGain = 1.0-pow(1.0-midGain,2); - double mPeak = pow((mPeakA*temp)+(mPeakB*(1.0-temp)),2); + //begin Stacked Biquad With Reversed Neutron Flow R + high[biqs_outR] = inputSampleR * fabs(high[biqs_level]); + high[biqs_dis] = fabs(high[biqs_a0] * (1.0+(high[biqs_outR]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outR] * high[biqs_dis]) + high[biqs_aR1]; + high[biqs_aR1] = high[biqs_aR2] - (high[biqs_temp]*high[biqs_b1]); + high[biqs_aR2] = (high[biqs_outR] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_b2]); + high[biqs_outR] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_c0] * (1.0+(high[biqs_outR]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outR] * high[biqs_dis]) + high[biqs_cR1]; + high[biqs_cR1] = high[biqs_cR2] - (high[biqs_temp]*high[biqs_d1]); + high[biqs_cR2] = (high[biqs_outR] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_d2]); + high[biqs_outR] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_e0] * (1.0+(high[biqs_outR]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outR] * high[biqs_dis]) + high[biqs_eR1]; + high[biqs_eR1] = high[biqs_eR2] - (high[biqs_temp]*high[biqs_f1]); + high[biqs_eR2] = (high[biqs_outR] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_f2]); + high[biqs_outR] = high[biqs_temp]; high[biqs_outR] *= high[biqs_level]; + if (high[biqs_level] > 1.0) high[biqs_outR] *= high[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R - double bassGain = (bassGainA*temp)+(bassGainB*(1.0-temp)); - if (bassGain > 1.0) bassGain *= bassGain; - if (bassGain < 1.0) bassGain = 1.0-pow(1.0-bassGain,2); + //begin Stacked Biquad With Reversed Neutron Flow R + hmid[biqs_outR] = inputSampleR * fabs(hmid[biqs_level]); + hmid[biqs_dis] = fabs(hmid[biqs_a0] * (1.0+(hmid[biqs_outR]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outR] * hmid[biqs_dis]) + hmid[biqs_aR1]; + hmid[biqs_aR1] = hmid[biqs_aR2] - (hmid[biqs_temp]*hmid[biqs_b1]); + hmid[biqs_aR2] = (hmid[biqs_outR] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_b2]); + hmid[biqs_outR] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_c0] * (1.0+(hmid[biqs_outR]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outR] * hmid[biqs_dis]) + hmid[biqs_cR1]; + hmid[biqs_cR1] = hmid[biqs_cR2] - (hmid[biqs_temp]*hmid[biqs_d1]); + hmid[biqs_cR2] = (hmid[biqs_outR] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_d2]); + hmid[biqs_outR] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_e0] * (1.0+(hmid[biqs_outR]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outR] * hmid[biqs_dis]) + hmid[biqs_eR1]; + hmid[biqs_eR1] = hmid[biqs_eR2] - (hmid[biqs_temp]*hmid[biqs_f1]); + hmid[biqs_eR2] = (hmid[biqs_outR] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_f2]); + hmid[biqs_outR] = hmid[biqs_temp]; hmid[biqs_outR] *= hmid[biqs_level]; + if (hmid[biqs_level] > 1.0) hmid[biqs_outR] *= hmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R + //begin Stacked Biquad With Reversed Neutron Flow R + lmid[biqs_outR] = inputSampleR * fabs(lmid[biqs_level]); + lmid[biqs_dis] = fabs(lmid[biqs_a0] * (1.0+(lmid[biqs_outR]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outR] * lmid[biqs_dis]) + lmid[biqs_aR1]; + lmid[biqs_aR1] = lmid[biqs_aR2] - (lmid[biqs_temp]*lmid[biqs_b1]); + lmid[biqs_aR2] = (lmid[biqs_outR] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_b2]); + lmid[biqs_outR] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_c0] * (1.0+(lmid[biqs_outR]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outR] * lmid[biqs_dis]) + lmid[biqs_cR1]; + lmid[biqs_cR1] = lmid[biqs_cR2] - (lmid[biqs_temp]*lmid[biqs_d1]); + lmid[biqs_cR2] = (lmid[biqs_outR] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_d2]); + lmid[biqs_outR] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_e0] * (1.0+(lmid[biqs_outR]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outR] * lmid[biqs_dis]) + lmid[biqs_eR1]; + lmid[biqs_eR1] = lmid[biqs_eR2] - (lmid[biqs_temp]*lmid[biqs_f1]); + lmid[biqs_eR2] = (lmid[biqs_outR] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_f2]); + lmid[biqs_outR] = lmid[biqs_temp]; lmid[biqs_outR] *= lmid[biqs_level]; + if (lmid[biqs_level] > 1.0) lmid[biqs_outR] *= lmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R + + //begin Stacked Biquad With Reversed Neutron Flow R + bass[biqs_outR] = inputSampleR * fabs(bass[biqs_level]); + bass[biqs_dis] = fabs(bass[biqs_a0] * (1.0+(bass[biqs_outR]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outR] * bass[biqs_dis]) + bass[biqs_aR1]; + bass[biqs_aR1] = bass[biqs_aR2] - (bass[biqs_temp]*bass[biqs_b1]); + bass[biqs_aR2] = (bass[biqs_outR] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_b2]); + bass[biqs_outR] = bass[biqs_temp]; + bass[biqs_dis] = fabs(bass[biqs_c0] * (1.0+(bass[biqs_outR]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outR] * bass[biqs_dis]) + bass[biqs_cR1]; + bass[biqs_cR1] = bass[biqs_cR2] - (bass[biqs_temp]*bass[biqs_d1]); + bass[biqs_cR2] = (bass[biqs_outR] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_d2]); + bass[biqs_outR] = bass[biqs_temp]; + bass[biqs_dis] = fabs(bass[biqs_e0] * (1.0+(bass[biqs_outR]*bass[biqs_nonlin]))); + if (bass[biqs_dis] > 1.0) bass[biqs_dis] = 1.0; + bass[biqs_temp] = (bass[biqs_outR] * bass[biqs_dis]) + bass[biqs_eR1]; + bass[biqs_eR1] = bass[biqs_eR2] - (bass[biqs_temp]*bass[biqs_f1]); + bass[biqs_eR2] = (bass[biqs_outR] * -bass[biqs_dis]) - (bass[biqs_temp]*bass[biqs_f2]); + bass[biqs_outR] = bass[biqs_temp]; bass[biqs_outR] *= bass[biqs_level]; + if (bass[biqs_level] > 1.0) bass[biqs_outR] *= bass[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R + + double temp = (double)sampleFrames/inFramesToProcess; double gainR = (panA*temp)+(panB*(1.0-temp)); double gainL = 1.57079633-gainR; gainR = sin(gainR); gainL = sin(gainL); - double gain = (inTrimA*temp)+(inTrimB*(1.0-temp)); if (gain > 1.0) gain *= gain; if (gain < 1.0) gain = 1.0-pow(1.0-gain,2); gain *= 1.527864045000421; + double airGain = (airGainA*temp)+(airGainB*(1.0-temp)); + double fireGain = (fireGainA*temp)+(fireGainB*(1.0-temp)); + double stoneGain = (stoneGainA*temp)+(stoneGainB*(1.0-temp)); + //set up smoothed gain controls //begin Air3L + double drySampleL = inputSampleL; air[pvSL4] = air[pvAL4] - air[pvAL3]; air[pvSL3] = air[pvAL3] - air[pvAL2]; air[pvSL2] = air[pvAL2] - air[pvAL1]; air[pvSL1] = air[pvAL1] - inputSampleL; air[accSL3] = air[pvSL4] - air[pvSL3]; air[accSL2] = air[pvSL3] - air[pvSL2]; @@ -403,13 +1047,13 @@ void ConsoleXChannel::processDoubleReplacing(double **inputs, double **outputs, if (air[gainAL] > 0.3*sqrt(overallscale)) air[gainAL] = 0.3*sqrt(overallscale); air[pvAL4] = air[pvAL3]; air[pvAL3] = air[pvAL2]; air[pvAL2] = air[pvAL1]; air[pvAL1] = (air[gainAL] * air[outAL]) + drySampleL; - double midL = drySampleL - ((air[outAL]*0.5)+(drySampleL*(0.457-(0.017*overallscale)))); - temp = (midL + air[gndavgL])*0.5; air[gndavgL] = midL; midL = temp; - double trebleL = drySampleL-midL; - inputSampleL = midL; + double fireL = drySampleL - ((air[outAL]*0.5)+(drySampleL*(0.457-(0.017*overallscale)))); + temp = (fireL + air[gndavgL])*0.5; air[gndavgL] = fireL; fireL = temp; + double airL = drySampleL-fireL; + inputSampleL = fireL; //end Air3L - //begin Air3R + double drySampleR = inputSampleR; air[pvSR4] = air[pvAR4] - air[pvAR3]; air[pvSR3] = air[pvAR3] - air[pvAR2]; air[pvSR2] = air[pvAR2] - air[pvAR1]; air[pvSR1] = air[pvAR1] - inputSampleR; air[accSR3] = air[pvSR4] - air[pvSR3]; air[accSR2] = air[pvSR3] - air[pvSR2]; @@ -420,15 +1064,14 @@ void ConsoleXChannel::processDoubleReplacing(double **inputs, double **outputs, if (air[gainAR] > 0.3*sqrt(overallscale)) air[gainAR] = 0.3*sqrt(overallscale); air[pvAR4] = air[pvAR3]; air[pvAR3] = air[pvAR2]; air[pvAR2] = air[pvAR1]; air[pvAR1] = (air[gainAR] * air[outAR]) + drySampleR; - double midR = drySampleR - ((air[outAR]*0.5)+(drySampleR*(0.457-(0.017*overallscale)))); - temp = (midR + air[gndavgR])*0.5; air[gndavgR] = midR; midR = temp; - double trebleR = drySampleR-midR; - inputSampleR = midR; + double fireR = drySampleR - ((air[outAR]*0.5)+(drySampleR*(0.457-(0.017*overallscale)))); + temp = (fireR + air[gndavgR])*0.5; air[gndavgR] = fireR; fireR = temp; + double airR = drySampleR-fireR; + inputSampleR = fireR; //end Air3R - //begin KalmanL - temp = inputSampleL = inputSampleL*(1.0-kalman)*0.777; - inputSampleL *= (1.0-kalman); + temp = inputSampleL = inputSampleL*(1.0-kalmanRange)*0.777; + inputSampleL *= (1.0-kalmanRange); //set up gain levels to control the beast kal[prevSlewL3] += kal[prevSampL3] - kal[prevSampL2]; kal[prevSlewL3] *= 0.5; kal[prevSlewL2] += kal[prevSampL2] - kal[prevSampL1]; kal[prevSlewL2] *= 0.5; @@ -441,23 +1084,22 @@ void ConsoleXChannel::processDoubleReplacing(double **inputs, double **outputs, //entering the abyss, what even is this kal[kalOutL] += kal[prevSampL1] + kal[prevSlewL2] + kal[accSlewL3]; kal[kalOutL] *= 0.5; //resynthesizing predicted result (all iir smoothed) - kal[kalGainL] += fabs(temp-kal[kalOutL])*kalman*8.0; kal[kalGainL] *= 0.5; + kal[kalGainL] += fabs(temp-kal[kalOutL])*kalmanRange*8.0; kal[kalGainL] *= 0.5; //madness takes its toll. Kalman Gain: how much dry to retain - if (kal[kalGainL] > kalman*0.5) kal[kalGainL] = kalman*0.5; + if (kal[kalGainL] > kalmanRange*0.5) kal[kalGainL] = kalmanRange*0.5; //attempts to avoid explosions - kal[kalOutL] += (temp*(1.0-(0.68+(kalman*0.157)))); + kal[kalOutL] += (temp*(1.0-(0.68+(kalmanRange*0.157)))); //this is for tuning a really complete cancellation up around Nyquist kal[prevSampL3] = kal[prevSampL2]; kal[prevSampL2] = kal[prevSampL1]; kal[prevSampL1] = (kal[kalGainL] * kal[kalOutL]) + ((1.0-kal[kalGainL])*temp); //feed the chain of previous samples if (kal[prevSampL1] > 1.0) kal[prevSampL1] = 1.0; if (kal[prevSampL1] < -1.0) kal[prevSampL1] = -1.0; - double bassL = kal[kalOutL]*0.777; - midL -= bassL; + double stoneL = kal[kalOutL]*0.777; + fireL -= stoneL; //end KalmanL - //begin KalmanR - temp = inputSampleR = inputSampleR*(1.0-kalman)*0.777; - inputSampleR *= (1.0-kalman); + temp = inputSampleR = inputSampleR*(1.0-kalmanRange)*0.777; + inputSampleR *= (1.0-kalmanRange); //set up gain levels to control the beast kal[prevSlewR3] += kal[prevSampR3] - kal[prevSampR2]; kal[prevSlewR3] *= 0.5; kal[prevSlewR2] += kal[prevSampR2] - kal[prevSampR1]; kal[prevSlewR2] *= 0.5; @@ -470,59 +1112,105 @@ void ConsoleXChannel::processDoubleReplacing(double **inputs, double **outputs, //entering the abyss, what even is this kal[kalOutR] += kal[prevSampR1] + kal[prevSlewR2] + kal[accSlewR3]; kal[kalOutR] *= 0.5; //resynthesizing predicted result (all iir smoothed) - kal[kalGainR] += fabs(temp-kal[kalOutR])*kalman*8.0; kal[kalGainR] *= 0.5; + kal[kalGainR] += fabs(temp-kal[kalOutR])*kalmanRange*8.0; kal[kalGainR] *= 0.5; //madness takes its toll. Kalman Gain: how much dry to retain - if (kal[kalGainR] > kalman*0.5) kal[kalGainR] = kalman*0.5; + if (kal[kalGainR] > kalmanRange*0.5) kal[kalGainR] = kalmanRange*0.5; //attempts to avoid explosions - kal[kalOutR] += (temp*(1.0-(0.68+(kalman*0.157)))); + kal[kalOutR] += (temp*(1.0-(0.68+(kalmanRange*0.157)))); //this is for tuning a really complete cancellation up around Nyquist kal[prevSampR3] = kal[prevSampR2]; kal[prevSampR2] = kal[prevSampR1]; kal[prevSampR1] = (kal[kalGainR] * kal[kalOutR]) + ((1.0-kal[kalGainR])*temp); //feed the chain of previous samples if (kal[prevSampR1] > 1.0) kal[prevSampR1] = 1.0; if (kal[prevSampR1] < -1.0) kal[prevSampR1] = -1.0; - double bassR = kal[kalOutR]*0.777; - midR -= bassR; + double stoneR = kal[kalOutR]*0.777; + fireR -= stoneR; //end KalmanR + //fire dynamics + if (fabs(fireL) > compFThresh) { //compression L + fireCompL -= (fireCompL * compFAttack); + fireCompL += ((compFThresh / fabs(fireL))*compFAttack); + } else fireCompL = (fireCompL*(1.0-compFRelease))+compFRelease; + if (fireCompL < 0.0) fireCompL = 0.0; + if (fabs(fireR) > compFThresh) { //compression R + fireCompR -= (fireCompR * compFAttack); + fireCompR += ((compFThresh / fabs(fireR))*compFAttack); + } else fireCompR = (fireCompR*(1.0-compFRelease))+compFRelease; + if (fireCompR < 0.0) fireCompR = 0.0; + if (fireCompL > fireCompR) fireCompL -= (fireCompL * compFAttack); + if (fireCompR > fireCompL) fireCompR -= (fireCompR * compFAttack); + if (fabs(fireL) > gateFThresh) fireGate = gateFSustain; + else if (fabs(fireR) > gateFThresh) fireGate = gateFSustain; + else fireGate *= (1.0-gateFRelease); + if (fireGate < 0.0) fireGate = 0.0; + if (fireCompL < 1.0) fireL *= ((1.0-compFRatio)+(fireCompL*compFRatio)); + if (fireCompR < 1.0) fireR *= ((1.0-compFRatio)+(fireCompR*compFRatio)); + if (fireGate < M_PI_2) { + temp = ((1.0-gateFRatio)+(sin(fireGate)*gateFRatio)); + airL *= temp; + airR *= temp; + fireL *= temp; + fireR *= temp; + high[biqs_outL] *= temp; + high[biqs_outR] *= temp; + hmid[biqs_outL] *= temp; //if Fire gating, gate Air, high and hmid + hmid[biqs_outR] *= temp; //note that we aren't compressing these + } + //stone dynamics + if (fabs(stoneL) > compSThresh) { //compression L + stoneCompL -= (stoneCompL * compSAttack); + stoneCompL += ((compSThresh / fabs(stoneL))*compSAttack); + } else stoneCompL = (stoneCompL*(1.0-compSRelease))+compSRelease; + if (stoneCompL < 0.0) stoneCompL = 0.0; + if (fabs(stoneR) > compSThresh) { //compression R + stoneCompR -= (stoneCompR * compSAttack); + stoneCompR += ((compSThresh / fabs(stoneR))*compSAttack); + } else stoneCompR = (stoneCompR*(1.0-compSRelease))+compSRelease; + if (stoneCompR < 0.0) stoneCompR = 0.0; + if (stoneCompL > stoneCompR) stoneCompL -= (stoneCompL * compSAttack); + if (stoneCompR > stoneCompL) stoneCompR -= (stoneCompR * compSAttack); + if (fabs(stoneL) > gateSThresh) stoneGate = gateSSustain; + else if (fabs(stoneR) > gateSThresh) stoneGate = gateSSustain; + else stoneGate *= (1.0-gateSRelease); + if (stoneGate < 0.0) stoneGate = 0.0; + if (stoneCompL < 1.0) stoneL *= ((1.0-compSRatio)+(stoneCompL*compSRatio)); + if (stoneCompR < 1.0) stoneR *= ((1.0-compSRatio)+(stoneCompR*compSRatio)); + if (stoneGate < M_PI_2) { + temp = ((1.0-gateSRatio)+(sin(stoneGate)*gateSRatio)); + stoneL *= temp; + stoneR *= temp; + lmid[biqs_outL] *= temp; + lmid[biqs_outR] *= temp; + bass[biqs_outL] *= temp; //if Stone gating, gate lmid and bass + bass[biqs_outR] *= temp; //note that we aren't compressing these + } + inputSampleL = (stoneL*stoneGain) + (fireL*fireGain) + (airL*airGain); + inputSampleR = (stoneR*stoneGain) + (fireR*fireGain) + (airR*airGain); + //create Stonefire output + + if (highpassEngage) { //distributed Highpass + highpass[hilp_temp] = (inputSampleL*highpass[hilp_c0])+highpass[hilp_cL1]; + highpass[hilp_cL1] = (inputSampleL*highpass[hilp_c1])-(highpass[hilp_temp]*highpass[hilp_d1])+highpass[hilp_cL2]; + highpass[hilp_cL2] = (inputSampleL*highpass[hilp_c0])-(highpass[hilp_temp]*highpass[hilp_d2]); inputSampleL = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleR*highpass[hilp_c0])+highpass[hilp_cR1]; + highpass[hilp_cR1] = (inputSampleR*highpass[hilp_c1])-(highpass[hilp_temp]*highpass[hilp_d1])+highpass[hilp_cR2]; + highpass[hilp_cR2] = (inputSampleR*highpass[hilp_c0])-(highpass[hilp_temp]*highpass[hilp_d2]); inputSampleR = highpass[hilp_temp]; + } else highpass[hilp_cR1] = highpass[hilp_cR2] = highpass[hilp_cL1] = highpass[hilp_cL2] = 0.0; + if (lowpassEngage) { //distributed Lowpass + lowpass[hilp_temp] = (inputSampleL*lowpass[hilp_c0])+lowpass[hilp_cL1]; + lowpass[hilp_cL1] = (inputSampleL*lowpass[hilp_c1])-(lowpass[hilp_temp]*lowpass[hilp_d1])+lowpass[hilp_cL2]; + lowpass[hilp_cL2] = (inputSampleL*lowpass[hilp_c0])-(lowpass[hilp_temp]*lowpass[hilp_d2]); inputSampleL = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleR*lowpass[hilp_c0])+lowpass[hilp_cR1]; + lowpass[hilp_cR1] = (inputSampleR*lowpass[hilp_c1])-(lowpass[hilp_temp]*lowpass[hilp_d1])+lowpass[hilp_cR2]; + lowpass[hilp_cR2] = (inputSampleR*lowpass[hilp_c0])-(lowpass[hilp_temp]*lowpass[hilp_d2]); inputSampleR = lowpass[hilp_temp]; + } else lowpass[hilp_cR1] = lowpass[hilp_cR2] = lowpass[hilp_cL1] = lowpass[hilp_cL2] = 0.0; + //another stage of Highpass/Lowpass before bringing in the parametric bands - //begin ResEQ2 Mid Boost - mpc++; if (mpc < 1 || mpc > 2001) mpc = 1; - mpkL[mpc] = midL; - mpkR[mpc] = midR; - double midPeakL = 0.0; - double midPeakR = 0.0; - for (int x = 0; x < maxMPeak; x++) { - int y = x*cycleEnd; - switch (cycleEnd) - { - case 1: - midPeakL += (mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x]); - midPeakR += (mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x]); break; - case 2: - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.5); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.5); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.5); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.5); break; - case 3: - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.333); break; - case 4: - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); y--; - midPeakL += ((mpkL[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); - midPeakR += ((mpkR[(mpc-y)+((mpc-y < 1)?2001:0)] * f[x])*0.25); //break - } - }//end ResEQ2 Mid Boost creating - - inputSampleL = ((bassL*bassGain) + (midL*midGain) + (midPeakL*mPeak) + (trebleL*trebleGain)) * gainL * gain; - inputSampleR = ((bassR*bassGain) + (midR*midGain) + (midPeakR*mPeak) + (trebleR*trebleGain)) * gainR * gain; + inputSampleL += (high[biqs_outL] + hmid[biqs_outL] + lmid[biqs_outL] + bass[biqs_outL]); + inputSampleR += (high[biqs_outR] + hmid[biqs_outR] + lmid[biqs_outR] + bass[biqs_outR]); + //add parametric boosts or cuts: clean as possible for maximal rawness and sonority + + inputSampleL = inputSampleL * gainL * gain; + inputSampleR = inputSampleR * gainR * gain; //applies pan section, and smoothed fader gain inputSampleL *= topdB; @@ -543,19 +1231,39 @@ void ConsoleXChannel::processDoubleReplacing(double **inputs, double **outputs, dBdly++; inputSampleR += dBaR[dBaXR-dBdly +((dBaXR-dBdly < 0)?dscBuf:0)]*dBi; dBaXR++; if (dBaXR < 0 || dBaXR >= dscBuf) dBaXR = 0; inputSampleR /= topdB; - //top dB processing for distributed discontinuity modeling air nonlinearity + //top dB processing for distributed discontinuity modeling air nonlinearity + //ConsoleXChannel before final Highpass/Lowpass stages inputSampleL *= 0.618033988749895; if (inputSampleL > 1.0) inputSampleL = 1.0; else if (inputSampleL > 0.0) inputSampleL = -expm1((log1p(-inputSampleL) * 1.618033988749895)); if (inputSampleL < -1.0) inputSampleL = -1.0; else if (inputSampleL < 0.0) inputSampleL = expm1((log1p(inputSampleL) * 1.618033988749895)); - inputSampleR *= 0.618033988749895; if (inputSampleR > 1.0) inputSampleR = 1.0; else if (inputSampleR > 0.0) inputSampleR = -expm1((log1p(-inputSampleR) * 1.618033988749895)); if (inputSampleR < -1.0) inputSampleR = -1.0; else if (inputSampleR < 0.0) inputSampleR = expm1((log1p(inputSampleR) * 1.618033988749895)); + //ConsoleXChannel before final Highpass/Lowpass stages + + if (highpassEngage) { //distributed Highpass + highpass[hilp_temp] = (inputSampleL*highpass[hilp_e0])+highpass[hilp_eL1]; + highpass[hilp_eL1] = (inputSampleL*highpass[hilp_e1])-(highpass[hilp_temp]*highpass[hilp_f1])+highpass[hilp_eL2]; + highpass[hilp_eL2] = (inputSampleL*highpass[hilp_e0])-(highpass[hilp_temp]*highpass[hilp_f2]); inputSampleL = highpass[hilp_temp]; + highpass[hilp_temp] = (inputSampleR*highpass[hilp_e0])+highpass[hilp_eR1]; + highpass[hilp_eR1] = (inputSampleR*highpass[hilp_e1])-(highpass[hilp_temp]*highpass[hilp_f1])+highpass[hilp_eR2]; + highpass[hilp_eR2] = (inputSampleR*highpass[hilp_e0])-(highpass[hilp_temp]*highpass[hilp_f2]); inputSampleR = highpass[hilp_temp]; + } else highpass[hilp_eR1] = highpass[hilp_eR2] = highpass[hilp_eL1] = highpass[hilp_eL2] = 0.0; + if (lowpassEngage) { //distributed Lowpass + lowpass[hilp_temp] = (inputSampleL*lowpass[hilp_e0])+lowpass[hilp_eL1]; + lowpass[hilp_eL1] = (inputSampleL*lowpass[hilp_e1])-(lowpass[hilp_temp]*lowpass[hilp_f1])+lowpass[hilp_eL2]; + lowpass[hilp_eL2] = (inputSampleL*lowpass[hilp_e0])-(lowpass[hilp_temp]*lowpass[hilp_f2]); inputSampleL = lowpass[hilp_temp]; + lowpass[hilp_temp] = (inputSampleR*lowpass[hilp_e0])+lowpass[hilp_eR1]; + lowpass[hilp_eR1] = (inputSampleR*lowpass[hilp_e1])-(lowpass[hilp_temp]*lowpass[hilp_f1])+lowpass[hilp_eR2]; + lowpass[hilp_eR2] = (inputSampleR*lowpass[hilp_e0])-(lowpass[hilp_temp]*lowpass[hilp_f2]); inputSampleR = lowpass[hilp_temp]; + } else lowpass[hilp_eR1] = lowpass[hilp_eR2] = lowpass[hilp_eL1] = lowpass[hilp_eL2] = 0.0; + //final Highpass/Lowpass continues to address aliasing + //final stacked biquad section is the softest Q for smoothness //begin 64 bit stereo floating point dither //int expon; frexp((double)inputSampleL, &expon); diff --git a/src/autogen_airwin/Distance3.cpp b/src/autogen_airwin/Distance3.cpp new file mode 100644 index 0000000..3743c08 --- /dev/null +++ b/src/autogen_airwin/Distance3.cpp @@ -0,0 +1,158 @@ +/* ======================================== + * Distance3 - Distance3.h + * Copyright (c) airwindows, Airwindows uses the MIT license + * ======================================== */ + +#ifndef __Distance3_H +#include "Distance3.h" +#endif +#include +#include +namespace airwinconsolidated::Distance3 { + +AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new Distance3(audioMaster);} + +Distance3::Distance3(audioMasterCallback audioMaster) : + AudioEffectX(audioMaster, kNumPrograms, kNumParameters) +{ + A = 0.5; + B = 0.5; + C = 1.0; + + prevresultAL = lastclampAL = clampAL = changeAL = lastAL = 0.0; + prevresultBL = lastclampBL = clampBL = changeBL = lastBL = 0.0; + prevresultCL = lastclampCL = clampCL = changeCL = lastCL = 0.0; + prevresultAR = lastclampAR = clampAR = changeAR = lastAR = 0.0; + prevresultBR = lastclampBR = clampBR = changeBR = lastBR = 0.0; + prevresultCR = lastclampCR = clampCR = changeCR = lastCR = 0.0; + for(int count = 0; count < dscBuf+2; count++) { + dBaL[count] = 0.0; + dBbL[count] = 0.0; + dBcL[count] = 0.0; + dBaR[count] = 0.0; + dBbR[count] = 0.0; + dBcR[count] = 0.0; + } + dBaPosL = 0.0; + dBbPosL = 0.0; + dBcPosL = 0.0; + dBaPosR = 0.0; + dBbPosR = 0.0; + dBcPosR = 0.0; + dBaXL = 1; + dBbXL = 1; + dBcXL = 1; + dBaXR = 1; + dBbXR = 1; + dBcXR = 1; + + 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 +} + +Distance3::~Distance3() {} +VstInt32 Distance3::getVendorVersion () {return 1000;} +void Distance3::setProgramName(char *name) {vst_strncpy (_programName, name, kVstMaxProgNameLen);} +void Distance3::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; +} + +void Distance3::setParameter(VstInt32 index, float value) { + switch (index) { + case kParamA: A = value; break; + case kParamB: B = value; break; + case kParamC: C = value; break; + default: break; // unknown parameter, shouldn't happen! + } +} + +float Distance3::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 Distance3::getParameterName(VstInt32 index, char *text) { + switch (index) { + case kParamA: vst_strncpy (text, "Distance", kVstMaxParamStrLen); break; + case kParamB: vst_strncpy (text, "Top dB", kVstMaxParamStrLen); break; + case kParamC: 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 Distance3::getParameterDisplay(VstInt32 index, char *text) { + switch (index) { + case kParamA: float2string (A*10.0, text, kVstMaxParamStrLen); break; + case kParamB: float2string ((B*70.0)+70.0, text, kVstMaxParamStrLen); break; + case kParamC: float2string (C, text, kVstMaxParamStrLen); break; + default: break; // unknown parameter, shouldn't happen! + } //this displays the values and handles 'popups' where it's discrete choices +} + +void Distance3::getParameterLabel(VstInt32 index, char *text) { + switch (index) { + case kParamA: vst_strncpy (text, "miles", kVstMaxParamStrLen); break; + case kParamB: vst_strncpy (text, "dB", kVstMaxParamStrLen); break; + case kParamC: vst_strncpy (text, "", kVstMaxParamStrLen); break; + default: break; // unknown parameter, shouldn't happen! + } +} + +VstInt32 Distance3::canDo(char *text) +{ return (_canDo.find(text) == _canDo.end()) ? -1: 1; } // 1 = yes, -1 = no, 0 = don't know + +bool Distance3::getEffectName(char* name) { + vst_strncpy(name, "Distance3", kVstMaxProductStrLen); return true; +} + +VstPlugCategory Distance3::getPlugCategory() {return kPlugCategEffect;} + +bool Distance3::getProductString(char* text) { + vst_strncpy (text, "airwindows Distance3", kVstMaxProductStrLen); return true; +} + +bool Distance3::getVendorString(char* text) { + vst_strncpy (text, "airwindows", kVstMaxVendorStrLen); return true; +} +bool Distance3::parameterTextToValue(VstInt32 index, const char *text, float &value) { + switch(index) { + case kParamA: { auto b = string2float(text, value); if (b) { value = value / (10.0); } return b; break; } + case kParamB: { auto b = string2float(text, value); if (b) { value = (value - 70.0) / (70.0); } return b; break; } + case kParamC: { auto b = string2float(text, value); return b; break; } + + } + return false; +} +bool Distance3::canConvertParameterTextToValue(VstInt32 index) { + switch(index) { + case kParamA: return true; + case kParamB: return true; + case kParamC: return true; + + } + return false; +} +} // end namespace diff --git a/src/autogen_airwin/Distance3.h b/src/autogen_airwin/Distance3.h new file mode 100644 index 0000000..3befdc0 --- /dev/null +++ b/src/autogen_airwin/Distance3.h @@ -0,0 +1,131 @@ +/* ======================================== + * Distance3 - Distance3.h + * Created 8/12/11 by SPIAdmin + * Copyright (c) Airwindows, Airwindows uses the MIT license + * ======================================== */ + +#ifndef __Distance3_Distance3_H +#define __Distance3_Distance3_H + +#ifndef __audioeffect__ +#include "../airwin_consolidated_base.h" +#endif + +#include +#include +#include + +namespace airwinconsolidated::Distance3 { +enum { + kParamA =0, + kParamB =1, + kParamC =2, + kNumParameters = 3 +}; // +const int dscBuf = 90; + +const int kNumPrograms = 0; +const int kNumInputs = 2; +const int kNumOutputs = 2; +const unsigned long kUniqueId = 'disv'; //Change this to what the AU identity is! + +class Distance3 : + public AudioEffectX +{ +public: + Distance3(audioMasterCallback audioMaster); + ~Distance3(); + 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 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 + // Added by the perl as inverses + virtual bool parameterTextToValue(VstInt32 index, const char *text, float &value); + virtual bool canConvertParameterTextToValue(VstInt32 index); + virtual VstInt32 canDo(char *text); +private: + char _programName[kVstMaxProgNameLen + 1]; + std::set< std::string > _canDo; + + float A; + float B; + float C; + + double lastclampAL; + double clampAL; + double changeAL; + double prevresultAL; + double lastAL; + + double lastclampBL; + double clampBL; + double changeBL; + double prevresultBL; + double lastBL; + + double lastclampCL; + double clampCL; + double changeCL; + double prevresultCL; + double lastCL; + + double dBaL[dscBuf+5]; + double dBaPosL; + int dBaXL; + + double dBbL[dscBuf+5]; + double dBbPosL; + int dBbXL; + + double dBcL[dscBuf+5]; + double dBcPosL; + int dBcXL; + + double lastclampAR; + double clampAR; + double changeAR; + double prevresultAR; + double lastAR; + + double lastclampBR; + double clampBR; + double changeBR; + double prevresultBR; + double lastBR; + + double lastclampCR; + double clampCR; + double changeCR; + double prevresultCR; + double lastCR; + + double dBaR[dscBuf+5]; + double dBaPosR; + int dBaXR; + + double dBbR[dscBuf+5]; + double dBbPosR; + int dBbXR; + + double dBcR[dscBuf+5]; + double dBcPosR; + int dBcXR; + + + uint32_t fpdL; + uint32_t fpdR; + //default stuff +}; + +#endif +} // end namespace diff --git a/src/autogen_airwin/Distance3Proc.cpp b/src/autogen_airwin/Distance3Proc.cpp new file mode 100644 index 0000000..b3a36f1 --- /dev/null +++ b/src/autogen_airwin/Distance3Proc.cpp @@ -0,0 +1,374 @@ +/* ======================================== + * Distance3 - Distance3.h + * Copyright (c) airwindows, Airwindows uses the MIT license + * ======================================== */ + +#ifndef __Distance3_H +#include "Distance3.h" +#endif +namespace airwinconsolidated::Distance3 { + +void Distance3::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames) +{ + float* in1 = inputs[0]; + float* in2 = inputs[1]; + float* out1 = outputs[0]; + float* out2 = outputs[1]; + + double overallscale = 1.0; + overallscale /= 44100.0; + overallscale *= getSampleRate(); + double softslew = (A*100.0)+0.5; + softslew *= overallscale; + double outslew = softslew * (1.0-(A*0.333)); + double refdB = (B*70.0)+70.0; + double topdB = 0.000000075 * pow(10.0,refdB/20.0) * overallscale; + double wet = C; + + while (--sampleFrames >= 0) + { + double inputSampleL = *in1; + double inputSampleR = *in2; + if (fabs(inputSampleL)<1.18e-23) inputSampleL = fpdL * 1.18e-17; + if (fabs(inputSampleR)<1.18e-23) inputSampleR = fpdR * 1.18e-17; + double drySampleL = inputSampleL; + double drySampleR = inputSampleR; + + inputSampleL *= softslew; + lastclampAL = clampAL; clampAL = inputSampleL - lastAL; + double postfilter = changeAL = fabs(clampAL - lastclampAL); + postfilter += (softslew / 2.0); + inputSampleL /= outslew; + inputSampleL += (prevresultAL * postfilter); + inputSampleL /= (postfilter + 1.0); + prevresultAL = inputSampleL; + //do an IIR like thing to further squish superdistant stuff + + inputSampleL *= topdB; + if (inputSampleL < -0.222) inputSampleL = -0.222; if (inputSampleL > 0.222) inputSampleL = 0.222; + //Air Discontinuity A begin + dBaL[dBaXL] = inputSampleL; dBaPosL *= 0.5; dBaPosL += fabs((inputSampleL*((inputSampleL*0.25)-0.5))*0.5); + int dBdly = floor(dBaPosL*dscBuf); + double dBi = (dBaPosL*dscBuf)-dBdly; + inputSampleL = dBaL[dBaXL-dBdly +((dBaXL-dBdly < 0)?dscBuf:0)]*(1.0-dBi); + dBdly++; inputSampleL += dBaL[dBaXL-dBdly +((dBaXL-dBdly < 0)?dscBuf:0)]*dBi; + dBaXL++; if (dBaXL < 0 || dBaXL >= dscBuf) dBaXL = 0; + //Air Discontinuity A end + inputSampleL /= topdB; + + inputSampleL *= softslew; + lastclampBL = clampBL; clampBL = inputSampleL - lastBL; + postfilter = changeBL = fabs(clampBL - lastclampBL); + postfilter += (softslew / 2.0); + lastBL = inputSampleL; + inputSampleL /= outslew; + inputSampleL += (prevresultBL * postfilter); + inputSampleL /= (postfilter + 1.0); + prevresultBL = inputSampleL; + //do an IIR like thing to further squish superdistant stuff + + inputSampleL *= topdB; + if (inputSampleL < -0.222) inputSampleL = -0.222; if (inputSampleL > 0.222) inputSampleL = 0.222; + //Air Discontinuity B begin + dBbL[dBbXL] = inputSampleL; dBbPosL *= 0.5; dBbPosL += fabs((inputSampleL*((inputSampleL*0.25)-0.5))*0.5); + dBdly = floor(dBbPosL*dscBuf); dBi = (dBbPosL*dscBuf)-dBdly; + inputSampleL = dBbL[dBbXL-dBdly +((dBbXL-dBdly < 0)?dscBuf:0)]*(1.0-dBi); + dBdly++; inputSampleL += dBbL[dBbXL-dBdly +((dBbXL-dBdly < 0)?dscBuf:0)]*dBi; + dBbXL++; if (dBbXL < 0 || dBbXL >= dscBuf) dBbXL = 0; + //Air Discontinuity B end + inputSampleL /= topdB; + + inputSampleL *= softslew; + lastclampCL = clampCL; clampCL = inputSampleL - lastCL; + postfilter = changeCL = fabs(clampCL - lastclampCL); + postfilter += (softslew / 2.0); + lastCL = inputSampleL; + inputSampleL /= softslew; //don't boost the final time! + inputSampleL += (prevresultCL * postfilter); + inputSampleL /= (postfilter + 1.0); + prevresultCL = inputSampleL; + //do an IIR like thing to further squish superdistant stuff + + inputSampleL *= topdB; + if (inputSampleL < -0.222) inputSampleL = -0.222; if (inputSampleL > 0.222) inputSampleL = 0.222; + //Air Discontinuity C begin + dBcL[dBcXL] = inputSampleL; dBcPosL *= 0.5; dBcPosL += fabs((inputSampleL*((inputSampleL*0.25)-0.5))*0.5); + dBdly = floor(dBcPosL*dscBuf); dBi = (dBcPosL*dscBuf)-dBdly; + inputSampleL = dBcL[dBcXL-dBdly +((dBcXL-dBdly < 0)?dscBuf:0)]*(1.0-dBi); + dBdly++; inputSampleL += dBcL[dBcXL-dBdly +((dBcXL-dBdly < 0)?dscBuf:0)]*dBi; + dBcXL++; if (dBcXL < 0 || dBcXL >= dscBuf) dBcXL = 0; + //Air Discontinuity C end + inputSampleL /= topdB; + + if (wet < 1.0) inputSampleL = (drySampleL * (1.0-wet))+(inputSampleL*wet); + + + inputSampleR *= softslew; + lastclampAR = clampAR; clampAR = inputSampleR - lastAR; + postfilter = changeAR = fabs(clampAR - lastclampAR); + postfilter += (softslew / 2.0); + inputSampleR /= outslew; + inputSampleR += (prevresultAR * postfilter); + inputSampleR /= (postfilter + 1.0); + prevresultAR = inputSampleR; + //do an IIR like thing to further squish superdistant stuff + + inputSampleR *= topdB; + if (inputSampleR < -0.222) inputSampleR = -0.222; if (inputSampleR > 0.222) inputSampleR = 0.222; + //Air Discontinuity A begin + dBaR[dBaXR] = inputSampleR; dBaPosR *= 0.5; dBaPosR += fabs((inputSampleR*((inputSampleR*0.25)-0.5))*0.5); + dBdly = floor(dBaPosR*dscBuf); + dBi = (dBaPosR*dscBuf)-dBdly; + inputSampleR = dBaR[dBaXR-dBdly +((dBaXR-dBdly < 0)?dscBuf:0)]*(1.0-dBi); + dBdly++; inputSampleR += dBaR[dBaXR-dBdly +((dBaXR-dBdly < 0)?dscBuf:0)]*dBi; + dBaXR++; if (dBaXR < 0 || dBaXR >= dscBuf) dBaXR = 0; + //Air Discontinuity A end + inputSampleR /= topdB; + + inputSampleR *= softslew; + lastclampBR = clampBR; clampBR = inputSampleR - lastBR; + postfilter = changeBR = fabs(clampBR - lastclampBR); + postfilter += (softslew / 2.0); + lastBR = inputSampleR; + inputSampleR /= outslew; + inputSampleR += (prevresultBR * postfilter); + inputSampleR /= (postfilter + 1.0); + prevresultBR = inputSampleR; + //do an IIR like thing to further squish superdistant stuff + + inputSampleR *= topdB; + if (inputSampleR < -0.222) inputSampleR = -0.222; if (inputSampleR > 0.222) inputSampleR = 0.222; + //Air Discontinuity B begin + dBbR[dBbXR] = inputSampleR; dBbPosR *= 0.5; dBbPosR += fabs((inputSampleR*((inputSampleR*0.25)-0.5))*0.5); + dBdly = floor(dBbPosR*dscBuf); dBi = (dBbPosR*dscBuf)-dBdly; + inputSampleR = dBbR[dBbXR-dBdly +((dBbXR-dBdly < 0)?dscBuf:0)]*(1.0-dBi); + dBdly++; inputSampleR += dBbR[dBbXR-dBdly +((dBbXR-dBdly < 0)?dscBuf:0)]*dBi; + dBbXR++; if (dBbXR < 0 || dBbXR >= dscBuf) dBbXR = 0; + //Air Discontinuity B end + inputSampleR /= topdB; + + inputSampleR *= softslew; + lastclampCR = clampCR; clampCR = inputSampleR - lastCR; + postfilter = changeCR = fabs(clampCR - lastclampCR); + postfilter += (softslew / 2.0); + lastCR = inputSampleR; + inputSampleR /= softslew; //don't boost the final time! + inputSampleR += (prevresultCR * postfilter); + inputSampleR /= (postfilter + 1.0); + prevresultCR = inputSampleR; + //do an IIR like thing to further squish superdistant stuff + + inputSampleR *= topdB; + if (inputSampleR < -0.222) inputSampleR = -0.222; if (inputSampleR > 0.222) inputSampleR = 0.222; + //Air Discontinuity C begin + dBcR[dBcXR] = inputSampleR; dBcPosR *= 0.5; dBcPosR += fabs((inputSampleR*((inputSampleR*0.25)-0.5))*0.5); + dBdly = floor(dBcPosR*dscBuf); dBi = (dBcPosR*dscBuf)-dBdly; + inputSampleR = dBcR[dBcXR-dBdly +((dBcXR-dBdly < 0)?dscBuf:0)]*(1.0-dBi); + dBdly++; inputSampleR += dBcR[dBcXR-dBdly +((dBcXR-dBdly < 0)?dscBuf:0)]*dBi; + dBcXR++; if (dBcXR < 0 || dBcXR >= dscBuf) dBcXR = 0; + //Air Discontinuity C end + inputSampleR /= topdB; + + if (wet < 1.0) inputSampleR = (drySampleR * (1.0-wet))+(inputSampleR*wet); + + //begin 32 bit stereo floating point dither + int expon; frexpf((float)inputSampleL, &expon); + fpdL ^= fpdL << 13; fpdL ^= fpdL >> 17; fpdL ^= fpdL << 5; + inputSampleL += ((double(fpdL)-uint32_t(0x7fffffff)) * 5.5e-36l * pow(2,expon+62)); + frexpf((float)inputSampleR, &expon); + fpdR ^= fpdR << 13; fpdR ^= fpdR >> 17; fpdR ^= fpdR << 5; + inputSampleR += ((double(fpdR)-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 Distance3::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames) +{ + double* in1 = inputs[0]; + double* in2 = inputs[1]; + double* out1 = outputs[0]; + double* out2 = outputs[1]; + + double overallscale = 1.0; + overallscale /= 44100.0; + overallscale *= getSampleRate(); + double softslew = (A*100.0)+0.5; + softslew *= overallscale; + double outslew = softslew * (1.0-(A*0.333)); + double refdB = (B*70.0)+70.0; + double topdB = 0.000000075 * pow(10.0,refdB/20.0) * overallscale; + double wet = C; + + while (--sampleFrames >= 0) + { + double inputSampleL = *in1; + double inputSampleR = *in2; + if (fabs(inputSampleL)<1.18e-23) inputSampleL = fpdL * 1.18e-17; + if (fabs(inputSampleR)<1.18e-23) inputSampleR = fpdR * 1.18e-17; + double drySampleL = inputSampleL; + double drySampleR = inputSampleR; + + inputSampleL *= softslew; + lastclampAL = clampAL; clampAL = inputSampleL - lastAL; + double postfilter = changeAL = fabs(clampAL - lastclampAL); + postfilter += (softslew / 2.0); + inputSampleL /= outslew; + inputSampleL += (prevresultAL * postfilter); + inputSampleL /= (postfilter + 1.0); + prevresultAL = inputSampleL; + //do an IIR like thing to further squish superdistant stuff + + inputSampleL *= topdB; + if (inputSampleL < -0.222) inputSampleL = -0.222; if (inputSampleL > 0.222) inputSampleL = 0.222; + //Air Discontinuity A begin + dBaL[dBaXL] = inputSampleL; dBaPosL *= 0.5; dBaPosL += fabs((inputSampleL*((inputSampleL*0.25)-0.5))*0.5); + int dBdly = floor(dBaPosL*dscBuf); + double dBi = (dBaPosL*dscBuf)-dBdly; + inputSampleL = dBaL[dBaXL-dBdly +((dBaXL-dBdly < 0)?dscBuf:0)]*(1.0-dBi); + dBdly++; inputSampleL += dBaL[dBaXL-dBdly +((dBaXL-dBdly < 0)?dscBuf:0)]*dBi; + dBaXL++; if (dBaXL < 0 || dBaXL >= dscBuf) dBaXL = 0; + //Air Discontinuity A end + inputSampleL /= topdB; + + inputSampleL *= softslew; + lastclampBL = clampBL; clampBL = inputSampleL - lastBL; + postfilter = changeBL = fabs(clampBL - lastclampBL); + postfilter += (softslew / 2.0); + lastBL = inputSampleL; + inputSampleL /= outslew; + inputSampleL += (prevresultBL * postfilter); + inputSampleL /= (postfilter + 1.0); + prevresultBL = inputSampleL; + //do an IIR like thing to further squish superdistant stuff + + inputSampleL *= topdB; + if (inputSampleL < -0.222) inputSampleL = -0.222; if (inputSampleL > 0.222) inputSampleL = 0.222; + //Air Discontinuity B begin + dBbL[dBbXL] = inputSampleL; dBbPosL *= 0.5; dBbPosL += fabs((inputSampleL*((inputSampleL*0.25)-0.5))*0.5); + dBdly = floor(dBbPosL*dscBuf); dBi = (dBbPosL*dscBuf)-dBdly; + inputSampleL = dBbL[dBbXL-dBdly +((dBbXL-dBdly < 0)?dscBuf:0)]*(1.0-dBi); + dBdly++; inputSampleL += dBbL[dBbXL-dBdly +((dBbXL-dBdly < 0)?dscBuf:0)]*dBi; + dBbXL++; if (dBbXL < 0 || dBbXL >= dscBuf) dBbXL = 0; + //Air Discontinuity B end + inputSampleL /= topdB; + + inputSampleL *= softslew; + lastclampCL = clampCL; clampCL = inputSampleL - lastCL; + postfilter = changeCL = fabs(clampCL - lastclampCL); + postfilter += (softslew / 2.0); + lastCL = inputSampleL; + inputSampleL /= softslew; //don't boost the final time! + inputSampleL += (prevresultCL * postfilter); + inputSampleL /= (postfilter + 1.0); + prevresultCL = inputSampleL; + //do an IIR like thing to further squish superdistant stuff + + inputSampleL *= topdB; + if (inputSampleL < -0.222) inputSampleL = -0.222; if (inputSampleL > 0.222) inputSampleL = 0.222; + //Air Discontinuity C begin + dBcL[dBcXL] = inputSampleL; dBcPosL *= 0.5; dBcPosL += fabs((inputSampleL*((inputSampleL*0.25)-0.5))*0.5); + dBdly = floor(dBcPosL*dscBuf); dBi = (dBcPosL*dscBuf)-dBdly; + inputSampleL = dBcL[dBcXL-dBdly +((dBcXL-dBdly < 0)?dscBuf:0)]*(1.0-dBi); + dBdly++; inputSampleL += dBcL[dBcXL-dBdly +((dBcXL-dBdly < 0)?dscBuf:0)]*dBi; + dBcXL++; if (dBcXL < 0 || dBcXL >= dscBuf) dBcXL = 0; + //Air Discontinuity C end + inputSampleL /= topdB; + + if (wet < 1.0) inputSampleL = (drySampleL * (1.0-wet))+(inputSampleL*wet); + + + inputSampleR *= softslew; + lastclampAR = clampAR; clampAR = inputSampleR - lastAR; + postfilter = changeAR = fabs(clampAR - lastclampAR); + postfilter += (softslew / 2.0); + inputSampleR /= outslew; + inputSampleR += (prevresultAR * postfilter); + inputSampleR /= (postfilter + 1.0); + prevresultAR = inputSampleR; + //do an IIR like thing to further squish superdistant stuff + + inputSampleR *= topdB; + if (inputSampleR < -0.222) inputSampleR = -0.222; if (inputSampleR > 0.222) inputSampleR = 0.222; + //Air Discontinuity A begin + dBaR[dBaXR] = inputSampleR; dBaPosR *= 0.5; dBaPosR += fabs((inputSampleR*((inputSampleR*0.25)-0.5))*0.5); + dBdly = floor(dBaPosR*dscBuf); + dBi = (dBaPosR*dscBuf)-dBdly; + inputSampleR = dBaR[dBaXR-dBdly +((dBaXR-dBdly < 0)?dscBuf:0)]*(1.0-dBi); + dBdly++; inputSampleR += dBaR[dBaXR-dBdly +((dBaXR-dBdly < 0)?dscBuf:0)]*dBi; + dBaXR++; if (dBaXR < 0 || dBaXR >= dscBuf) dBaXR = 0; + //Air Discontinuity A end + inputSampleR /= topdB; + + inputSampleR *= softslew; + lastclampBR = clampBR; clampBR = inputSampleR - lastBR; + postfilter = changeBR = fabs(clampBR - lastclampBR); + postfilter += (softslew / 2.0); + lastBR = inputSampleR; + inputSampleR /= outslew; + inputSampleR += (prevresultBR * postfilter); + inputSampleR /= (postfilter + 1.0); + prevresultBR = inputSampleR; + //do an IIR like thing to further squish superdistant stuff + + inputSampleR *= topdB; + if (inputSampleR < -0.222) inputSampleR = -0.222; if (inputSampleR > 0.222) inputSampleR = 0.222; + //Air Discontinuity B begin + dBbR[dBbXR] = inputSampleR; dBbPosR *= 0.5; dBbPosR += fabs((inputSampleR*((inputSampleR*0.25)-0.5))*0.5); + dBdly = floor(dBbPosR*dscBuf); dBi = (dBbPosR*dscBuf)-dBdly; + inputSampleR = dBbR[dBbXR-dBdly +((dBbXR-dBdly < 0)?dscBuf:0)]*(1.0-dBi); + dBdly++; inputSampleR += dBbR[dBbXR-dBdly +((dBbXR-dBdly < 0)?dscBuf:0)]*dBi; + dBbXR++; if (dBbXR < 0 || dBbXR >= dscBuf) dBbXR = 0; + //Air Discontinuity B end + inputSampleR /= topdB; + + inputSampleR *= softslew; + lastclampCR = clampCR; clampCR = inputSampleR - lastCR; + postfilter = changeCR = fabs(clampCR - lastclampCR); + postfilter += (softslew / 2.0); + lastCR = inputSampleR; + inputSampleR /= softslew; //don't boost the final time! + inputSampleR += (prevresultCR * postfilter); + inputSampleR /= (postfilter + 1.0); + prevresultCR = inputSampleR; + //do an IIR like thing to further squish superdistant stuff + + inputSampleR *= topdB; + if (inputSampleR < -0.222) inputSampleR = -0.222; if (inputSampleR > 0.222) inputSampleR = 0.222; + //Air Discontinuity C begin + dBcR[dBcXR] = inputSampleR; dBcPosR *= 0.5; dBcPosR += fabs((inputSampleR*((inputSampleR*0.25)-0.5))*0.5); + dBdly = floor(dBcPosR*dscBuf); dBi = (dBcPosR*dscBuf)-dBdly; + inputSampleR = dBcR[dBcXR-dBdly +((dBcXR-dBdly < 0)?dscBuf:0)]*(1.0-dBi); + dBdly++; inputSampleR += dBcR[dBcXR-dBdly +((dBcXR-dBdly < 0)?dscBuf:0)]*dBi; + dBcXR++; if (dBcXR < 0 || dBcXR >= dscBuf) dBcXR = 0; + //Air Discontinuity C end + inputSampleR /= topdB; + + if (wet < 1.0) inputSampleR = (drySampleR * (1.0-wet))+(inputSampleR*wet); + + //begin 64 bit stereo floating point dither + //int expon; frexp((double)inputSampleL, &expon); + fpdL ^= fpdL << 13; fpdL ^= fpdL >> 17; fpdL ^= fpdL << 5; + //inputSampleL += ((double(fpdL)-uint32_t(0x7fffffff)) * 1.1e-44l * pow(2,expon+62)); + //frexp((double)inputSampleR, &expon); + fpdR ^= fpdR << 13; fpdR ^= fpdR >> 17; fpdR ^= fpdR << 5; + //inputSampleR += ((double(fpdR)-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++; + } +} +} // end namespace diff --git a/src/autogen_airwin/Parametric.cpp b/src/autogen_airwin/Parametric.cpp new file mode 100644 index 0000000..8edaae7 --- /dev/null +++ b/src/autogen_airwin/Parametric.cpp @@ -0,0 +1,193 @@ +/* ======================================== + * Parametric - Parametric.h + * Copyright (c) airwindows, Airwindows uses the MIT license + * ======================================== */ + +#ifndef __Parametric_H +#include "Parametric.h" +#endif +#include +#include +namespace airwinconsolidated::Parametric { + +AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new Parametric(audioMaster);} + +Parametric::Parametric(audioMasterCallback audioMaster) : + AudioEffectX(audioMaster, kNumPrograms, kNumParameters) +{ + A = 0.5; + B = 0.5; + C = 0.5; + D = 0.5; + E = 0.5; + F = 0.5; + G = 0.5; + H = 0.5; + I = 0.5; + J = 1.0; + + for (int x = 0; x < biqs_total; x++) { + high[x] = 0.0; + hmid[x] = 0.0; + lmid[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 +} + +Parametric::~Parametric() {} +VstInt32 Parametric::getVendorVersion () {return 1000;} +void Parametric::setProgramName(char *name) {vst_strncpy (_programName, name, kVstMaxProgNameLen);} +void Parametric::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; +} + +void Parametric::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; + case kParamF: F = value; break; + case kParamG: G = value; break; + case kParamH: H = value; break; + case kParamI: I = value; break; + case kParamJ: J = value; break; + default: break; // unknown parameter, shouldn't happen! + } +} + +float Parametric::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; + case kParamF: return F; break; + case kParamG: return G; break; + case kParamH: return H; break; + case kParamI: return I; break; + case kParamJ: return J; 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 Parametric::getParameterName(VstInt32 index, char *text) { + switch (index) { + case kParamA: vst_strncpy (text, "Tr Freq", kVstMaxParamStrLen); break; + case kParamB: vst_strncpy (text, "Treble", kVstMaxParamStrLen); break; + case kParamC: vst_strncpy (text, "Tr Reso", kVstMaxParamStrLen); break; + case kParamD: vst_strncpy (text, "HM Freq", kVstMaxParamStrLen); break; + case kParamE: vst_strncpy (text, "HighMid", kVstMaxParamStrLen); break; + case kParamF: vst_strncpy (text, "HM Reso", kVstMaxParamStrLen); break; + case kParamG: vst_strncpy (text, "LM Freq", kVstMaxParamStrLen); break; + case kParamH: vst_strncpy (text, "LowMid", kVstMaxParamStrLen); break; + case kParamI: vst_strncpy (text, "LM Reso", kVstMaxParamStrLen); break; + case kParamJ: 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 Parametric::getParameterDisplay(VstInt32 index, char *text) { + switch (index) { + case kParamA: float2string (A, text, kVstMaxParamStrLen); break; + case kParamB: float2string (B, text, kVstMaxParamStrLen); break; + case kParamC: float2string (C, text, kVstMaxParamStrLen); break; + case kParamD: float2string (D, text, kVstMaxParamStrLen); break; + case kParamE: float2string (E, text, kVstMaxParamStrLen); break; + case kParamF: float2string (F, text, kVstMaxParamStrLen); break; + case kParamG: float2string (G, text, kVstMaxParamStrLen); break; + case kParamH: float2string (H, text, kVstMaxParamStrLen); break; + case kParamI: float2string (I, text, kVstMaxParamStrLen); break; + case kParamJ: float2string (J, text, kVstMaxParamStrLen); break; + default: break; // unknown parameter, shouldn't happen! + } //this displays the values and handles 'popups' where it's discrete choices +} + +void Parametric::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; + case kParamF: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamG: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamH: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamI: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamJ: vst_strncpy (text, "", kVstMaxParamStrLen); break; + default: break; // unknown parameter, shouldn't happen! + } +} + +VstInt32 Parametric::canDo(char *text) +{ return (_canDo.find(text) == _canDo.end()) ? -1: 1; } // 1 = yes, -1 = no, 0 = don't know + +bool Parametric::getEffectName(char* name) { + vst_strncpy(name, "Parametric", kVstMaxProductStrLen); return true; +} + +VstPlugCategory Parametric::getPlugCategory() {return kPlugCategEffect;} + +bool Parametric::getProductString(char* text) { + vst_strncpy (text, "airwindows Parametric", kVstMaxProductStrLen); return true; +} + +bool Parametric::getVendorString(char* text) { + vst_strncpy (text, "airwindows", kVstMaxVendorStrLen); return true; +} +bool Parametric::parameterTextToValue(VstInt32 index, const char *text, float &value) { + switch(index) { + case kParamA: { auto b = string2float(text, value); return b; break; } + case kParamB: { auto b = string2float(text, value); return b; break; } + case kParamC: { auto b = string2float(text, value); return b; break; } + case kParamD: { auto b = string2float(text, value); return b; break; } + case kParamE: { auto b = string2float(text, value); return b; break; } + case kParamF: { auto b = string2float(text, value); return b; break; } + case kParamG: { auto b = string2float(text, value); return b; break; } + case kParamH: { auto b = string2float(text, value); return b; break; } + case kParamI: { auto b = string2float(text, value); return b; break; } + case kParamJ: { auto b = string2float(text, value); return b; break; } + + } + return false; +} +bool Parametric::canConvertParameterTextToValue(VstInt32 index) { + switch(index) { + case kParamA: return true; + case kParamB: return true; + case kParamC: return true; + case kParamD: return true; + case kParamE: return true; + case kParamF: return true; + case kParamG: return true; + case kParamH: return true; + case kParamI: return true; + case kParamJ: return true; + + } + return false; +} +} // end namespace diff --git a/src/autogen_airwin/Parametric.h b/src/autogen_airwin/Parametric.h new file mode 100644 index 0000000..566c539 --- /dev/null +++ b/src/autogen_airwin/Parametric.h @@ -0,0 +1,98 @@ +/* ======================================== + * Parametric - Parametric.h + * Created 8/12/11 by SPIAdmin + * Copyright (c) Airwindows, Airwindows uses the MIT license + * ======================================== */ + +#ifndef __Parametric_Parametric_H +#define __Parametric_Parametric_H + +#ifndef __audioeffect__ +#include "../airwin_consolidated_base.h" +#endif + +#include +#include +#include + +namespace airwinconsolidated::Parametric { +enum { + kParamA =0, + kParamB =1, + kParamC =2, + kParamD =3, + kParamE =4, + kParamF =5, + kParamG =6, + kParamH =7, + kParamI =8, + kParamJ =9, + kNumParameters = 10 +}; // + +const int kNumPrograms = 0; +const int kNumInputs = 2; +const int kNumOutputs = 2; +const unsigned long kUniqueId = 'para'; //Change this to what the AU identity is! + +class Parametric : + public AudioEffectX +{ +public: + Parametric(audioMasterCallback audioMaster); + ~Parametric(); + 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 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 + // Added by the perl as inverses + virtual bool parameterTextToValue(VstInt32 index, const char *text, float &value); + virtual bool canConvertParameterTextToValue(VstInt32 index); + virtual VstInt32 canDo(char *text); +private: + char _programName[kVstMaxProgNameLen + 1]; + std::set< std::string > _canDo; + + float A; + float B; + float C; + float D; + float E; + float F; + float G; + float H; + float I; + float J; + + enum { + biqs_freq, biqs_reso, biqs_level, + biqs_nonlin, biqs_temp, biqs_dis, + biqs_a0, biqs_a1, biqs_b1, biqs_b2, + biqs_c0, biqs_c1, biqs_d1, biqs_d2, + biqs_e0, biqs_e1, biqs_f1, biqs_f2, + biqs_aL1, biqs_aL2, biqs_aR1, biqs_aR2, + biqs_cL1, biqs_cL2, biqs_cR1, biqs_cR2, + biqs_eL1, biqs_eL2, biqs_eR1, biqs_eR2, + biqs_outL, biqs_outR, biqs_total + }; + double high[biqs_total]; + double hmid[biqs_total]; + double lmid[biqs_total]; + + uint32_t fpdL; + uint32_t fpdR; + //default stuff +}; + +#endif +} // end namespace diff --git a/src/autogen_airwin/ParametricProc.cpp b/src/autogen_airwin/ParametricProc.cpp new file mode 100644 index 0000000..bb4b063 --- /dev/null +++ b/src/autogen_airwin/ParametricProc.cpp @@ -0,0 +1,500 @@ +/* ======================================== + * Parametric - Parametric.h + * Copyright (c) airwindows, Airwindows uses the MIT license + * ======================================== */ + +#ifndef __Parametric_H +#include "Parametric.h" +#endif +namespace airwinconsolidated::Parametric { + +void Parametric::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames) +{ + float* in1 = inputs[0]; + float* in2 = inputs[1]; + float* out1 = outputs[0]; + float* out2 = outputs[1]; + + double overallscale = 1.0; + overallscale /= 44100.0; + overallscale *= getSampleRate(); + + high[biqs_freq] = (((pow(A,3)*14500.0)+1500.0)/getSampleRate()); + if (high[biqs_freq] < 0.0001) high[biqs_freq] = 0.0001; + high[biqs_nonlin] = B; + high[biqs_level] = (high[biqs_nonlin]*2.0)-1.0; + if (high[biqs_level] > 0.0) high[biqs_level] *= 2.0; + high[biqs_reso] = ((0.5+(high[biqs_nonlin]*0.5)+sqrt(high[biqs_freq]))-(1.0-pow(1.0-C,2.0)))+0.5+(high[biqs_nonlin]*0.5); + double K = tan(M_PI * high[biqs_freq]); + double norm = 1.0 / (1.0 + K / (high[biqs_reso]*1.93185165) + K * K); + high[biqs_a0] = K / (high[biqs_reso]*1.93185165) * norm; + high[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + high[biqs_b2] = (1.0 - K / (high[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (high[biqs_reso]*0.70710678) + K * K); + high[biqs_c0] = K / (high[biqs_reso]*0.70710678) * norm; + high[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + high[biqs_d2] = (1.0 - K / (high[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (high[biqs_reso]*0.51763809) + K * K); + high[biqs_e0] = K / (high[biqs_reso]*0.51763809) * norm; + high[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + high[biqs_f2] = (1.0 - K / (high[biqs_reso]*0.51763809) + K * K) * norm; + //high + + hmid[biqs_freq] = (((pow(D,3)*6400.0)+600.0)/getSampleRate()); + if (hmid[biqs_freq] < 0.0001) hmid[biqs_freq] = 0.0001; + hmid[biqs_nonlin] = E; + hmid[biqs_level] = (hmid[biqs_nonlin]*2.0)-1.0; + if (hmid[biqs_level] > 0.0) hmid[biqs_level] *= 2.0; + hmid[biqs_reso] = ((0.5+(hmid[biqs_nonlin]*0.5)+sqrt(hmid[biqs_freq]))-(1.0-pow(1.0-F,2.0)))+0.5+(hmid[biqs_nonlin]*0.5); + K = tan(M_PI * hmid[biqs_freq]); + norm = 1.0 / (1.0 + K / (hmid[biqs_reso]*1.93185165) + K * K); + hmid[biqs_a0] = K / (hmid[biqs_reso]*1.93185165) * norm; + hmid[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + hmid[biqs_b2] = (1.0 - K / (hmid[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (hmid[biqs_reso]*0.70710678) + K * K); + hmid[biqs_c0] = K / (hmid[biqs_reso]*0.70710678) * norm; + hmid[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + hmid[biqs_d2] = (1.0 - K / (hmid[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (hmid[biqs_reso]*0.51763809) + K * K); + hmid[biqs_e0] = K / (hmid[biqs_reso]*0.51763809) * norm; + hmid[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + hmid[biqs_f2] = (1.0 - K / (hmid[biqs_reso]*0.51763809) + K * K) * norm; + //hmid + + lmid[biqs_freq] = (((pow(G,3)*2200.0)+20.0)/getSampleRate()); + if (lmid[biqs_freq] < 0.00001) lmid[biqs_freq] = 0.00001; + lmid[biqs_nonlin] = H; + lmid[biqs_level] = (lmid[biqs_nonlin]*2.0)-1.0; + if (lmid[biqs_level] > 0.0) lmid[biqs_level] *= 2.0; + lmid[biqs_reso] = ((0.5+(lmid[biqs_nonlin]*0.5)+sqrt(lmid[biqs_freq]))-(1.0-pow(1.0-I,2.0)))+0.5+(lmid[biqs_nonlin]*0.5); + K = tan(M_PI * lmid[biqs_freq]); + norm = 1.0 / (1.0 + K / (lmid[biqs_reso]*1.93185165) + K * K); + lmid[biqs_a0] = K / (lmid[biqs_reso]*1.93185165) * norm; + lmid[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + lmid[biqs_b2] = (1.0 - K / (lmid[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (lmid[biqs_reso]*0.70710678) + K * K); + lmid[biqs_c0] = K / (lmid[biqs_reso]*0.70710678) * norm; + lmid[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + lmid[biqs_d2] = (1.0 - K / (lmid[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (lmid[biqs_reso]*0.51763809) + K * K); + lmid[biqs_e0] = K / (lmid[biqs_reso]*0.51763809) * norm; + lmid[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + lmid[biqs_f2] = (1.0 - K / (lmid[biqs_reso]*0.51763809) + K * K) * norm; + //lmid + + double wet = J; + + while (--sampleFrames >= 0) + { + double inputSampleL = *in1; + double inputSampleR = *in2; + if (fabs(inputSampleL)<1.18e-23) inputSampleL = fpdL * 1.18e-17; + if (fabs(inputSampleR)<1.18e-23) inputSampleR = fpdR * 1.18e-17; + + //begin Stacked Biquad With Reversed Neutron Flow L + high[biqs_outL] = inputSampleL * fabs(high[biqs_level]); + high[biqs_dis] = fabs(high[biqs_a0] * (1.0+(high[biqs_outL]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outL] * high[biqs_dis]) + high[biqs_aL1]; + high[biqs_aL1] = high[biqs_aL2] - (high[biqs_temp]*high[biqs_b1]); + high[biqs_aL2] = (high[biqs_outL] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_b2]); + high[biqs_outL] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_c0] * (1.0+(high[biqs_outL]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outL] * high[biqs_dis]) + high[biqs_cL1]; + high[biqs_cL1] = high[biqs_cL2] - (high[biqs_temp]*high[biqs_d1]); + high[biqs_cL2] = (high[biqs_outL] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_d2]); + high[biqs_outL] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_e0] * (1.0+(high[biqs_outL]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outL] * high[biqs_dis]) + high[biqs_eL1]; + high[biqs_eL1] = high[biqs_eL2] - (high[biqs_temp]*high[biqs_f1]); + high[biqs_eL2] = (high[biqs_outL] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_f2]); + high[biqs_outL] = high[biqs_temp]; high[biqs_outL] *= high[biqs_level]; + if (high[biqs_level] > 1.0) high[biqs_outL] *= high[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L + + //begin Stacked Biquad With Reversed Neutron Flow L + hmid[biqs_outL] = inputSampleL * fabs(hmid[biqs_level]); + hmid[biqs_dis] = fabs(hmid[biqs_a0] * (1.0+(hmid[biqs_outL]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outL] * hmid[biqs_dis]) + hmid[biqs_aL1]; + hmid[biqs_aL1] = hmid[biqs_aL2] - (hmid[biqs_temp]*hmid[biqs_b1]); + hmid[biqs_aL2] = (hmid[biqs_outL] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_b2]); + hmid[biqs_outL] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_c0] * (1.0+(hmid[biqs_outL]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outL] * hmid[biqs_dis]) + hmid[biqs_cL1]; + hmid[biqs_cL1] = hmid[biqs_cL2] - (hmid[biqs_temp]*hmid[biqs_d1]); + hmid[biqs_cL2] = (hmid[biqs_outL] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_d2]); + hmid[biqs_outL] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_e0] * (1.0+(hmid[biqs_outL]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outL] * hmid[biqs_dis]) + hmid[biqs_eL1]; + hmid[biqs_eL1] = hmid[biqs_eL2] - (hmid[biqs_temp]*hmid[biqs_f1]); + hmid[biqs_eL2] = (hmid[biqs_outL] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_f2]); + hmid[biqs_outL] = hmid[biqs_temp]; hmid[biqs_outL] *= hmid[biqs_level]; + if (hmid[biqs_level] > 1.0) hmid[biqs_outL] *= hmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L + + //begin Stacked Biquad With Reversed Neutron Flow L + lmid[biqs_outL] = inputSampleL * fabs(lmid[biqs_level]); + lmid[biqs_dis] = fabs(lmid[biqs_a0] * (1.0+(lmid[biqs_outL]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outL] * lmid[biqs_dis]) + lmid[biqs_aL1]; + lmid[biqs_aL1] = lmid[biqs_aL2] - (lmid[biqs_temp]*lmid[biqs_b1]); + lmid[biqs_aL2] = (lmid[biqs_outL] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_b2]); + lmid[biqs_outL] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_c0] * (1.0+(lmid[biqs_outL]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outL] * lmid[biqs_dis]) + lmid[biqs_cL1]; + lmid[biqs_cL1] = lmid[biqs_cL2] - (lmid[biqs_temp]*lmid[biqs_d1]); + lmid[biqs_cL2] = (lmid[biqs_outL] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_d2]); + lmid[biqs_outL] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_e0] * (1.0+(lmid[biqs_outL]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outL] * lmid[biqs_dis]) + lmid[biqs_eL1]; + lmid[biqs_eL1] = lmid[biqs_eL2] - (lmid[biqs_temp]*lmid[biqs_f1]); + lmid[biqs_eL2] = (lmid[biqs_outL] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_f2]); + lmid[biqs_outL] = lmid[biqs_temp]; lmid[biqs_outL] *= lmid[biqs_level]; + if (lmid[biqs_level] > 1.0) lmid[biqs_outL] *= lmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L + + //begin Stacked Biquad With Reversed Neutron Flow R + high[biqs_outR] = inputSampleR * fabs(high[biqs_level]); + high[biqs_dis] = fabs(high[biqs_a0] * (1.0+(high[biqs_outR]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outR] * high[biqs_dis]) + high[biqs_aR1]; + high[biqs_aR1] = high[biqs_aR2] - (high[biqs_temp]*high[biqs_b1]); + high[biqs_aR2] = (high[biqs_outR] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_b2]); + high[biqs_outR] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_c0] * (1.0+(high[biqs_outR]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outR] * high[biqs_dis]) + high[biqs_cR1]; + high[biqs_cR1] = high[biqs_cR2] - (high[biqs_temp]*high[biqs_d1]); + high[biqs_cR2] = (high[biqs_outR] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_d2]); + high[biqs_outR] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_e0] * (1.0+(high[biqs_outR]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outR] * high[biqs_dis]) + high[biqs_eR1]; + high[biqs_eR1] = high[biqs_eR2] - (high[biqs_temp]*high[biqs_f1]); + high[biqs_eR2] = (high[biqs_outR] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_f2]); + high[biqs_outR] = high[biqs_temp]; high[biqs_outR] *= high[biqs_level]; + if (high[biqs_level] > 1.0) high[biqs_outR] *= high[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R + + //begin Stacked Biquad With Reversed Neutron Flow R + hmid[biqs_outR] = inputSampleR * fabs(hmid[biqs_level]); + hmid[biqs_dis] = fabs(hmid[biqs_a0] * (1.0+(hmid[biqs_outR]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outR] * hmid[biqs_dis]) + hmid[biqs_aR1]; + hmid[biqs_aR1] = hmid[biqs_aR2] - (hmid[biqs_temp]*hmid[biqs_b1]); + hmid[biqs_aR2] = (hmid[biqs_outR] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_b2]); + hmid[biqs_outR] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_c0] * (1.0+(hmid[biqs_outR]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outR] * hmid[biqs_dis]) + hmid[biqs_cR1]; + hmid[biqs_cR1] = hmid[biqs_cR2] - (hmid[biqs_temp]*hmid[biqs_d1]); + hmid[biqs_cR2] = (hmid[biqs_outR] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_d2]); + hmid[biqs_outR] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_e0] * (1.0+(hmid[biqs_outR]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outR] * hmid[biqs_dis]) + hmid[biqs_eR1]; + hmid[biqs_eR1] = hmid[biqs_eR2] - (hmid[biqs_temp]*hmid[biqs_f1]); + hmid[biqs_eR2] = (hmid[biqs_outR] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_f2]); + hmid[biqs_outR] = hmid[biqs_temp]; hmid[biqs_outR] *= hmid[biqs_level]; + if (hmid[biqs_level] > 1.0) hmid[biqs_outR] *= hmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R + + //begin Stacked Biquad With Reversed Neutron Flow R + lmid[biqs_outR] = inputSampleR * fabs(lmid[biqs_level]); + lmid[biqs_dis] = fabs(lmid[biqs_a0] * (1.0+(lmid[biqs_outR]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outR] * lmid[biqs_dis]) + lmid[biqs_aR1]; + lmid[biqs_aR1] = lmid[biqs_aR2] - (lmid[biqs_temp]*lmid[biqs_b1]); + lmid[biqs_aR2] = (lmid[biqs_outR] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_b2]); + lmid[biqs_outR] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_c0] * (1.0+(lmid[biqs_outR]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outR] * lmid[biqs_dis]) + lmid[biqs_cR1]; + lmid[biqs_cR1] = lmid[biqs_cR2] - (lmid[biqs_temp]*lmid[biqs_d1]); + lmid[biqs_cR2] = (lmid[biqs_outR] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_d2]); + lmid[biqs_outR] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_e0] * (1.0+(lmid[biqs_outR]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outR] * lmid[biqs_dis]) + lmid[biqs_eR1]; + lmid[biqs_eR1] = lmid[biqs_eR2] - (lmid[biqs_temp]*lmid[biqs_f1]); + lmid[biqs_eR2] = (lmid[biqs_outR] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_f2]); + lmid[biqs_outR] = lmid[biqs_temp]; lmid[biqs_outR] *= lmid[biqs_level]; + if (lmid[biqs_level] > 1.0) lmid[biqs_outR] *= lmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R + + double parametric = high[biqs_outL] + hmid[biqs_outL] + lmid[biqs_outL]; + inputSampleL += (parametric * wet); //purely a parallel filter stage here + parametric = high[biqs_outR] + hmid[biqs_outR] + lmid[biqs_outR]; + inputSampleR += (parametric * wet); //purely a parallel filter stage here + + //begin 32 bit stereo floating point dither + int expon; frexpf((float)inputSampleL, &expon); + fpdL ^= fpdL << 13; fpdL ^= fpdL >> 17; fpdL ^= fpdL << 5; + inputSampleL += ((double(fpdL)-uint32_t(0x7fffffff)) * 5.5e-36l * pow(2,expon+62)); + frexpf((float)inputSampleR, &expon); + fpdR ^= fpdR << 13; fpdR ^= fpdR >> 17; fpdR ^= fpdR << 5; + inputSampleR += ((double(fpdR)-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 Parametric::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames) +{ + double* in1 = inputs[0]; + double* in2 = inputs[1]; + double* out1 = outputs[0]; + double* out2 = outputs[1]; + + double overallscale = 1.0; + overallscale /= 44100.0; + overallscale *= getSampleRate(); + + high[biqs_freq] = (((pow(A,3)*14500.0)+1500.0)/getSampleRate()); + if (high[biqs_freq] < 0.0001) high[biqs_freq] = 0.0001; + high[biqs_nonlin] = B; + high[biqs_level] = (high[biqs_nonlin]*2.0)-1.0; + if (high[biqs_level] > 0.0) high[biqs_level] *= 2.0; + high[biqs_reso] = ((0.5+(high[biqs_nonlin]*0.5)+sqrt(high[biqs_freq]))-(1.0-pow(1.0-C,2.0)))+0.5+(high[biqs_nonlin]*0.5); + double K = tan(M_PI * high[biqs_freq]); + double norm = 1.0 / (1.0 + K / (high[biqs_reso]*1.93185165) + K * K); + high[biqs_a0] = K / (high[biqs_reso]*1.93185165) * norm; + high[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + high[biqs_b2] = (1.0 - K / (high[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (high[biqs_reso]*0.70710678) + K * K); + high[biqs_c0] = K / (high[biqs_reso]*0.70710678) * norm; + high[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + high[biqs_d2] = (1.0 - K / (high[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (high[biqs_reso]*0.51763809) + K * K); + high[biqs_e0] = K / (high[biqs_reso]*0.51763809) * norm; + high[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + high[biqs_f2] = (1.0 - K / (high[biqs_reso]*0.51763809) + K * K) * norm; + //high + + hmid[biqs_freq] = (((pow(D,3)*6400.0)+600.0)/getSampleRate()); + if (hmid[biqs_freq] < 0.0001) hmid[biqs_freq] = 0.0001; + hmid[biqs_nonlin] = E; + hmid[biqs_level] = (hmid[biqs_nonlin]*2.0)-1.0; + if (hmid[biqs_level] > 0.0) hmid[biqs_level] *= 2.0; + hmid[biqs_reso] = ((0.5+(hmid[biqs_nonlin]*0.5)+sqrt(hmid[biqs_freq]))-(1.0-pow(1.0-F,2.0)))+0.5+(hmid[biqs_nonlin]*0.5); + K = tan(M_PI * hmid[biqs_freq]); + norm = 1.0 / (1.0 + K / (hmid[biqs_reso]*1.93185165) + K * K); + hmid[biqs_a0] = K / (hmid[biqs_reso]*1.93185165) * norm; + hmid[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + hmid[biqs_b2] = (1.0 - K / (hmid[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (hmid[biqs_reso]*0.70710678) + K * K); + hmid[biqs_c0] = K / (hmid[biqs_reso]*0.70710678) * norm; + hmid[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + hmid[biqs_d2] = (1.0 - K / (hmid[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (hmid[biqs_reso]*0.51763809) + K * K); + hmid[biqs_e0] = K / (hmid[biqs_reso]*0.51763809) * norm; + hmid[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + hmid[biqs_f2] = (1.0 - K / (hmid[biqs_reso]*0.51763809) + K * K) * norm; + //hmid + + lmid[biqs_freq] = (((pow(G,3)*2200.0)+20.0)/getSampleRate()); + if (lmid[biqs_freq] < 0.00001) lmid[biqs_freq] = 0.00001; + lmid[biqs_nonlin] = H; + lmid[biqs_level] = (lmid[biqs_nonlin]*2.0)-1.0; + if (lmid[biqs_level] > 0.0) lmid[biqs_level] *= 2.0; + lmid[biqs_reso] = ((0.5+(lmid[biqs_nonlin]*0.5)+sqrt(lmid[biqs_freq]))-(1.0-pow(1.0-I,2.0)))+0.5+(lmid[biqs_nonlin]*0.5); + K = tan(M_PI * lmid[biqs_freq]); + norm = 1.0 / (1.0 + K / (lmid[biqs_reso]*1.93185165) + K * K); + lmid[biqs_a0] = K / (lmid[biqs_reso]*1.93185165) * norm; + lmid[biqs_b1] = 2.0 * (K * K - 1.0) * norm; + lmid[biqs_b2] = (1.0 - K / (lmid[biqs_reso]*1.93185165) + K * K) * norm; + norm = 1.0 / (1.0 + K / (lmid[biqs_reso]*0.70710678) + K * K); + lmid[biqs_c0] = K / (lmid[biqs_reso]*0.70710678) * norm; + lmid[biqs_d1] = 2.0 * (K * K - 1.0) * norm; + lmid[biqs_d2] = (1.0 - K / (lmid[biqs_reso]*0.70710678) + K * K) * norm; + norm = 1.0 / (1.0 + K / (lmid[biqs_reso]*0.51763809) + K * K); + lmid[biqs_e0] = K / (lmid[biqs_reso]*0.51763809) * norm; + lmid[biqs_f1] = 2.0 * (K * K - 1.0) * norm; + lmid[biqs_f2] = (1.0 - K / (lmid[biqs_reso]*0.51763809) + K * K) * norm; + //lmid + + double wet = J; + + while (--sampleFrames >= 0) + { + double inputSampleL = *in1; + double inputSampleR = *in2; + if (fabs(inputSampleL)<1.18e-23) inputSampleL = fpdL * 1.18e-17; + if (fabs(inputSampleR)<1.18e-23) inputSampleR = fpdR * 1.18e-17; + + //begin Stacked Biquad With Reversed Neutron Flow L + high[biqs_outL] = inputSampleL * fabs(high[biqs_level]); + high[biqs_dis] = fabs(high[biqs_a0] * (1.0+(high[biqs_outL]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outL] * high[biqs_dis]) + high[biqs_aL1]; + high[biqs_aL1] = high[biqs_aL2] - (high[biqs_temp]*high[biqs_b1]); + high[biqs_aL2] = (high[biqs_outL] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_b2]); + high[biqs_outL] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_c0] * (1.0+(high[biqs_outL]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outL] * high[biqs_dis]) + high[biqs_cL1]; + high[biqs_cL1] = high[biqs_cL2] - (high[biqs_temp]*high[biqs_d1]); + high[biqs_cL2] = (high[biqs_outL] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_d2]); + high[biqs_outL] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_e0] * (1.0+(high[biqs_outL]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outL] * high[biqs_dis]) + high[biqs_eL1]; + high[biqs_eL1] = high[biqs_eL2] - (high[biqs_temp]*high[biqs_f1]); + high[biqs_eL2] = (high[biqs_outL] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_f2]); + high[biqs_outL] = high[biqs_temp]; high[biqs_outL] *= high[biqs_level]; + if (high[biqs_level] > 1.0) high[biqs_outL] *= high[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L + + //begin Stacked Biquad With Reversed Neutron Flow L + hmid[biqs_outL] = inputSampleL * fabs(hmid[biqs_level]); + hmid[biqs_dis] = fabs(hmid[biqs_a0] * (1.0+(hmid[biqs_outL]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outL] * hmid[biqs_dis]) + hmid[biqs_aL1]; + hmid[biqs_aL1] = hmid[biqs_aL2] - (hmid[biqs_temp]*hmid[biqs_b1]); + hmid[biqs_aL2] = (hmid[biqs_outL] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_b2]); + hmid[biqs_outL] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_c0] * (1.0+(hmid[biqs_outL]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outL] * hmid[biqs_dis]) + hmid[biqs_cL1]; + hmid[biqs_cL1] = hmid[biqs_cL2] - (hmid[biqs_temp]*hmid[biqs_d1]); + hmid[biqs_cL2] = (hmid[biqs_outL] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_d2]); + hmid[biqs_outL] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_e0] * (1.0+(hmid[biqs_outL]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outL] * hmid[biqs_dis]) + hmid[biqs_eL1]; + hmid[biqs_eL1] = hmid[biqs_eL2] - (hmid[biqs_temp]*hmid[biqs_f1]); + hmid[biqs_eL2] = (hmid[biqs_outL] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_f2]); + hmid[biqs_outL] = hmid[biqs_temp]; hmid[biqs_outL] *= hmid[biqs_level]; + if (hmid[biqs_level] > 1.0) hmid[biqs_outL] *= hmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L + + //begin Stacked Biquad With Reversed Neutron Flow L + lmid[biqs_outL] = inputSampleL * fabs(lmid[biqs_level]); + lmid[biqs_dis] = fabs(lmid[biqs_a0] * (1.0+(lmid[biqs_outL]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outL] * lmid[biqs_dis]) + lmid[biqs_aL1]; + lmid[biqs_aL1] = lmid[biqs_aL2] - (lmid[biqs_temp]*lmid[biqs_b1]); + lmid[biqs_aL2] = (lmid[biqs_outL] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_b2]); + lmid[biqs_outL] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_c0] * (1.0+(lmid[biqs_outL]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outL] * lmid[biqs_dis]) + lmid[biqs_cL1]; + lmid[biqs_cL1] = lmid[biqs_cL2] - (lmid[biqs_temp]*lmid[biqs_d1]); + lmid[biqs_cL2] = (lmid[biqs_outL] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_d2]); + lmid[biqs_outL] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_e0] * (1.0+(lmid[biqs_outL]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outL] * lmid[biqs_dis]) + lmid[biqs_eL1]; + lmid[biqs_eL1] = lmid[biqs_eL2] - (lmid[biqs_temp]*lmid[biqs_f1]); + lmid[biqs_eL2] = (lmid[biqs_outL] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_f2]); + lmid[biqs_outL] = lmid[biqs_temp]; lmid[biqs_outL] *= lmid[biqs_level]; + if (lmid[biqs_level] > 1.0) lmid[biqs_outL] *= lmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow L + + //begin Stacked Biquad With Reversed Neutron Flow R + high[biqs_outR] = inputSampleR * fabs(high[biqs_level]); + high[biqs_dis] = fabs(high[biqs_a0] * (1.0+(high[biqs_outR]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outR] * high[biqs_dis]) + high[biqs_aR1]; + high[biqs_aR1] = high[biqs_aR2] - (high[biqs_temp]*high[biqs_b1]); + high[biqs_aR2] = (high[biqs_outR] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_b2]); + high[biqs_outR] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_c0] * (1.0+(high[biqs_outR]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outR] * high[biqs_dis]) + high[biqs_cR1]; + high[biqs_cR1] = high[biqs_cR2] - (high[biqs_temp]*high[biqs_d1]); + high[biqs_cR2] = (high[biqs_outR] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_d2]); + high[biqs_outR] = high[biqs_temp]; + high[biqs_dis] = fabs(high[biqs_e0] * (1.0+(high[biqs_outR]*high[biqs_nonlin]))); + if (high[biqs_dis] > 1.0) high[biqs_dis] = 1.0; + high[biqs_temp] = (high[biqs_outR] * high[biqs_dis]) + high[biqs_eR1]; + high[biqs_eR1] = high[biqs_eR2] - (high[biqs_temp]*high[biqs_f1]); + high[biqs_eR2] = (high[biqs_outR] * -high[biqs_dis]) - (high[biqs_temp]*high[biqs_f2]); + high[biqs_outR] = high[biqs_temp]; high[biqs_outR] *= high[biqs_level]; + if (high[biqs_level] > 1.0) high[biqs_outR] *= high[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R + + //begin Stacked Biquad With Reversed Neutron Flow R + hmid[biqs_outR] = inputSampleR * fabs(hmid[biqs_level]); + hmid[biqs_dis] = fabs(hmid[biqs_a0] * (1.0+(hmid[biqs_outR]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outR] * hmid[biqs_dis]) + hmid[biqs_aR1]; + hmid[biqs_aR1] = hmid[biqs_aR2] - (hmid[biqs_temp]*hmid[biqs_b1]); + hmid[biqs_aR2] = (hmid[biqs_outR] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_b2]); + hmid[biqs_outR] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_c0] * (1.0+(hmid[biqs_outR]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outR] * hmid[biqs_dis]) + hmid[biqs_cR1]; + hmid[biqs_cR1] = hmid[biqs_cR2] - (hmid[biqs_temp]*hmid[biqs_d1]); + hmid[biqs_cR2] = (hmid[biqs_outR] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_d2]); + hmid[biqs_outR] = hmid[biqs_temp]; + hmid[biqs_dis] = fabs(hmid[biqs_e0] * (1.0+(hmid[biqs_outR]*hmid[biqs_nonlin]))); + if (hmid[biqs_dis] > 1.0) hmid[biqs_dis] = 1.0; + hmid[biqs_temp] = (hmid[biqs_outR] * hmid[biqs_dis]) + hmid[biqs_eR1]; + hmid[biqs_eR1] = hmid[biqs_eR2] - (hmid[biqs_temp]*hmid[biqs_f1]); + hmid[biqs_eR2] = (hmid[biqs_outR] * -hmid[biqs_dis]) - (hmid[biqs_temp]*hmid[biqs_f2]); + hmid[biqs_outR] = hmid[biqs_temp]; hmid[biqs_outR] *= hmid[biqs_level]; + if (hmid[biqs_level] > 1.0) hmid[biqs_outR] *= hmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R + + //begin Stacked Biquad With Reversed Neutron Flow R + lmid[biqs_outR] = inputSampleR * fabs(lmid[biqs_level]); + lmid[biqs_dis] = fabs(lmid[biqs_a0] * (1.0+(lmid[biqs_outR]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outR] * lmid[biqs_dis]) + lmid[biqs_aR1]; + lmid[biqs_aR1] = lmid[biqs_aR2] - (lmid[biqs_temp]*lmid[biqs_b1]); + lmid[biqs_aR2] = (lmid[biqs_outR] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_b2]); + lmid[biqs_outR] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_c0] * (1.0+(lmid[biqs_outR]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outR] * lmid[biqs_dis]) + lmid[biqs_cR1]; + lmid[biqs_cR1] = lmid[biqs_cR2] - (lmid[biqs_temp]*lmid[biqs_d1]); + lmid[biqs_cR2] = (lmid[biqs_outR] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_d2]); + lmid[biqs_outR] = lmid[biqs_temp]; + lmid[biqs_dis] = fabs(lmid[biqs_e0] * (1.0+(lmid[biqs_outR]*lmid[biqs_nonlin]))); + if (lmid[biqs_dis] > 1.0) lmid[biqs_dis] = 1.0; + lmid[biqs_temp] = (lmid[biqs_outR] * lmid[biqs_dis]) + lmid[biqs_eR1]; + lmid[biqs_eR1] = lmid[biqs_eR2] - (lmid[biqs_temp]*lmid[biqs_f1]); + lmid[biqs_eR2] = (lmid[biqs_outR] * -lmid[biqs_dis]) - (lmid[biqs_temp]*lmid[biqs_f2]); + lmid[biqs_outR] = lmid[biqs_temp]; lmid[biqs_outR] *= lmid[biqs_level]; + if (lmid[biqs_level] > 1.0) lmid[biqs_outR] *= lmid[biqs_level]; + //end Stacked Biquad With Reversed Neutron Flow R + + double parametric = high[biqs_outL] + hmid[biqs_outL] + lmid[biqs_outL]; + inputSampleL += (parametric * wet); //purely a parallel filter stage here + parametric = high[biqs_outR] + hmid[biqs_outR] + lmid[biqs_outR]; + inputSampleR += (parametric * wet); //purely a parallel filter stage here + + //begin 64 bit stereo floating point dither + //int expon; frexp((double)inputSampleL, &expon); + fpdL ^= fpdL << 13; fpdL ^= fpdL >> 17; fpdL ^= fpdL << 5; + //inputSampleL += ((double(fpdL)-uint32_t(0x7fffffff)) * 1.1e-44l * pow(2,expon+62)); + //frexp((double)inputSampleR, &expon); + fpdR ^= fpdR << 13; fpdR ^= fpdR >> 17; fpdR ^= fpdR << 5; + //inputSampleR += ((double(fpdR)-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++; + } +} +} // end namespace diff --git a/src/autogen_airwin/Pop3.cpp b/src/autogen_airwin/Pop3.cpp new file mode 100644 index 0000000..f07eb96 --- /dev/null +++ b/src/autogen_airwin/Pop3.cpp @@ -0,0 +1,175 @@ +/* ======================================== + * Pop3 - Pop3.h + * Copyright (c) airwindows, Airwindows uses the MIT license + * ======================================== */ + +#ifndef __Pop3_H +#include "Pop3.h" +#endif +#include +#include +namespace airwinconsolidated::Pop3 { + +AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new Pop3(audioMaster);} + +Pop3::Pop3(audioMasterCallback audioMaster) : + AudioEffectX(audioMaster, kNumPrograms, kNumParameters) +{ + A = 1.0; + B = 0.5; + C = 0.5; + D = 0.5; + E = 0.0; + F = 0.5; + G = 0.5; + H = 0.5; + + popCompL = 1.0; + popCompR = 1.0; + popGate = 1.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 +} + +Pop3::~Pop3() {} +VstInt32 Pop3::getVendorVersion () {return 1000;} +void Pop3::setProgramName(char *name) {vst_strncpy (_programName, name, kVstMaxProgNameLen);} +void Pop3::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; +} + +void Pop3::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; + case kParamF: F = value; break; + case kParamG: G = value; break; + case kParamH: H = value; break; + default: break; // unknown parameter, shouldn't happen! + } +} + +float Pop3::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; + case kParamF: return F; break; + case kParamG: return G; break; + case kParamH: return H; 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 Pop3::getParameterName(VstInt32 index, char *text) { + switch (index) { + case kParamA: vst_strncpy (text, "Thresld", kVstMaxParamStrLen); break; + case kParamB: vst_strncpy (text, "C Ratio", kVstMaxParamStrLen); break; + case kParamC: vst_strncpy (text, "C Atk", kVstMaxParamStrLen); break; + case kParamD: vst_strncpy (text, "C Rls", kVstMaxParamStrLen); break; + case kParamE: vst_strncpy (text, "Thresld", kVstMaxParamStrLen); break; + case kParamF: vst_strncpy (text, "G Ratio", kVstMaxParamStrLen); break; + case kParamG: vst_strncpy (text, "G Sust", kVstMaxParamStrLen); break; + case kParamH: vst_strncpy (text, "G Rls", kVstMaxParamStrLen); break; + default: break; // unknown parameter, shouldn't happen! + } //this is our labels for displaying in the VST host +} + +void Pop3::getParameterDisplay(VstInt32 index, char *text) { + switch (index) { + case kParamA: float2string (A, text, kVstMaxParamStrLen); break; + case kParamB: float2string (B, text, kVstMaxParamStrLen); break; + case kParamC: float2string (C, text, kVstMaxParamStrLen); break; + case kParamD: float2string (D, text, kVstMaxParamStrLen); break; + case kParamE: float2string (E, text, kVstMaxParamStrLen); break; + case kParamF: float2string (F, text, kVstMaxParamStrLen); break; + case kParamG: float2string (G, text, kVstMaxParamStrLen); break; + case kParamH: float2string (H, text, kVstMaxParamStrLen); break; + default: break; // unknown parameter, shouldn't happen! + } //this displays the values and handles 'popups' where it's discrete choices +} + +void Pop3::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; + case kParamF: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamG: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamH: vst_strncpy (text, "", kVstMaxParamStrLen); break; + default: break; // unknown parameter, shouldn't happen! + } +} + +VstInt32 Pop3::canDo(char *text) +{ return (_canDo.find(text) == _canDo.end()) ? -1: 1; } // 1 = yes, -1 = no, 0 = don't know + +bool Pop3::getEffectName(char* name) { + vst_strncpy(name, "Pop3", kVstMaxProductStrLen); return true; +} + +VstPlugCategory Pop3::getPlugCategory() {return kPlugCategEffect;} + +bool Pop3::getProductString(char* text) { + vst_strncpy (text, "airwindows Pop3", kVstMaxProductStrLen); return true; +} + +bool Pop3::getVendorString(char* text) { + vst_strncpy (text, "airwindows", kVstMaxVendorStrLen); return true; +} +bool Pop3::parameterTextToValue(VstInt32 index, const char *text, float &value) { + switch(index) { + case kParamA: { auto b = string2float(text, value); return b; break; } + case kParamB: { auto b = string2float(text, value); return b; break; } + case kParamC: { auto b = string2float(text, value); return b; break; } + case kParamD: { auto b = string2float(text, value); return b; break; } + case kParamE: { auto b = string2float(text, value); return b; break; } + case kParamF: { auto b = string2float(text, value); return b; break; } + case kParamG: { auto b = string2float(text, value); return b; break; } + case kParamH: { auto b = string2float(text, value); return b; break; } + + } + return false; +} +bool Pop3::canConvertParameterTextToValue(VstInt32 index) { + switch(index) { + case kParamA: return true; + case kParamB: return true; + case kParamC: return true; + case kParamD: return true; + case kParamE: return true; + case kParamF: return true; + case kParamG: return true; + case kParamH: return true; + + } + return false; +} +} // end namespace diff --git a/src/autogen_airwin/Pop3.h b/src/autogen_airwin/Pop3.h new file mode 100644 index 0000000..f397ce4 --- /dev/null +++ b/src/autogen_airwin/Pop3.h @@ -0,0 +1,83 @@ +/* ======================================== + * Pop3 - Pop3.h + * Created 8/12/11 by SPIAdmin + * Copyright (c) Airwindows, Airwindows uses the MIT license + * ======================================== */ + +#ifndef __Pop3_Pop3_H +#define __Pop3_Pop3_H + +#ifndef __audioeffect__ +#include "../airwin_consolidated_base.h" +#endif + +#include +#include +#include + +namespace airwinconsolidated::Pop3 { +enum { + kParamA =0, + kParamB =1, + kParamC =2, + kParamD =3, + kParamE =4, + kParamF =5, + kParamG =6, + kParamH =7, + kNumParameters = 8 +}; // + +const int kNumPrograms = 0; +const int kNumInputs = 2; +const int kNumOutputs = 2; +const unsigned long kUniqueId = 'popf'; //Change this to what the AU identity is! + +class Pop3 : + public AudioEffectX +{ +public: + Pop3(audioMasterCallback audioMaster); + ~Pop3(); + 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 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 + // Added by the perl as inverses + virtual bool parameterTextToValue(VstInt32 index, const char *text, float &value); + virtual bool canConvertParameterTextToValue(VstInt32 index); + virtual VstInt32 canDo(char *text); +private: + char _programName[kVstMaxProgNameLen + 1]; + std::set< std::string > _canDo; + + float A; + float B; + float C; + float D; + float E; + float F; + float G; + float H; + + double popCompL; + double popCompR; + double popGate; + + uint32_t fpdL; + uint32_t fpdR; + //default stuff +}; + +#endif +} // end namespace diff --git a/src/autogen_airwin/Pop3Proc.cpp b/src/autogen_airwin/Pop3Proc.cpp new file mode 100644 index 0000000..efaae33 --- /dev/null +++ b/src/autogen_airwin/Pop3Proc.cpp @@ -0,0 +1,150 @@ +/* ======================================== + * Pop3 - Pop3.h + * Copyright (c) airwindows, Airwindows uses the MIT license + * ======================================== */ + +#ifndef __Pop3_H +#include "Pop3.h" +#endif +namespace airwinconsolidated::Pop3 { + +void Pop3::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames) +{ + float* in1 = inputs[0]; + float* in2 = inputs[1]; + float* out1 = outputs[0]; + float* out2 = outputs[1]; + + double overallscale = 1.0; + overallscale /= 44100.0; + overallscale *= getSampleRate(); + + double compThresh = pow(A,4); + double compRatio = 1.0-pow(1.0-B,2); + double compAttack = 1.0/(((pow(C,3)*5000.0)+500.0)*overallscale); + double compRelease = 1.0/(((pow(D,5)*50000.0)+500.0)*overallscale); + + double gateThresh = pow(E,4); + double gateRatio = 1.0-pow(1.0-F,2); + double gateSustain = M_PI_2 * pow(G+1.0,4.0); + double gateRelease = 1.0/(((pow(H,5)*500000.0)+500.0)*overallscale); + + while (--sampleFrames >= 0) + { + double inputSampleL = *in1; + double inputSampleR = *in2; + if (fabs(inputSampleL)<1.18e-23) inputSampleL = fpdL * 1.18e-17; + if (fabs(inputSampleR)<1.18e-23) inputSampleR = fpdR * 1.18e-17; + + if (fabs(inputSampleL) > compThresh) { //compression L + popCompL -= (popCompL * compAttack); + popCompL += ((compThresh / fabs(inputSampleL))*compAttack); + } else popCompL = (popCompL*(1.0-compRelease))+compRelease; + if (popCompL < 0.0) popCompL = 0.0; + if (fabs(inputSampleR) > compThresh) { //compression R + popCompR -= (popCompR * compAttack); + popCompR += ((compThresh / fabs(inputSampleR))*compAttack); + } else popCompR = (popCompR*(1.0-compRelease))+compRelease; + if (popCompR < 0.0) popCompR = 0.0; + if (popCompL > popCompR) popCompL -= (popCompL * compAttack); + if (popCompR > popCompL) popCompR -= (popCompR * compAttack); + if (fabs(inputSampleL) > gateThresh) popGate = gateSustain; + else if (fabs(inputSampleR) > gateThresh) popGate = gateSustain; + else popGate *= (1.0-gateRelease); + if (popGate < 0.0) popGate = 0.0; + if (popCompL < 1.0) inputSampleL *= ((1.0-compRatio)+(popCompL*compRatio)); + if (popCompR < 1.0) inputSampleR *= ((1.0-compRatio)+(popCompR*compRatio)); + if (popGate < M_PI_2) { + inputSampleL *= ((1.0-gateRatio)+(sin(popGate)*gateRatio)); + inputSampleR *= ((1.0-gateRatio)+(sin(popGate)*gateRatio)); + } + + //begin 32 bit stereo floating point dither + int expon; frexpf((float)inputSampleL, &expon); + fpdL ^= fpdL << 13; fpdL ^= fpdL >> 17; fpdL ^= fpdL << 5; + inputSampleL += ((double(fpdL)-uint32_t(0x7fffffff)) * 5.5e-36l * pow(2,expon+62)); + frexpf((float)inputSampleR, &expon); + fpdR ^= fpdR << 13; fpdR ^= fpdR >> 17; fpdR ^= fpdR << 5; + inputSampleR += ((double(fpdR)-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 Pop3::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames) +{ + double* in1 = inputs[0]; + double* in2 = inputs[1]; + double* out1 = outputs[0]; + double* out2 = outputs[1]; + + double overallscale = 1.0; + overallscale /= 44100.0; + overallscale *= getSampleRate(); + + double compThresh = pow(A,4); + double compRatio = 1.0-pow(1.0-B,2); + double compAttack = 1.0/(((pow(C,3)*5000.0)+500.0)*overallscale); + double compRelease = 1.0/(((pow(D,5)*50000.0)+500.0)*overallscale); + + double gateThresh = pow(E,4); + double gateRatio = 1.0-pow(1.0-F,2); + double gateSustain = M_PI_2 * pow(G+1.0,4.0); + double gateRelease = 1.0/(((pow(H,5)*500000.0)+500.0)*overallscale); + + while (--sampleFrames >= 0) + { + double inputSampleL = *in1; + double inputSampleR = *in2; + if (fabs(inputSampleL)<1.18e-23) inputSampleL = fpdL * 1.18e-17; + if (fabs(inputSampleR)<1.18e-23) inputSampleR = fpdR * 1.18e-17; + + if (fabs(inputSampleL) > compThresh) { //compression L + popCompL -= (popCompL * compAttack); + popCompL += ((compThresh / fabs(inputSampleL))*compAttack); + } else popCompL = (popCompL*(1.0-compRelease))+compRelease; + if (popCompL < 0.0) popCompL = 0.0; + if (fabs(inputSampleR) > compThresh) { //compression R + popCompR -= (popCompR * compAttack); + popCompR += ((compThresh / fabs(inputSampleR))*compAttack); + } else popCompR = (popCompR*(1.0-compRelease))+compRelease; + if (popCompR < 0.0) popCompR = 0.0; + if (popCompL > popCompR) popCompL -= (popCompL * compAttack); + if (popCompR > popCompL) popCompR -= (popCompR * compAttack); + if (fabs(inputSampleL) > gateThresh) popGate = gateSustain; + else if (fabs(inputSampleR) > gateThresh) popGate = gateSustain; + else popGate *= (1.0-gateRelease); + if (popGate < 0.0) popGate = 0.0; + if (popCompL < 1.0) inputSampleL *= ((1.0-compRatio)+(popCompL*compRatio)); + if (popCompR < 1.0) inputSampleR *= ((1.0-compRatio)+(popCompR*compRatio)); + if (popGate < M_PI_2) { + inputSampleL *= ((1.0-gateRatio)+(sin(popGate)*gateRatio)); + inputSampleR *= ((1.0-gateRatio)+(sin(popGate)*gateRatio)); + } + + //begin 64 bit stereo floating point dither + //int expon; frexp((double)inputSampleL, &expon); + fpdL ^= fpdL << 13; fpdL ^= fpdL >> 17; fpdL ^= fpdL << 5; + //inputSampleL += ((double(fpdL)-uint32_t(0x7fffffff)) * 1.1e-44l * pow(2,expon+62)); + //frexp((double)inputSampleR, &expon); + fpdR ^= fpdR << 13; fpdR ^= fpdR >> 17; fpdR ^= fpdR << 5; + //inputSampleR += ((double(fpdR)-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++; + } +} +} // end namespace diff --git a/src/autogen_airwin/StoneFireComp.cpp b/src/autogen_airwin/StoneFireComp.cpp new file mode 100644 index 0000000..fdb894e --- /dev/null +++ b/src/autogen_airwin/StoneFireComp.cpp @@ -0,0 +1,193 @@ +/* ======================================== + * StoneFireComp - StoneFireComp.h + * Copyright (c) airwindows, Airwindows uses the MIT license + * ======================================== */ + +#ifndef __StoneFireComp_H +#include "StoneFireComp.h" +#endif +#include +#include +namespace airwinconsolidated::StoneFireComp { + +AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {return new StoneFireComp(audioMaster);} + +StoneFireComp::StoneFireComp(audioMasterCallback audioMaster) : + AudioEffectX(audioMaster, kNumPrograms, kNumParameters) +{ + A = 1.0; + B = 0.5; + C = 0.5; + D = 0.5; + E = 1.0; + F = 0.5; + G = 0.5; + H = 0.5; + I = 0.5; + J = 1.0; + + for (int x = 0; x < kal_total; x++) kal[x] = 0.0; + fireCompL = 1.0; + fireCompR = 1.0; + stoneCompL = 1.0; + stoneCompR = 1.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 +} + +StoneFireComp::~StoneFireComp() {} +VstInt32 StoneFireComp::getVendorVersion () {return 1000;} +void StoneFireComp::setProgramName(char *name) {vst_strncpy (_programName, name, kVstMaxProgNameLen);} +void StoneFireComp::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; +} + +void StoneFireComp::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; + case kParamF: F = value; break; + case kParamG: G = value; break; + case kParamH: H = value; break; + case kParamI: I = value; break; + case kParamJ: J = value; break; + default: break; // unknown parameter, shouldn't happen! + } +} + +float StoneFireComp::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; + case kParamF: return F; break; + case kParamG: return G; break; + case kParamH: return H; break; + case kParamI: return I; break; + case kParamJ: return J; 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 StoneFireComp::getParameterName(VstInt32 index, char *text) { + switch (index) { + case kParamA: vst_strncpy (text, "Fire Th", kVstMaxParamStrLen); break; + case kParamB: vst_strncpy (text, "Attack", kVstMaxParamStrLen); break; + case kParamC: vst_strncpy (text, "Release", kVstMaxParamStrLen); break; + case kParamD: vst_strncpy (text, "Fire", kVstMaxParamStrLen); break; + case kParamE: vst_strncpy (text, "StoneTh", kVstMaxParamStrLen); break; + case kParamF: vst_strncpy (text, "Attack", kVstMaxParamStrLen); break; + case kParamG: vst_strncpy (text, "Release", kVstMaxParamStrLen); break; + case kParamH: vst_strncpy (text, "Stone", kVstMaxParamStrLen); break; + case kParamI: vst_strncpy (text, "Range", kVstMaxParamStrLen); break; + case kParamJ: vst_strncpy (text, "Ratio", kVstMaxParamStrLen); break; + default: break; // unknown parameter, shouldn't happen! + } //this is our labels for displaying in the VST host +} + +void StoneFireComp::getParameterDisplay(VstInt32 index, char *text) { + switch (index) { + case kParamA: float2string (A, text, kVstMaxParamStrLen); break; + case kParamB: float2string (B, text, kVstMaxParamStrLen); break; + case kParamC: float2string (C, text, kVstMaxParamStrLen); break; + case kParamD: float2string (D, text, kVstMaxParamStrLen); break; + case kParamE: float2string (E, text, kVstMaxParamStrLen); break; + case kParamF: float2string (F, text, kVstMaxParamStrLen); break; + case kParamG: float2string (G, text, kVstMaxParamStrLen); break; + case kParamH: float2string (H, text, kVstMaxParamStrLen); break; + case kParamI: float2string (I, text, kVstMaxParamStrLen); break; + case kParamJ: float2string (J, text, kVstMaxParamStrLen); break; + default: break; // unknown parameter, shouldn't happen! + } //this displays the values and handles 'popups' where it's discrete choices +} + +void StoneFireComp::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; + case kParamF: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamG: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamH: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamI: vst_strncpy (text, "", kVstMaxParamStrLen); break; + case kParamJ: vst_strncpy (text, "", kVstMaxParamStrLen); break; + default: break; // unknown parameter, shouldn't happen! + } +} + +VstInt32 StoneFireComp::canDo(char *text) +{ return (_canDo.find(text) == _canDo.end()) ? -1: 1; } // 1 = yes, -1 = no, 0 = don't know + +bool StoneFireComp::getEffectName(char* name) { + vst_strncpy(name, "StoneFireComp", kVstMaxProductStrLen); return true; +} + +VstPlugCategory StoneFireComp::getPlugCategory() {return kPlugCategEffect;} + +bool StoneFireComp::getProductString(char* text) { + vst_strncpy (text, "airwindows StoneFireComp", kVstMaxProductStrLen); return true; +} + +bool StoneFireComp::getVendorString(char* text) { + vst_strncpy (text, "airwindows", kVstMaxVendorStrLen); return true; +} +bool StoneFireComp::parameterTextToValue(VstInt32 index, const char *text, float &value) { + switch(index) { + case kParamA: { auto b = string2float(text, value); return b; break; } + case kParamB: { auto b = string2float(text, value); return b; break; } + case kParamC: { auto b = string2float(text, value); return b; break; } + case kParamD: { auto b = string2float(text, value); return b; break; } + case kParamE: { auto b = string2float(text, value); return b; break; } + case kParamF: { auto b = string2float(text, value); return b; break; } + case kParamG: { auto b = string2float(text, value); return b; break; } + case kParamH: { auto b = string2float(text, value); return b; break; } + case kParamI: { auto b = string2float(text, value); return b; break; } + case kParamJ: { auto b = string2float(text, value); return b; break; } + + } + return false; +} +bool StoneFireComp::canConvertParameterTextToValue(VstInt32 index) { + switch(index) { + case kParamA: return true; + case kParamB: return true; + case kParamC: return true; + case kParamD: return true; + case kParamE: return true; + case kParamF: return true; + case kParamG: return true; + case kParamH: return true; + case kParamI: return true; + case kParamJ: return true; + + } + return false; +} +} // end namespace diff --git a/src/autogen_airwin/StoneFireComp.h b/src/autogen_airwin/StoneFireComp.h new file mode 100644 index 0000000..34d7f1c --- /dev/null +++ b/src/autogen_airwin/StoneFireComp.h @@ -0,0 +1,100 @@ +/* ======================================== + * StoneFireComp - StoneFireComp.h + * Created 8/12/11 by SPIAdmin + * Copyright (c) Airwindows, Airwindows uses the MIT license + * ======================================== */ + +#ifndef __StoneFireComp_StoneFireComp_H +#define __StoneFireComp_StoneFireComp_H + +#ifndef __audioeffect__ +#include "../airwin_consolidated_base.h" +#endif + +#include +#include +#include + +namespace airwinconsolidated::StoneFireComp { +enum { + kParamA =0, + kParamB =1, + kParamC =2, + kParamD =3, + kParamE =4, + kParamF =5, + kParamG =6, + kParamH =7, + kParamI =8, + kParamJ =9, + kNumParameters = 10 +}; // + +const int kNumPrograms = 0; +const int kNumInputs = 2; +const int kNumOutputs = 2; +const unsigned long kUniqueId = 'stfc'; //Change this to what the AU identity is! + +class StoneFireComp : + public AudioEffectX +{ +public: + StoneFireComp(audioMasterCallback audioMaster); + ~StoneFireComp(); + 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 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 + // Added by the perl as inverses + virtual bool parameterTextToValue(VstInt32 index, const char *text, float &value); + virtual bool canConvertParameterTextToValue(VstInt32 index); + virtual VstInt32 canDo(char *text); +private: + char _programName[kVstMaxProgNameLen + 1]; + std::set< std::string > _canDo; + + float A; + float B; + float C; + float D; + float E; + float F; + float G; + float H; + float I; + float J; + + enum { + prevSampL1, prevSlewL1, accSlewL1, + prevSampL2, prevSlewL2, accSlewL2, + prevSampL3, prevSlewL3, accSlewL3, + kalGainL, kalOutL, + prevSampR1, prevSlewR1, accSlewR1, + prevSampR2, prevSlewR2, accSlewR2, + prevSampR3, prevSlewR3, accSlewR3, + kalGainR, kalOutR, + kal_total + }; + double kal[kal_total]; + double fireCompL; + double fireCompR; + double stoneCompL; + double stoneCompR; + + uint32_t fpdL; + uint32_t fpdR; + //default stuff +}; + +#endif +} // end namespace diff --git a/src/autogen_airwin/StoneFireCompProc.cpp b/src/autogen_airwin/StoneFireCompProc.cpp new file mode 100644 index 0000000..3750e80 --- /dev/null +++ b/src/autogen_airwin/StoneFireCompProc.cpp @@ -0,0 +1,314 @@ +/* ======================================== + * StoneFireComp - StoneFireComp.h + * Copyright (c) airwindows, Airwindows uses the MIT license + * ======================================== */ + +#ifndef __StoneFireComp_H +#include "StoneFireComp.h" +#endif +namespace airwinconsolidated::StoneFireComp { + +void StoneFireComp::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames) +{ + float* in1 = inputs[0]; + float* in2 = inputs[1]; + float* out1 = outputs[0]; + float* out2 = outputs[1]; + + double overallscale = 1.0; + overallscale /= 44100.0; + overallscale *= getSampleRate(); + + double compFThresh = pow(A,4); + double compFAttack = 1.0/(((pow(B,3)*5000.0)+500.0)*overallscale); + double compFRelease = 1.0/(((pow(C,5)*50000.0)+500.0)*overallscale); + double fireGain = D*2.0; fireGain = pow(fireGain,3); + double firePad = fireGain; if (firePad > 1.0) firePad = 1.0; + + double compSThresh = pow(E,4); + double compSAttack = 1.0/(((pow(F,3)*5000.0)+500.0)*overallscale); + double compSRelease = 1.0/(((pow(G,5)*50000.0)+500.0)*overallscale); + double stoneGain = H*2.0; stoneGain = pow(stoneGain,3); + double stonePad = stoneGain; if (stonePad > 1.0) stonePad = 1.0; + + double kalman = 1.0-pow(I,2); + //crossover frequency between mid/bass + double compRatio = 1.0-pow(1.0-J,2); + + while (--sampleFrames >= 0) + { + double inputSampleL = *in1; + double inputSampleR = *in2; + if (fabs(inputSampleL)<1.18e-23) inputSampleL = fpdL * 1.18e-17; + if (fabs(inputSampleR)<1.18e-23) inputSampleR = fpdR * 1.18e-17; + + //begin KalmanL + double fireL = inputSampleL; + double temp = inputSampleL = inputSampleL*(1.0-kalman)*0.777; + inputSampleL *= (1.0-kalman); + //set up gain levels to control the beast + kal[prevSlewL3] += kal[prevSampL3] - kal[prevSampL2]; kal[prevSlewL3] *= 0.5; + kal[prevSlewL2] += kal[prevSampL2] - kal[prevSampL1]; kal[prevSlewL2] *= 0.5; + kal[prevSlewL1] += kal[prevSampL1] - inputSampleL; kal[prevSlewL1] *= 0.5; + //make slews from each set of samples used + kal[accSlewL2] += kal[prevSlewL3] - kal[prevSlewL2]; kal[accSlewL2] *= 0.5; + kal[accSlewL1] += kal[prevSlewL2] - kal[prevSlewL1]; kal[accSlewL1] *= 0.5; + //differences between slews: rate of change of rate of change + kal[accSlewL3] += (kal[accSlewL2] - kal[accSlewL1]); kal[accSlewL3] *= 0.5; + //entering the abyss, what even is this + kal[kalOutL] += kal[prevSampL1] + kal[prevSlewL2] + kal[accSlewL3]; kal[kalOutL] *= 0.5; + //resynthesizing predicted result (all iir smoothed) + kal[kalGainL] += fabs(temp-kal[kalOutL])*kalman*8.0; kal[kalGainL] *= 0.5; + //madness takes its toll. Kalman Gain: how much dry to retain + if (kal[kalGainL] > kalman*0.5) kal[kalGainL] = kalman*0.5; + //attempts to avoid explosions + kal[kalOutL] += (temp*(1.0-(0.68+(kalman*0.157)))); + //this is for tuning a really complete cancellation up around Nyquist + kal[prevSampL3] = kal[prevSampL2]; kal[prevSampL2] = kal[prevSampL1]; + kal[prevSampL1] = (kal[kalGainL] * kal[kalOutL]) + ((1.0-kal[kalGainL])*temp); + //feed the chain of previous samples + if (kal[prevSampL1] > 1.0) kal[prevSampL1] = 1.0; if (kal[prevSampL1] < -1.0) kal[prevSampL1] = -1.0; + double stoneL = kal[kalOutL]*0.777; + fireL -= stoneL; + //end KalmanL + + //begin KalmanR + double fireR = inputSampleR; + temp = inputSampleR = inputSampleR*(1.0-kalman)*0.777; + inputSampleR *= (1.0-kalman); + //set up gain levels to control the beast + kal[prevSlewR3] += kal[prevSampR3] - kal[prevSampR2]; kal[prevSlewR3] *= 0.5; + kal[prevSlewR2] += kal[prevSampR2] - kal[prevSampR1]; kal[prevSlewR2] *= 0.5; + kal[prevSlewR1] += kal[prevSampR1] - inputSampleR; kal[prevSlewR1] *= 0.5; + //make slews from each set of samples used + kal[accSlewR2] += kal[prevSlewR3] - kal[prevSlewR2]; kal[accSlewR2] *= 0.5; + kal[accSlewR1] += kal[prevSlewR2] - kal[prevSlewR1]; kal[accSlewR1] *= 0.5; + //differences between slews: rate of change of rate of change + kal[accSlewR3] += (kal[accSlewR2] - kal[accSlewR1]); kal[accSlewR3] *= 0.5; + //entering the abyss, what even is this + kal[kalOutR] += kal[prevSampR1] + kal[prevSlewR2] + kal[accSlewR3]; kal[kalOutR] *= 0.5; + //resynthesizing predicted result (all iir smoothed) + kal[kalGainR] += fabs(temp-kal[kalOutR])*kalman*8.0; kal[kalGainR] *= 0.5; + //madness takes its toll. Kalman Gain: how much dry to retain + if (kal[kalGainR] > kalman*0.5) kal[kalGainR] = kalman*0.5; + //attempts to avoid explosions + kal[kalOutR] += (temp*(1.0-(0.68+(kalman*0.157)))); + //this is for tuning a really complete cancellation up around Nyquist + kal[prevSampR3] = kal[prevSampR2]; kal[prevSampR2] = kal[prevSampR1]; + kal[prevSampR1] = (kal[kalGainR] * kal[kalOutR]) + ((1.0-kal[kalGainR])*temp); + //feed the chain of previous samples + if (kal[prevSampR1] > 1.0) kal[prevSampR1] = 1.0; if (kal[prevSampR1] < -1.0) kal[prevSampR1] = -1.0; + double stoneR = kal[kalOutR]*0.777; + fireR -= stoneR; + //end KalmanR + + //fire dynamics + if (fabs(fireL) > compFThresh) { //compression L + fireCompL -= (fireCompL * compFAttack); + fireCompL += ((compFThresh / fabs(fireL))*compFAttack); + } else fireCompL = (fireCompL*(1.0-compFRelease))+compFRelease; + if (fireCompL < 0.0) fireCompL = 0.0; + if (fabs(fireR) > compFThresh) { //compression R + fireCompR -= (fireCompR * compFAttack); + fireCompR += ((compFThresh / fabs(fireR))*compFAttack); + } else fireCompR = (fireCompR*(1.0-compFRelease))+compFRelease; + if (fireCompR < 0.0) fireCompR = 0.0; + if (fireCompL > fireCompR) fireCompL -= (fireCompL * compFAttack); + if (fireCompR > fireCompL) fireCompR -= (fireCompR * compFAttack); + if (fireCompL < 1.0) fireL *= (((1.0-compRatio)*firePad)+(fireCompL*compRatio*fireGain)); + else fireL *= firePad; + if (fireCompR < 1.0) fireR *= (((1.0-compRatio)*firePad)+(fireCompR*compRatio*fireGain)); + else fireR *= firePad; + + //stone dynamics + if (fabs(stoneL) > compSThresh) { //compression L + stoneCompL -= (stoneCompL * compSAttack); + stoneCompL += ((compSThresh / fabs(stoneL))*compSAttack); + } else stoneCompL = (stoneCompL*(1.0-compSRelease))+compSRelease; + if (stoneCompL < 0.0) stoneCompL = 0.0; + if (fabs(stoneR) > compSThresh) { //compression R + stoneCompR -= (stoneCompR * compSAttack); + stoneCompR += ((compSThresh / fabs(stoneR))*compSAttack); + } else stoneCompR = (stoneCompR*(1.0-compSRelease))+compSRelease; + if (stoneCompR < 0.0) stoneCompR = 0.0; + if (stoneCompL > stoneCompR) stoneCompL -= (stoneCompL * compSAttack); + if (stoneCompR > stoneCompL) stoneCompR -= (stoneCompR * compSAttack); + if (stoneCompL < 1.0) stoneL *= (((1.0-compRatio)*stonePad)+(stoneCompL*compRatio*stoneGain)); + else stoneL *= stonePad; + if (stoneCompR < 1.0) stoneR *= (((1.0-compRatio)*stonePad)+(stoneCompR*compRatio*stoneGain)); + else stoneR *= stonePad; + + inputSampleL = stoneL+fireL; + inputSampleR = stoneR+fireR; + + //begin 32 bit stereo floating point dither + int expon; frexpf((float)inputSampleL, &expon); + fpdL ^= fpdL << 13; fpdL ^= fpdL >> 17; fpdL ^= fpdL << 5; + inputSampleL += ((double(fpdL)-uint32_t(0x7fffffff)) * 5.5e-36l * pow(2,expon+62)); + frexpf((float)inputSampleR, &expon); + fpdR ^= fpdR << 13; fpdR ^= fpdR >> 17; fpdR ^= fpdR << 5; + inputSampleR += ((double(fpdR)-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 StoneFireComp::processDoubleReplacing(double **inputs, double **outputs, VstInt32 sampleFrames) +{ + double* in1 = inputs[0]; + double* in2 = inputs[1]; + double* out1 = outputs[0]; + double* out2 = outputs[1]; + + double overallscale = 1.0; + overallscale /= 44100.0; + overallscale *= getSampleRate(); + + double compFThresh = pow(A,4); + double compFAttack = 1.0/(((pow(B,3)*5000.0)+500.0)*overallscale); + double compFRelease = 1.0/(((pow(C,5)*50000.0)+500.0)*overallscale); + double fireGain = D*2.0; fireGain = pow(fireGain,3); + double firePad = fireGain; if (firePad > 1.0) firePad = 1.0; + + double compSThresh = pow(E,4); + double compSAttack = 1.0/(((pow(F,3)*5000.0)+500.0)*overallscale); + double compSRelease = 1.0/(((pow(G,5)*50000.0)+500.0)*overallscale); + double stoneGain = H*2.0; stoneGain = pow(stoneGain,3); + double stonePad = stoneGain; if (stonePad > 1.0) stonePad = 1.0; + + double kalman = 1.0-pow(I,2); + //crossover frequency between mid/bass + double compRatio = 1.0-pow(1.0-J,2); + + while (--sampleFrames >= 0) + { + double inputSampleL = *in1; + double inputSampleR = *in2; + if (fabs(inputSampleL)<1.18e-23) inputSampleL = fpdL * 1.18e-17; + if (fabs(inputSampleR)<1.18e-23) inputSampleR = fpdR * 1.18e-17; + + //begin KalmanL + double fireL = inputSampleL; + double temp = inputSampleL = inputSampleL*(1.0-kalman)*0.777; + inputSampleL *= (1.0-kalman); + //set up gain levels to control the beast + kal[prevSlewL3] += kal[prevSampL3] - kal[prevSampL2]; kal[prevSlewL3] *= 0.5; + kal[prevSlewL2] += kal[prevSampL2] - kal[prevSampL1]; kal[prevSlewL2] *= 0.5; + kal[prevSlewL1] += kal[prevSampL1] - inputSampleL; kal[prevSlewL1] *= 0.5; + //make slews from each set of samples used + kal[accSlewL2] += kal[prevSlewL3] - kal[prevSlewL2]; kal[accSlewL2] *= 0.5; + kal[accSlewL1] += kal[prevSlewL2] - kal[prevSlewL1]; kal[accSlewL1] *= 0.5; + //differences between slews: rate of change of rate of change + kal[accSlewL3] += (kal[accSlewL2] - kal[accSlewL1]); kal[accSlewL3] *= 0.5; + //entering the abyss, what even is this + kal[kalOutL] += kal[prevSampL1] + kal[prevSlewL2] + kal[accSlewL3]; kal[kalOutL] *= 0.5; + //resynthesizing predicted result (all iir smoothed) + kal[kalGainL] += fabs(temp-kal[kalOutL])*kalman*8.0; kal[kalGainL] *= 0.5; + //madness takes its toll. Kalman Gain: how much dry to retain + if (kal[kalGainL] > kalman*0.5) kal[kalGainL] = kalman*0.5; + //attempts to avoid explosions + kal[kalOutL] += (temp*(1.0-(0.68+(kalman*0.157)))); + //this is for tuning a really complete cancellation up around Nyquist + kal[prevSampL3] = kal[prevSampL2]; kal[prevSampL2] = kal[prevSampL1]; + kal[prevSampL1] = (kal[kalGainL] * kal[kalOutL]) + ((1.0-kal[kalGainL])*temp); + //feed the chain of previous samples + if (kal[prevSampL1] > 1.0) kal[prevSampL1] = 1.0; if (kal[prevSampL1] < -1.0) kal[prevSampL1] = -1.0; + double stoneL = kal[kalOutL]*0.777; + fireL -= stoneL; + //end KalmanL + + //begin KalmanR + double fireR = inputSampleR; + temp = inputSampleR = inputSampleR*(1.0-kalman)*0.777; + inputSampleR *= (1.0-kalman); + //set up gain levels to control the beast + kal[prevSlewR3] += kal[prevSampR3] - kal[prevSampR2]; kal[prevSlewR3] *= 0.5; + kal[prevSlewR2] += kal[prevSampR2] - kal[prevSampR1]; kal[prevSlewR2] *= 0.5; + kal[prevSlewR1] += kal[prevSampR1] - inputSampleR; kal[prevSlewR1] *= 0.5; + //make slews from each set of samples used + kal[accSlewR2] += kal[prevSlewR3] - kal[prevSlewR2]; kal[accSlewR2] *= 0.5; + kal[accSlewR1] += kal[prevSlewR2] - kal[prevSlewR1]; kal[accSlewR1] *= 0.5; + //differences between slews: rate of change of rate of change + kal[accSlewR3] += (kal[accSlewR2] - kal[accSlewR1]); kal[accSlewR3] *= 0.5; + //entering the abyss, what even is this + kal[kalOutR] += kal[prevSampR1] + kal[prevSlewR2] + kal[accSlewR3]; kal[kalOutR] *= 0.5; + //resynthesizing predicted result (all iir smoothed) + kal[kalGainR] += fabs(temp-kal[kalOutR])*kalman*8.0; kal[kalGainR] *= 0.5; + //madness takes its toll. Kalman Gain: how much dry to retain + if (kal[kalGainR] > kalman*0.5) kal[kalGainR] = kalman*0.5; + //attempts to avoid explosions + kal[kalOutR] += (temp*(1.0-(0.68+(kalman*0.157)))); + //this is for tuning a really complete cancellation up around Nyquist + kal[prevSampR3] = kal[prevSampR2]; kal[prevSampR2] = kal[prevSampR1]; + kal[prevSampR1] = (kal[kalGainR] * kal[kalOutR]) + ((1.0-kal[kalGainR])*temp); + //feed the chain of previous samples + if (kal[prevSampR1] > 1.0) kal[prevSampR1] = 1.0; if (kal[prevSampR1] < -1.0) kal[prevSampR1] = -1.0; + double stoneR = kal[kalOutR]*0.777; + fireR -= stoneR; + //end KalmanR + + //fire dynamics + if (fabs(fireL) > compFThresh) { //compression L + fireCompL -= (fireCompL * compFAttack); + fireCompL += ((compFThresh / fabs(fireL))*compFAttack); + } else fireCompL = (fireCompL*(1.0-compFRelease))+compFRelease; + if (fireCompL < 0.0) fireCompL = 0.0; + if (fabs(fireR) > compFThresh) { //compression R + fireCompR -= (fireCompR * compFAttack); + fireCompR += ((compFThresh / fabs(fireR))*compFAttack); + } else fireCompR = (fireCompR*(1.0-compFRelease))+compFRelease; + if (fireCompR < 0.0) fireCompR = 0.0; + if (fireCompL > fireCompR) fireCompL -= (fireCompL * compFAttack); + if (fireCompR > fireCompL) fireCompR -= (fireCompR * compFAttack); + if (fireCompL < 1.0) fireL *= (((1.0-compRatio)*firePad)+(fireCompL*compRatio*fireGain)); + else fireL *= firePad; + if (fireCompR < 1.0) fireR *= (((1.0-compRatio)*firePad)+(fireCompR*compRatio*fireGain)); + else fireR *= firePad; + + //stone dynamics + if (fabs(stoneL) > compSThresh) { //compression L + stoneCompL -= (stoneCompL * compSAttack); + stoneCompL += ((compSThresh / fabs(stoneL))*compSAttack); + } else stoneCompL = (stoneCompL*(1.0-compSRelease))+compSRelease; + if (stoneCompL < 0.0) stoneCompL = 0.0; + if (fabs(stoneR) > compSThresh) { //compression R + stoneCompR -= (stoneCompR * compSAttack); + stoneCompR += ((compSThresh / fabs(stoneR))*compSAttack); + } else stoneCompR = (stoneCompR*(1.0-compSRelease))+compSRelease; + if (stoneCompR < 0.0) stoneCompR = 0.0; + if (stoneCompL > stoneCompR) stoneCompL -= (stoneCompL * compSAttack); + if (stoneCompR > stoneCompL) stoneCompR -= (stoneCompR * compSAttack); + if (stoneCompL < 1.0) stoneL *= (((1.0-compRatio)*stonePad)+(stoneCompL*compRatio*stoneGain)); + else stoneL *= stonePad; + if (stoneCompR < 1.0) stoneR *= (((1.0-compRatio)*stonePad)+(stoneCompR*compRatio*stoneGain)); + else stoneR *= stonePad; + + inputSampleL = stoneL+fireL; + inputSampleR = stoneR+fireR; + + //begin 64 bit stereo floating point dither + //int expon; frexp((double)inputSampleL, &expon); + fpdL ^= fpdL << 13; fpdL ^= fpdL >> 17; fpdL ^= fpdL << 5; + //inputSampleL += ((double(fpdL)-uint32_t(0x7fffffff)) * 1.1e-44l * pow(2,expon+62)); + //frexp((double)inputSampleR, &expon); + fpdR ^= fpdR << 13; fpdR ^= fpdR >> 17; fpdR ^= fpdR << 5; + //inputSampleR += ((double(fpdR)-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++; + } +} +} // end namespace