summaryrefslogtreecommitdiff
path: root/src/mdaPiano.cpp
diff options
context:
space:
mode:
authorrekado <rekado@elephly.net>2013-01-14 18:16:19 +0800
committerrekado <rekado@elephly.net>2013-01-14 18:16:19 +0800
commitd577482b1d594cd811d731ce320926801b7a34fa (patch)
treefeb1a8da579ae84f655bbde025b2ce9991405655 /src/mdaPiano.cpp
parentb0e8f1588987af7a8fae41cae0f3a7e24667322f (diff)
move mdaPiano::noteOn to mdaPianoVoice::on
Diffstat (limited to 'src/mdaPiano.cpp')
-rw-r--r--src/mdaPiano.cpp74
1 files changed, 0 insertions, 74 deletions
diff --git a/src/mdaPiano.cpp b/src/mdaPiano.cpp
index 2b8a81b..7c1a3a0 100644
--- a/src/mdaPiano.cpp
+++ b/src/mdaPiano.cpp
@@ -207,80 +207,6 @@ if(!(r > -2.0f) || !(r < 2.0f))
}
-void mdaPiano::noteOn(uint32_t note, uint32_t velocity)
-{
- float * param = programs[curProgram].param;
- float l=99.0f;
- uint32_t v, vl=0, k, s;
-
- if(velocity>0)
- {
- if(activevoices < poly) //add a note
- {
- vl = activevoices;
- activevoices++;
- }
- else //steal a note
- {
- for(v=0; v<poly; v++) //find quietest voice
- {
- if(voice[v].env < l) { l = voice[v].env; vl = v; }
- }
- }
-
- k = (note - 60) * (note - 60);
- l = fine + random * ((float)(k % 13) - 6.5f); //random & fine tune
- if(note > 60) l += stretch * (float)k; //stretch
-
- s = size;
- if(velocity > 40) s += (uint32_t)(sizevel * (float)(velocity - 40));
-
- k = 0;
- while(note > (kgrp[k].high + s)) k++; //find keygroup
-
- l += (float)(note - kgrp[k].root); //pitch
- l = 22050.0f * iFs * (float)exp(0.05776226505 * l);
- voice[vl].delta = (uint32_t)(65536.0f * l);
- voice[vl].frac = 0;
- voice[vl].pos = kgrp[k].pos;
- voice[vl].end = kgrp[k].end;
- voice[vl].loop = kgrp[k].loop;
-
- voice[vl].env = (0.5f + velsens) * (float)pow(0.0078f * velocity, velsens); //velocity
-
- l = 50.0f + param[4] * param[4] * muff + muffvel * (float)(velocity - 64); //muffle
- if(l < (55.0f + 0.25f * (float)note)) l = 55.0f + 0.25f * (float)note;
- if(l > 210.0f) l = 210.0f;
- voice[vl].ff = l * l * iFs;
- voice[vl].f0 = voice[vl].f1 = 0.0f;
-
- voice[vl].note = note; //note->pan
- if(note < 12) note = 12;
- if(note > 108) note = 108;
- l = volume * trim;
- voice[vl].outr = l + l * width * (float)(note - 60);
- voice[vl].outl = l + l - voice[vl].outr;
-
- if(note < 44) note = 44; //limit max decay length
- l = 2.0f * param[0];
- if(l < 1.0f) l += 0.25f - 0.5f * param[0];
- voice[vl].dec = (float)exp(-iFs * exp(-0.6 + 0.033 * (double)note - l));
- }
- else //note off
- {
- for(v=0; v<NVOICES; v++) if(voice[v].note==note) //any voices playing that note?
- {
- if(sustain==0)
- {
- if(note < 94 || note == SUSTAIN) //no release on highest notes
- voice[v].dec = (float)exp(-iFs * exp(2.0 + 0.017 * (double)note - 2.0 * param[1]));
- }
- else voice[v].note = SUSTAIN;
- }
- }
-}
-
-
uint32_t mdaPiano::processEvents(VstEvents* ev)
{
uint32_t npos=0;