MCPcopy Create free account
hub / github.com/VCVRack/Rack / doProcess

Method doProcess

src/engine/Module.cpp:333–385  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

331
332
333void Module::doProcess(const ProcessArgs& args) {
334 // This global setting can change while the function is running, so use a local variable.
335 bool meterEnabled = settings::cpuMeter && (args.frame % METER_DIVIDER == 0);
336
337 // Start CPU timer
338 double startTime;
339 if (meterEnabled) {
340 startTime = system::getTime();
341 }
342
343 // Step module
344 if (!internal->bypassed)
345 process(args);
346 else
347 processBypass(args);
348
349 // Stop CPU timer
350 if (meterEnabled) {
351 double endTime = system::getTime();
352 // Subtract call time of getTime() itself, since we only want to measure process() time.
353 double endTime2 = system::getTime();
354 float duration = (endTime - startTime) - (endTime2 - endTime);
355
356 internal->meterSamples++;
357 internal->meterDurationTotal += duration;
358
359 // Seconds we've been measuring
360 float meterTime = internal->meterSamples * METER_DIVIDER * args.sampleTime;
361
362 if (meterTime >= METER_TIME) {
363 // Push time to buffer
364 if (internal->meterSamples > 0) {
365 internal->meterIndex++;
366 internal->meterIndex %= METER_BUFFER_LEN;
367 internal->meterBuffer[internal->meterIndex] = internal->meterDurationTotal / internal->meterSamples;
368 }
369 // Reset total
370 internal->meterSamples = 0;
371 internal->meterDurationTotal = 0.f;
372 }
373 }
374
375 // Iterate ports to step plug lights
376 if (args.frame % PORT_DIVIDER == 0) {
377 float portTime = args.sampleTime * PORT_DIVIDER;
378 for (Input& input : inputs) {
379 Port_step(&input, portTime);
380 }
381 for (Output& output : outputs) {
382 Port_step(&output, portTime);
383 }
384 }
385}
386
387
388void Module::jsonStripIds(json_t* rootJ) {

Callers 1

Engine_stepWorkerFunction · 0.80

Calls 2

getTimeFunction · 0.85
Port_stepFunction · 0.85

Tested by

no test coverage detected