-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathAdsrEnvelope.cpp
More file actions
38 lines (30 loc) · 1.03 KB
/
AdsrEnvelope.cpp
File metadata and controls
38 lines (30 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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