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

Method process

src/Muxlicer.cpp:114–163  ·  view source on GitHub ↗

returns the gated clock signal, returns true when high

Source from the content-addressed store, hash-verified

112
113 // returns the gated clock signal, returns true when high
114 bool process(float deltaTime, bool clockPulseReceived) {
115
116 if (clockPulseReceived) {
117 // update our record of the incoming clock spacing
118 if (secondsSinceLastClock > 0.0f) {
119 inputClockLengthSeconds = secondsSinceLastClock;
120 }
121 secondsSinceLastClock = 0.0f;
122 }
123
124 bool out = false;
125 if (secondsSinceLastClock >= 0.0f) {
126 secondsSinceLastClock += deltaTime;
127
128 // negative values are used for division (x 1/mult), positive for multiplication (x mult)
129 const int division = std::max(-multDiv, 1);
130 const int multiplication = std::max(multDiv, 1);
131
132 if (clockPulseReceived) {
133 if (dividerCount < 1) {
134 dividedProgressSeconds = 0.0f;
135 }
136 else {
137 dividedProgressSeconds += deltaTime;
138 }
139 ++dividerCount;
140 if (dividerCount >= division) {
141 dividerCount = 0;
142 }
143 }
144 else {
145 dividedProgressSeconds += deltaTime;
146 }
147
148 // lengths of the mult/div versions of the clock
149 const float dividedSeconds = inputClockLengthSeconds * (float) division;
150 const float multipliedSeconds = dividedSeconds / (float) multiplication;
151
152 // length of the output gate (s)
153 const float gateSeconds = std::max(0.001f, multipliedSeconds * 0.5f);
154
155 if (dividedProgressSeconds < dividedSeconds) {
156 float multipliedProgressSeconds = dividedProgressSeconds / multipliedSeconds;
157 multipliedProgressSeconds -= (float)(int)multipliedProgressSeconds;
158 multipliedProgressSeconds *= multipliedSeconds;
159 out = (multipliedProgressSeconds <= gateSeconds);
160 }
161 }
162 return out;
163 }
164
165 float getEffectiveClockLength() {
166 // negative values are used for division (x 1/mult), positive for multiplication (x mult)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected