aboutsummaryrefslogtreecommitdiffstats
path: root/src/mdaSpecMeter.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-02-22 21:24:34 +0000
committerDavid Robillard <d@drobilla.net>2010-02-22 21:24:34 +0000
commitadacb33bf4eadcd49a744177bf3f059e7b2f2f52 (patch)
tree922620c99fdc348529002d1a000ec0e8f94f3041 /src/mdaSpecMeter.cpp
parent4514036c46168f4bbc693649989d53bdffe6137b (diff)
downloadmda.lv2-adacb33bf4eadcd49a744177bf3f059e7b2f2f52.tar.gz
mda.lv2-adacb33bf4eadcd49a744177bf3f059e7b2f2f52.tar.bz2
mda.lv2-adacb33bf4eadcd49a744177bf3f059e7b2f2f52.zip
Merge with upstream r2.
git-svn-id: http://svn.drobilla.net/lad/trunk/mda-lv2@2471 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/mdaSpecMeter.cpp')
-rw-r--r--src/mdaSpecMeter.cpp54
1 files changed, 32 insertions, 22 deletions
diff --git a/src/mdaSpecMeter.cpp b/src/mdaSpecMeter.cpp
index 7aae786..5a02c7c 100644
--- a/src/mdaSpecMeter.cpp
+++ b/src/mdaSpecMeter.cpp
@@ -22,8 +22,10 @@ createEffectInstance (audioMasterCallback audioMaster)
mdaSpecMeterProgram::mdaSpecMeterProgram ()
{
- param[_PARAM0] = 1.0;
- strcpy (name, "MDA SpecMeter");
+ param[_PARAM0] = 0.5;
+ param[_PARAM1] = 0.5;
+ param[_PARAM2] = 0.75;
+ strcpy (name, "default");
}
@@ -83,9 +85,9 @@ mdaSpecMeter::suspend ()
lpeak = rpeak = lrms = rrms = corr = 0.0f;
Lhold = Rhold = 0.0f;
Lmin = Rmin = 0.0000001f;
- for (long i = 0; i < 16; i++) {
+ for (LvzInt32 i = 0; i < 16; i++) {
band[0][i] = band[1][i] = 0.0f;
- for (long j = 0; j < 6; j++)
+ for (LvzInt32 j = 0; j < 6; j++)
lpp[j][i] = rpp[j][i] = 0.0f;
}
@@ -93,20 +95,14 @@ mdaSpecMeter::suspend ()
}
void
-mdaSpecMeter::setSampleRate (float rate)
+mdaSpecMeter::setSampleRate(float sampleRate)
{
- AudioEffectX::setSampleRate (rate);
- if (rate > 64000) {
- topband = 12;
- kmax = 4096;
- } else {
- topband = 11;
- kmax = 2048;
- }
- iK = 1.0f / (float) kmax;
+ AudioEffectX::setSampleRate(sampleRate);
+ if(sampleRate > 64000) { topband = 12; kmax = 4096; }
+ else { topband = 11; kmax = 2048; }
+ iK = 1.0f / (float)kmax;
}
-
mdaSpecMeter::~mdaSpecMeter ()
{
//if(buffer) delete [] buffer;
@@ -127,10 +123,21 @@ mdaSpecMeter::getProgramName (char *name)
strcpy (name, programs[curProgram].name);
}
+
+bool
+mdaSpecMeter::getProgramNameIndexed (LvzInt32 category, LvzInt32 index, char* name)
+{
+ if ((unsigned int)index < NPROGS) {
+ strcpy(name, programs[index].name);
+ return true;
+ }
+ return false;
+}
+
float
mdaSpecMeter::getParameter (LvzInt32 index)
{
- return param[index];
+ return programs[curProgram].param[index];
}
void
@@ -148,12 +155,11 @@ mdaSpecMeter::setProgram (LvzInt32 program)
void
mdaSpecMeter::setParameter (LvzInt32 index, float value)
{
- mdaSpecMeterProgram *p = &programs[curProgram];
- param[index] = p->param[index] = value;
+ programs[curProgram].param[index] = value;
switch (index) {
case _PARAM0:
- gain = (float) pow (10.0f, 2.0f * param[index] - 1.0f);
+ gain = (float)pow(10.0f, 2.0f * programs[curProgram].param[index] - 1.0f);
break;
default:
@@ -181,13 +187,17 @@ void
mdaSpecMeter::getParameterDisplay (LvzInt32 index, char *text)
{
char string[16];
+ float * param = programs[curProgram].param;
switch (index) {
case _PARAM0:
- sprintf (string, "%.1f", 40.0f * param[index] - 20.0f);
+ sprintf(string, "%.1f", 40.0f * param[index] - 20.0f);
+ break;
+ case _PARAM1:
+ strcpy (string, "");
break;
default:
- sprintf (string, "%.0f", 0.0f * param[index]);
+ sprintf(string, "%.0f", 100.0f * param[index]);
}
string[8] = 0;
strcpy (text, (char *) string);
@@ -199,7 +209,7 @@ mdaSpecMeter::getParameterLabel (LvzInt32 index, char *label)
{
switch (index) {
case _PARAM0:
- strcpy (label, "Gain");
+ strcpy (label, "");
break;
default:
strcpy (label, "");