Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions LibSource/AdsrEnvelope.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "AdsrEnvelope.h"

template<>
float AdsrEnvelope<true>::increment(float level, float amount){
return level + amount;
}

template<>
float AdsrEnvelope<true>::decrement(float level, float amount){
return level + amount;
}

template<>
float AdsrEnvelope<false>::increment(float level, float amount){
return level + (1.01-level)*amount; // aim slightly higher to ensure we reach 1.0
}

template<>
float AdsrEnvelope<false>::decrement(float level, float amount){
return level + level * amount;
}

template<>
float AdsrEnvelope<true>::calculateIncrement(float startValue, float endValue, float time){
return (endValue-startValue)/(sampleRate*time+1);
}

template<>
float AdsrEnvelope<false>::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<true>::MINLEVEL = 0;

template<>
const float AdsrEnvelope<false>::MINLEVEL = 0.00001; // -100dB
37 changes: 0 additions & 37 deletions LibSource/AdsrEnvelope.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,43 +168,6 @@ class AdsrEnvelope : public Envelope {
int gateTime;
};

template<>
float AdsrEnvelope<true>::increment(float level, float amount){
return level + amount;
}

template<>
float AdsrEnvelope<true>::decrement(float level, float amount){
return level + amount;
}

template<>
float AdsrEnvelope<false>::increment(float level, float amount){
return level + (1.01-level)*amount; // aim slightly higher to ensure we reach 1.0
}

template<>
float AdsrEnvelope<false>::decrement(float level, float amount){
return level + level * amount;
}

template<>
float AdsrEnvelope<true>::calculateIncrement(float startValue, float endValue, float time){
return (endValue-startValue)/(sampleRate*time+1);
}

template<>
float AdsrEnvelope<false>::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<true>::MINLEVEL = 0;

template<>
const float AdsrEnvelope<false>::MINLEVEL = 0.00001; // -100dB

typedef AdsrEnvelope<true> LinearAdsrEnvelope;
typedef AdsrEnvelope<false> ExponentialAdsrEnvelope;

Expand Down