MCPcopy Create free account
hub / github.com/VCVRack/Befaco / processTransitionsTriggerMode

Method processTransitionsTriggerMode

src/ADSR.cpp:79–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77 }
78
79 void processTransitionsTriggerMode(const bool& gateHeld) {
80
81 // calculate stage transitions
82 switch (stage) {
83 case STAGE_ATTACK: {
84 if (env >= 1.f) {
85 timeInCurrentStage = 0.f;
86 if (gateHeld) {
87 stage = STAGE_DECAY;
88 }
89 else {
90 stage = STAGE_RELEASE;
91 releaseValue = 1.f;
92 }
93 }
94 break;
95 }
96 case STAGE_DECAY: {
97 if (timeInCurrentStage >= decayTime) {
98 timeInCurrentStage = 0.f;
99 if (gateHeld) {
100 stage = STAGE_SUSTAIN;
101 }
102 else {
103 stage = STAGE_RELEASE;
104 releaseValue = env;
105 }
106 }
107 break;
108 }
109 case STAGE_OFF:
110 case STAGE_RELEASE:
111 case STAGE_SUSTAIN: {
112 break;
113 }
114 }
115
116 if (!gateHeld) {
117 if (stage == STAGE_DECAY || stage == STAGE_SUSTAIN) {
118 timeInCurrentStage = 0.f;
119 stage = STAGE_RELEASE;
120 releaseValue = env;
121 }
122 else if (stage == STAGE_RELEASE) {
123 if (timeInCurrentStage >= releaseTime) {
124 stage = STAGE_OFF;
125 timeInCurrentStage = 0.f;
126 }
127 }
128 }
129 }
130
131 void evolveEnvelope(const float& sampleTime) {
132 switch (stage) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected