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

Method processTransitionsGateMode

src/ADSR.cpp:30–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28 }
29
30 void processTransitionsGateMode(const bool& gateHeld) {
31 if (gateHeld) {
32 // calculate stage transitions
33 switch (stage) {
34 case STAGE_OFF: {
35 env = 0.0f;
36 timeInCurrentStage = 0.f;
37 stage = STAGE_ATTACK;
38 break;
39 }
40 case STAGE_ATTACK: {
41 if (env >= 1.f) {
42 timeInCurrentStage = 0.f;
43 stage = STAGE_DECAY;
44 }
45 break;
46 }
47 case STAGE_DECAY: {
48 if (timeInCurrentStage >= decayTime) {
49 timeInCurrentStage = 0.f;
50 stage = STAGE_SUSTAIN;
51 }
52 break;
53 }
54 case STAGE_SUSTAIN: {
55 break;
56 }
57 case STAGE_RELEASE: {
58 stage = STAGE_ATTACK;
59 timeInCurrentStage = attackTime * env;
60 break;
61 }
62 }
63 }
64 else {
65 if (stage == STAGE_ATTACK || stage == STAGE_DECAY || stage == STAGE_SUSTAIN) {
66 timeInCurrentStage = 0.f;
67 stage = STAGE_RELEASE;
68 releaseValue = env;
69 }
70 else if (stage == STAGE_RELEASE) {
71 if (timeInCurrentStage >= releaseTime) {
72 stage = STAGE_OFF;
73 timeInCurrentStage = 0.f;
74 }
75 }
76 }
77 }
78
79 void processTransitionsTriggerMode(const bool& gateHeld) {
80

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected