commit 5334d94283a513ae42e472aa020db571a3589fb9
parent bb5bb4e36131198e25e9d80f1b18e859417d558d
Author: fundamental <mark.d.mccurry@gmail.com>
Date: Mon, 16 Jun 2014 15:33:45 -0400
Smooth Out Amplitude Envelop Tail
Another Commit in the Christopher Oliver Patch Set
Diffstat:
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/Synth/Envelope.cpp b/src/Synth/Envelope.cpp
@@ -159,6 +159,14 @@ float Envelope::envout()
return out;
}
+inline float Envelope::env_dB2rap(float db) {
+ return (exp10f((db) / 20.0f) - 0.01)/.99f;
+}
+
+inline float Envelope::env_rap2dB(float rap) {
+ return 20.0f * log10f(rap * 0.99f + 0.01);
+}
+
/*
* Envelope Output (dB)
*/
@@ -169,8 +177,8 @@ float Envelope::envout_dB()
return envout();
if((currentpoint == 1) && (!keyreleased || (forcedrelase == 0))) { //first point is always lineary interpolated
- float v1 = dB2rap(envval[0]);
- float v2 = dB2rap(envval[1]);
+ float v1 = env_dB2rap(envval[0]);
+ float v2 = env_dB2rap(envval[1]);
out = v1 + (v2 - v1) * t;
t += inct;
@@ -182,12 +190,12 @@ float Envelope::envout_dB()
}
if(out > 0.001f)
- envoutval = rap2dB(out);
+ envoutval = env_rap2dB(out);
else
envoutval = MIN_ENVELOPE_DB;
}
else
- out = dB2rap(envout());
+ out = env_dB2rap(envout());
return out;
}
diff --git a/src/Synth/Envelope.h b/src/Synth/Envelope.h
@@ -42,6 +42,8 @@ class Envelope
* @return returns 1 if the envelope is finished*/
bool finished() const;
private:
+ float env_rap2dB(float rap);
+ float env_dB2rap(float db);
int envpoints;
int envsustain; //"-1" means disabled
float envdt[MAX_ENVELOPE_POINTS]; //millisecons