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

Method trigger

src/Burst.cpp:106–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104 }
105
106 void trigger(int numBursts, int multDiv, float baseTimeWindow, float distribution, bool inhibitBurst, bool includeOriginalTrigger) {
107
108 active = true;
109 wasInhibited = inhibitBurst;
110
111 // the window in which the burst fits is a multiple (or division) of the base tempo
112 int divisions = multDiv + (multDiv > 0 ? 1 : multDiv < 0 ? -1 : 0); // skip 2/-2
113 float actualTimeWindow = baseTimeWindow;
114 if (divisions > 0) {
115 actualTimeWindow = baseTimeWindow * divisions;
116 }
117 else if (divisions < 0) {
118 actualTimeWindow = baseTimeWindow / (-divisions);
119 }
120
121 // calculate the times at which triggers should fire, will be skewed by distribution
122 const float power = 1 + std::abs(distribution) * 2;
123 for (int i = 0; i <= numBursts; ++i) {
124 if (distribution >= 0) {
125 timings[i] = actualTimeWindow * std::pow((float)i / numBursts, power);
126 }
127 else {
128 timings[i] = actualTimeWindow * std::pow((float)i / numBursts, 1 / power);
129 }
130 }
131
132 triggersOccurred = includeOriginalTrigger ? 0 : 1;
133 triggersRequested = inhibitBurst ? 1 : numBursts;
134 burstTimer.reset();
135 }
136};
137
138struct Burst : Module {

Callers 4

PingableClockMethod · 0.45
processMethod · 0.45
processMethod · 0.45
processMethod · 0.45

Calls 1

resetMethod · 0.45

Tested by

no test coverage detected