MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / Module__doProcess

Function Module__doProcess

src/override/Engine.cpp:213–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211
212
213static void Module__doProcess(Module* const module, const Module::ProcessArgs& args) {
214 Module::Internal* const internal = module->internal;
215
216#ifndef HEADLESS
217 // This global setting can change while the function is running, so use a local variable.
218 bool meterEnabled = settings::cpuMeter && (args.frame % METER_DIVIDER == 0);
219
220 // Start CPU timer
221 double startTime;
222 if (meterEnabled) {
223 startTime = system::getTime();
224 }
225#endif
226
227 // Step module
228 if (!internal->bypassed)
229 module->process(args);
230 else
231 module->processBypass(args);
232
233#ifndef HEADLESS
234 // Stop CPU timer
235 if (meterEnabled) {
236 double endTime = system::getTime();
237 // Subtract call time of getTime() itself, since we only want to measure process() time.
238 double endTime2 = system::getTime();
239 float duration = (endTime - startTime) - (endTime2 - endTime);
240
241 internal->meterSamples++;
242 internal->meterDurationTotal += duration;
243
244 // Seconds we've been measuring
245 float meterTime = internal->meterSamples * METER_DIVIDER * args.sampleTime;
246
247 if (meterTime >= METER_TIME) {
248 // Push time to buffer
249 if (internal->meterSamples > 0) {
250 internal->meterIndex++;
251 internal->meterIndex %= METER_BUFFER_LEN;
252 internal->meterBuffer[internal->meterIndex] = internal->meterDurationTotal / internal->meterSamples;
253 }
254 // Reset total
255 internal->meterSamples = 0;
256 internal->meterDurationTotal = 0.f;
257 }
258 }
259
260 // Iterate ports to step plug lights
261 if (args.frame % PORT_DIVIDER == 0) {
262 float portTime = args.sampleTime * PORT_DIVIDER;
263 for (Input& input : module->inputs) {
264 Port_step(&input, portTime);
265 }
266 for (Output& output : module->outputs) {
267 Port_step(&output, portTime);
268 }
269 }
270#endif

Callers 1

Engine_stepFrameFunction · 0.85

Calls 2

Port_stepFunction · 0.85
processMethod · 0.45

Tested by

no test coverage detected