26 |
#include <math.h> |
#include <math.h> |
27 |
|
|
28 |
#include "global.h" |
#include "global.h" |
29 |
|
#include "gig.h" |
30 |
|
#include "rtelmemorypool.h" |
31 |
#include "modulationsystem.h" |
#include "modulationsystem.h" |
32 |
|
|
33 |
#define EG_ENVELOPE_LIMIT 0.001 |
#define EG_ENVELOPE_LIMIT 0.001 |
42 |
public: |
public: |
43 |
enum stage_t { |
enum stage_t { |
44 |
stage_attack, |
stage_attack, |
45 |
|
stage_attack_hold, |
46 |
|
stage_decay1, |
47 |
|
stage_decay2, |
48 |
stage_sustain, |
stage_sustain, |
49 |
stage_release, |
stage_release, |
50 |
stage_end |
stage_end |
51 |
}; |
}; |
52 |
|
|
|
static const double Limit; |
|
|
|
|
53 |
EG_VCA(); |
EG_VCA(); |
54 |
void Process(uint Samples); |
void Process(uint Samples, RTEList<ModulationSystem::Event>* pEvents, ModulationSystem::Event* pTriggerEvent, double SamplePos, double CurrentPitch); |
55 |
void Trigger(uint PreAttack, double Attack, double Release, uint Delay); |
void Trigger(uint PreAttack, double AttackTime, bool HoldAttack, long LoopStart, double Decay1Time, double Decay2Time, bool InfiniteSustain, uint SustainLevel, double ReleaseTime, uint Delay); |
56 |
void Release(uint Delay); |
inline EG_VCA::stage_t GetStage() { return Stage; } |
|
inline EG_VCA::stage_t GetStage() { return Stage; }; |
|
57 |
protected: |
protected: |
58 |
|
uint TriggerDelay; ///< number of sample points triggering should be delayed |
59 |
float Level; |
float Level; |
|
bool ReleaseSignalReceived; |
|
60 |
stage_t Stage; |
stage_t Stage; |
61 |
float AttackCoeff; |
float AttackCoeff; |
62 |
long AttackStepsLeft; ///< number of sample points til end of attack stage |
long AttackStepsLeft; ///< number of sample points til end of attack stage |
63 |
|
bool HoldAttack; |
64 |
|
long LoopStart; |
65 |
|
float Decay1Coeff; |
66 |
|
long Decay1StepsLeft; ///< number of sample points in Decay1 stage |
67 |
|
float Decay2Coeff; |
68 |
|
bool InfiniteSustain; |
69 |
|
float SustainLevel; |
70 |
float ReleaseCoeff; |
float ReleaseCoeff; |
71 |
long ReleaseStepsLeft; ///< number of sample points til end of release stage |
long ReleaseStepsLeft; ///< number of sample points til end of release stage |
72 |
uint TriggerDelay; ///< number of sample points to triggering should be delayed |
bool ReleasePostponed; ///< If a "release" event occured in the previous audio fragment, but wasn't processed yet. |
|
uint ReleaseDelay; ///< number of sample points the release stage should be delayed |
|
73 |
|
|
74 |
inline long Min(long A, long B) { |
inline long Min(long A, long B) { |
75 |
return (A > B) ? B : A; |
return (A > B) ? B : A; |