diff --git a/LibSource/AdsrEnvelope.cpp b/LibSource/AdsrEnvelope.cpp new file mode 100644 index 00000000..0d2e6f3a --- /dev/null +++ b/LibSource/AdsrEnvelope.cpp @@ -0,0 +1,38 @@ +#include "AdsrEnvelope.h" + +template<> +float AdsrEnvelope::increment(float level, float amount){ + return level + amount; +} + +template<> +float AdsrEnvelope::decrement(float level, float amount){ + return level + amount; +} + +template<> +float AdsrEnvelope::increment(float level, float amount){ + return level + (1.01-level)*amount; // aim slightly higher to ensure we reach 1.0 +} + +template<> +float AdsrEnvelope::decrement(float level, float amount){ + return level + level * amount; +} + +template<> +float AdsrEnvelope::calculateIncrement(float startValue, float endValue, float time){ + return (endValue-startValue)/(sampleRate*time+1); +} + +template<> +float AdsrEnvelope::calculateIncrement(float startValue, float endValue, float time) { + // Ref: Christian Schoenebeck http://www.musicdsp.org/showone.php?id=189 + return (logf(endValue) - logf(startValue)) / (time*sampleRate+10); +} + +template<> +const float AdsrEnvelope::MINLEVEL = 0; + +template<> +const float AdsrEnvelope::MINLEVEL = 0.00001; // -100dB diff --git a/LibSource/AdsrEnvelope.h b/LibSource/AdsrEnvelope.h index 21e57f6e..d918e92f 100644 --- a/LibSource/AdsrEnvelope.h +++ b/LibSource/AdsrEnvelope.h @@ -168,43 +168,6 @@ class AdsrEnvelope : public Envelope { int gateTime; }; -template<> -float AdsrEnvelope::increment(float level, float amount){ - return level + amount; -} - -template<> -float AdsrEnvelope::decrement(float level, float amount){ - return level + amount; -} - -template<> -float AdsrEnvelope::increment(float level, float amount){ - return level + (1.01-level)*amount; // aim slightly higher to ensure we reach 1.0 -} - -template<> -float AdsrEnvelope::decrement(float level, float amount){ - return level + level * amount; -} - -template<> -float AdsrEnvelope::calculateIncrement(float startValue, float endValue, float time){ - return (endValue-startValue)/(sampleRate*time+1); -} - -template<> -float AdsrEnvelope::calculateIncrement(float startValue, float endValue, float time) { - // Ref: Christian Schoenebeck http://www.musicdsp.org/showone.php?id=189 - return (logf(endValue) - logf(startValue)) / (time*sampleRate+10); -} - -template<> -const float AdsrEnvelope::MINLEVEL = 0; - -template<> -const float AdsrEnvelope::MINLEVEL = 0.00001; // -100dB - typedef AdsrEnvelope LinearAdsrEnvelope; typedef AdsrEnvelope ExponentialAdsrEnvelope;