summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrekado <rekado@elephly.net>2013-01-14 21:35:09 +0800
committerrekado <rekado@elephly.net>2013-01-14 21:41:34 +0800
commita5c1fa43261a7ce246a92c6ffd1c339b4cb1b613 (patch)
tree5df938e4893f5d7c43e1ea523f7433d6267c04da
parentf4e5570ed047b2975321786cb3093bcad8a3224f (diff)
implement volume setter
-rw-r--r--src/mdaPiano.cpp9
-rw-r--r--src/mdaPiano.h1
-rw-r--r--src/mdaPianoVoice.h2
3 files changed, 11 insertions, 1 deletions
diff --git a/src/mdaPiano.cpp b/src/mdaPiano.cpp
index 1110c56..9912c75 100644
--- a/src/mdaPiano.cpp
+++ b/src/mdaPiano.cpp
@@ -52,6 +52,13 @@ void mdaPiano::update() {
}
+void mdaPiano::setVolume(float value)
+{
+ for (uint32_t v=0; v<NVOICES; ++v)
+ voices[v]->set_volume(value);
+}
+
+
void mdaPiano::setParameter(unsigned char id, float value)
{
if(id>=NPARAMS)
@@ -95,7 +102,7 @@ void mdaPiano::handle_midi(uint32_t size, unsigned char* data) {
break;
case 0x07: //volume
- volume = 0.00002f * (float)(data[2] * data[2]);
+ setVolume(0.00002f * (float)(data[2] * data[2]));
break;
case 0x40: //sustain pedal
diff --git a/src/mdaPiano.h b/src/mdaPiano.h
index 73f1404..723041a 100644
--- a/src/mdaPiano.h
+++ b/src/mdaPiano.h
@@ -20,6 +20,7 @@ public:
void load_samples(short**);
void handle_midi(uint32_t size, unsigned char* data);
+ void setVolume(float);
void setParameter(unsigned char, float);
diff --git a/src/mdaPianoVoice.h b/src/mdaPianoVoice.h
index 53d8d60..dc87719 100644
--- a/src/mdaPianoVoice.h
+++ b/src/mdaPianoVoice.h
@@ -21,6 +21,7 @@ class mdaPianoVoice : public LV2::Voice {
short *waves;
float default_preset[NPARAMS]; // contains the default preset
short sustain;
+ float volume;
// voice state
uint32_t delta; //sample playback
@@ -46,6 +47,7 @@ class mdaPianoVoice : public LV2::Voice {
public:
mdaPianoVoice(double, short*, KGRP*);
+ void set_volume(float v) { volume = v; }
float p_helper(unsigned short, Param);
void update(Param); // recalculates internal variables