From d5b12c38851c53791d95c212baffb091f802c10a Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 22 Feb 2010 21:34:05 +0000 Subject: Merge with upstream r9. git-svn-id: http://svn.drobilla.net/lad/trunk/mda-lv2@2475 a436a847-0d15-0410-975c-d299462d15a1 --- src/mdaDetune.cpp | 23 +++++++++ src/mdaSplitter.cpp | 143 ++++++++++++++++++++++++++++++++-------------------- src/mdaSplitter.h | 27 ++++++---- 3 files changed, 130 insertions(+), 63 deletions(-) diff --git a/src/mdaDetune.cpp b/src/mdaDetune.cpp index 8fe7704..925d401 100644 --- a/src/mdaDetune.cpp +++ b/src/mdaDetune.cpp @@ -78,6 +78,29 @@ void mdaDetune::setProgram(LvzInt32 program) if ((unsigned int)program < NPROGS) { curProgram = program; + + // update + float * param = programs[curProgram].param; + semi = 3.0f * param[0] * param[0] * param[0]; + dpos2 = (float)pow(1.0594631f, semi); + dpos1 = 1.0f / dpos2; + + wet = (float)pow(10.0f, 2.0f * param[2] - 1.0f); + dry = wet - wet * param[1] * param[1]; + wet = (wet + wet - wet * param[1]) * param[1]; + + LvzInt32 tmp = 1 << (8 + (LvzInt32)(4.9f * param[3])); + + if(tmp!=buflen) //recalculate crossfade window + { + buflen = tmp; + if (buflen > BUFMAX) buflen = BUFMAX; + bufres = 1000.0f * (float)buflen / getSampleRate(); + + LvzInt32 i; //hanning half-overlap-and-add + double p=0.0, dp=6.28318530718/buflen; + for(i=0;i1.0f) freq = 1.0f; + ff = -1.0f; //above + LvzInt32 tmp = (LvzInt32)(2.9f * param[2]); //frequency switching + if(tmp==0) ff = 0.0f; //below + if(tmp==1) freq = 0.001f; //all + break; + } + case 3: + case 4: + { + ldisp = 40.0f * param[3] - 40.0f; //level + level = (float)pow(10.0f, 0.05f * ldisp + 0.3f); + ll = 0.0f; //above + LvzInt32 tmp = (LvzInt32)(2.9f * param[4]); //level switching + if(tmp==0) ll = -1.0f; //below + if(tmp==1) level = 0.0f; //all + break; + } + case 5: + att = 0.05f - 0.05f * param[5]; + rel = 1.0f - (float)exp(-6.0f - 4.0f * param[5]); //envelope + if(att>0.02f) att=0.02f; + if(rel<0.9995f) rel = 0.9995f; + break; + default: + break; + } } -float mdaSplitter::getParameter(LvzInt32 index) { return programs[curProgram].param[index]; } +float mdaSplitter::getParameter(LvzInt32 which) { return programs[curProgram].param[which]; } void mdaSplitter::setProgramName(char *name) { strcpy(programs[curProgram].name, name); } void mdaSplitter::getProgramName(char *name) { strcpy(name, programs[curProgram].name); } -bool mdaSplitter::getProgramNameIndexed (LvzInt32 category, LvzInt32 index, char* name) +bool mdaSplitter::getProgramNameIndexed (LvzInt32 category, LvzInt32 which, char* name) { - if ((unsigned int)index < NPROGS) + if ((unsigned int)which < NPROGS) { - strcpy(name, programs[index].name); + strcpy(name, programs[which].name); return true; } return false; } -void mdaSplitter::getParameterName(LvzInt32 index, char *label) +void mdaSplitter::getParameterName(LvzInt32 which, char *label) { - switch(index) + switch(which) { case 0: strcpy(label, "Mode"); break; case 1: strcpy(label, "Freq"); break; - case 2: strcpy(label, "Freq Mode"); break; + case 2: strcpy(label, "Freq SW"); break; case 3: strcpy(label, "Level"); break; - case 4: strcpy(label, "Level Mode"); break; + case 4: strcpy(label, "Level SW"); break; case 5: strcpy(label, "Envelope"); break; default: strcpy(label, "Output"); } } -void mdaSplitter::getParameterDisplay(LvzInt32 index, char *text) +void mdaSplitter::getParameterDisplay(LvzInt32 which, char *text) { char string[16]; float * param = programs[curProgram].param; - switch(index) + switch(which) { - case 0: switch(mode) - { - case 0: strcpy (string, "NORMAL "); break; - case 1: strcpy (string, "INVERSE "); break; - case 2: strcpy (string, "NORM/INV"); break; - default: strcpy (string, "INV/NORM"); break; - } break; + case 0: + switch(mode) + { + case 0: strcpy (string, "NORMAL "); break; + case 1: strcpy (string, "INVERSE "); break; + case 2: strcpy (string, "NORM/INV"); break; + default: strcpy (string, "INV/NORM"); break; + } + break; case 1: sprintf(string, "%.0f", fdisp); break; case 3: sprintf(string, "%.0f", ldisp); break; - case 5: sprintf(string, "%.0f", (float)pow(10.0f, 1.0f + 2.0f * param[index])); break; - case 6: sprintf(string, "%.1f", 40.0f * param[index] - 20.0f); break; - default: switch((LvzInt32)(2.9f * param[index])) - { - case 0: strcpy (string, "BELOW"); break; - case 1: strcpy (string, "ALL"); break; - default: strcpy (string, "ABOVE"); break; - } break; + case 5: sprintf(string, "%.0f", (float)pow(10.0f, 1.0f + 2.0f * param[which])); break; + case 6: sprintf(string, "%.1f", 40.0f * param[which] - 20.0f); break; + default: + switch((LvzInt32)(2.9f * param[which])) + { + case 0: strcpy (string, "BELOW"); break; + case 1: strcpy (string, "ALL"); break; + default: strcpy (string, "ABOVE"); break; + } + break; } string[8] = 0; - strcpy(text, (char *)string); + strcpy(text, string); } -void mdaSplitter::getParameterLabel(LvzInt32 index, char *label) +void mdaSplitter::getParameterLabel(LvzInt32 which, char *label) { - switch(index) + *label = '\0'; + + switch(which) { case 1: strcpy(label, "Hz"); break; case 3: case 6: strcpy(label, "dB"); break; case 5: strcpy(label, "ms"); break; - default: strcpy(label, ""); + default: break; } } diff --git a/src/mdaSplitter.h b/src/mdaSplitter.h index dcb078c..b2ca065 100644 --- a/src/mdaSplitter.h +++ b/src/mdaSplitter.h @@ -12,7 +12,17 @@ class mdaSplitterProgram { public: - mdaSplitterProgram(); + mdaSplitterProgram() + { + param[0] = 0.10f; //mode + param[1] = 0.50f; //freq + param[2] = 0.25f; //freq mode + param[3] = 0.50f; //level (was 2) + param[4] = 0.50f; //level mode + param[5] = 0.50f; //envelope + param[6] = 0.50f; //gain + strcpy(name, "Frequency/Level Splitter"); + } private: friend class mdaSplitter; float param[NPARAMS]; @@ -24,19 +34,18 @@ class mdaSplitter : public AudioEffectX { public: mdaSplitter(audioMasterCallback audioMaster); - ~mdaSplitter(); virtual void process(float **inputs, float **outputs, LvzInt32 sampleFrames); virtual void processReplacing(float **inputs, float **outputs, LvzInt32 sampleFrames); virtual void setProgram(LvzInt32 program); virtual void setProgramName(char *name); virtual void getProgramName(char *name); - virtual bool getProgramNameIndexed (LvzInt32 category, LvzInt32 index, char* name); - virtual void setParameter(LvzInt32 index, float value); - virtual float getParameter(LvzInt32 index); - virtual void getParameterLabel(LvzInt32 index, char *label); - virtual void getParameterDisplay(LvzInt32 index, char *text); - virtual void getParameterName(LvzInt32 index, char *text); + virtual bool getProgramNameIndexed (LvzInt32 category, LvzInt32 which, char* name); + virtual void setParameter(LvzInt32 which, float value); + virtual float getParameter(LvzInt32 which); + virtual void getParameterLabel(LvzInt32 which, char *label); + virtual void getParameterDisplay(LvzInt32 which, char *text); + virtual void getParameterName(LvzInt32 which, char *text); virtual void suspend(); virtual void resume(); @@ -46,7 +55,7 @@ public: virtual LvzInt32 getVendorVersion() { return 1000; } protected: - mdaSplitterProgram *programs; + mdaSplitterProgram programs[NPROGS]; ///global internal variables float freq, fdisp, buf0, buf1, buf2, buf3; //filter -- cgit v1.2.1