summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrekado <rekado@elephly.net>2013-01-14 21:09:45 +0800
committerrekado <rekado@elephly.net>2013-01-14 21:09:45 +0800
commit94582e6641d67daf3af30de4fc9a3e5577583227 (patch)
tree8c550fa97acf4371fdfe7b7aacafd41da4856123
parentde9ff425adc8df348f88505a5a045006f44c6e55 (diff)
move `update` to voices and call from synth
-rw-r--r--src/mdaPiano.cpp25
-rw-r--r--src/mdaPianoVoice.cpp23
-rw-r--r--src/mdaPianoVoice.h1
3 files changed, 29 insertions, 20 deletions
diff --git a/src/mdaPiano.cpp b/src/mdaPiano.cpp
index d3286c3..17298ed 100644
--- a/src/mdaPiano.cpp
+++ b/src/mdaPiano.cpp
@@ -43,26 +43,11 @@ mdaPiano::mdaPiano(double rate)
update();
}
-
-void mdaPiano::update() //parameter change
-{
- float * param = programs[curProgram].param;
- size = (uint32_t)(12.0f * param[2] - 6.0f);
- sizevel = 0.12f * param[3];
- muffvel = param[5] * param[5] * 5.0f;
-
- velsens = 1.0f + param[6] + param[6];
- if(param[6] < 0.25f) velsens -= 0.75f - 3.0f * param[6];
-
- fine = param[9] - 0.5f;
- random = 0.077f * param[10] * param[10];
- stretch = 0.000434f * (param[11] - 0.5f);
-
- cdep = param[7] * param[7];
- trim = 1.50f - 0.79f * cdep;
- width = 0.04f * param[7]; if(width > 0.03f) width = 0.03f;
-
- poly = 8 + (uint32_t)(24.9f * param[8]);
+//parameter change
+void mdaPiano::update() {
+ for (uint32_t v=0; v<NVOICES; ++v) {
+ voices[v]->update(Current);
+ }
}
diff --git a/src/mdaPianoVoice.cpp b/src/mdaPianoVoice.cpp
index a1f9529..4c88e8f 100644
--- a/src/mdaPianoVoice.cpp
+++ b/src/mdaPianoVoice.cpp
@@ -205,3 +205,26 @@ if(!(r > -2.0f) || !(r < 2.0f))
for(v=0; v<activevoices; v++) if(voice[v].env < SILENCE) voice[v] = voice[--activevoices];
notes[0] = EVENTS_DONE; //mark events buffer as done
}
+
+
+void mdaPianoVoice::update(Param par)
+{
+ //TODO: use local copy
+ float * param = programs[curProgram].param;
+ size = (uint32_t)(12.0f * param[2] - 6.0f);
+ sizevel = 0.12f * param[3];
+ muffvel = param[5] * param[5] * 5.0f;
+
+ velsens = 1.0f + param[6] + param[6];
+ if(param[6] < 0.25f) velsens -= 0.75f - 3.0f * param[6];
+
+ fine = param[9] - 0.5f;
+ random = 0.077f * param[10] * param[10];
+ stretch = 0.000434f * (param[11] - 0.5f);
+
+ cdep = param[7] * param[7];
+ trim = 1.50f - 0.79f * cdep;
+ width = 0.04f * param[7]; if(width > 0.03f) width = 0.03f;
+
+ poly = 8 + (uint32_t)(24.9f * param[8]);
+}
diff --git a/src/mdaPianoVoice.h b/src/mdaPianoVoice.h
index b7958d4..c7b2e43 100644
--- a/src/mdaPianoVoice.h
+++ b/src/mdaPianoVoice.h
@@ -46,6 +46,7 @@ class mdaPianoVoice : public LV2::Voice {
mdaPianoVoice(double, short*, KGRP*);
float p_helper(unsigned short, Param);
+ void update(Param); // recalculates internal variables
void reset(void);
};