diff options
author | David Robillard <d@drobilla.net> | 2010-02-22 21:32:24 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-02-22 21:32:24 +0000 |
commit | 23d245ab8840d5518a691835e243eba705a6838b (patch) | |
tree | a671fca306763f144a1308e19a31ecf230963d31 /src/mdaDetune.cpp | |
parent | e926cd18a51f037bd6078b0177a0c99de844be36 (diff) | |
download | mda.lv2-23d245ab8840d5518a691835e243eba705a6838b.tar.gz mda.lv2-23d245ab8840d5518a691835e243eba705a6838b.tar.bz2 mda.lv2-23d245ab8840d5518a691835e243eba705a6838b.zip |
Merge with upstream r8.
git-svn-id: http://svn.drobilla.net/lad/trunk/mda-lv2@2474 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/mdaDetune.cpp')
-rw-r--r-- | src/mdaDetune.cpp | 88 |
1 files changed, 53 insertions, 35 deletions
diff --git a/src/mdaDetune.cpp b/src/mdaDetune.cpp index 21274f5..8fe7704 100644 --- a/src/mdaDetune.cpp +++ b/src/mdaDetune.cpp @@ -28,9 +28,6 @@ mdaDetune::mdaDetune(audioMasterCallback audioMaster): AudioEffectX(audioMaster, DECLARE_LVZ_DEPRECATED(canMono) (); canProcessReplacing(); - ///initialise... - buflen=0; - programs[0].param[0] = 0.20f; //fine programs[0].param[1] = 0.90f; //mix programs[0].param[2] = 0.50f; //output @@ -47,43 +44,32 @@ mdaDetune::mdaDetune(audioMasterCallback audioMaster): AudioEffectX(audioMaster, programs[2].param[3] = 0.50f; strcpy(programs[2].name,"Out Of Tune"); - setProgram(0); + ///initialise... + curProgram=0; suspend(); -} - - -void mdaDetune::resume() ///update internal parameters... -{ - float * param = programs[curProgram].param; - - semi = 3.0f * param[0] * param[0] * param[0]; + + semi = 3.0f * 0.20f * 0.20f * 0.20f; 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;i<buflen;i++) { win[i] = (float)(0.5 - 0.5 * cos(p)); p+=dp; } - } + wet = 1.0f; + dry = wet - wet * 0.90f * 0.90f; + wet = (wet + wet - wet * 0.90f) * 0.90f; } - void mdaDetune::suspend() ///clear any buffers... { - memset(buf, 0, BUFMAX * sizeof(float)); - memset(win, 0, BUFMAX * sizeof(float)); + memset(buf, 0, sizeof (buf)); + memset(win, 0, sizeof (win)); pos0 = 0; pos1 = pos2 = 0.0f; + + //recalculate crossfade window + buflen = 1 << (8 + (LvzInt32)(4.9f * programs[curProgram].param[3])); + 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;i<buflen;i++) { win[i] = (float)(0.5 - 0.5 * cos(p)); p+=dp; } } @@ -92,15 +78,47 @@ void mdaDetune::setProgram(LvzInt32 program) if ((unsigned int)program < NPROGS) { curProgram = program; - resume(); } } void mdaDetune::setParameter(LvzInt32 which, float value) { - programs[curProgram].param[which] = value; - resume(); + float * param = programs[curProgram].param; + param[which] = value; + + switch(which) + { + case 0: + semi = 3.0f * param[0] * param[0] * param[0]; + dpos2 = (float)pow(1.0594631f, semi); + dpos1 = 1.0f / dpos2; + break; + case 1: + case 2: + 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]; + break; + case 3: + { + 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;i<buflen;i++) { win[i] = (float)(0.5 - 0.5 * cos(p)); p+=dp; } + } + break; + } + default: + break; + } } |