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

Function Engine_stepFrame

src/engine/Engine.cpp:428–473  ·  view source on GitHub ↗

Steps a single frame */

Source from the content-addressed store, hash-verified

426/** Steps a single frame
427*/
428static void Engine_stepFrame(Engine* that) {
429 Engine::Internal* internal = that->internal;
430
431 // Param smoothing
432 Module* smoothModule = internal->smoothModule;
433 if (smoothModule) {
434 int smoothParamId = internal->smoothParamId;
435 float smoothValue = internal->smoothValue;
436 Param* smoothParam = &smoothModule->params[smoothParamId];
437 float value = smoothParam->value;
438 // Use decay rate of roughly 1 graphics frame
439 const float smoothLambda = 60.f;
440 float newValue = value + (smoothValue - value) * smoothLambda * internal->sampleTime;
441 if (value == newValue) {
442 // Snap to actual smooth value if the value doesn't change enough (due to the granularity of floats)
443 smoothParam->setValue(smoothValue);
444 internal->smoothModule = NULL;
445 internal->smoothParamId = 0;
446 }
447 else {
448 smoothParam->setValue(newValue);
449 }
450 }
451
452 // Step modules along with workers
453 internal->workerModuleIndex = 0;
454 internal->engineBarrier.wait();
455 Engine_stepWorker(that, 0);
456 internal->workerBarrier.wait();
457
458 Engine_stepFrameCables(that);
459
460 // Flip messages for each module
461 for (Module* module : that->internal->modules) {
462 if (module->leftExpander.messageFlipRequested) {
463 std::swap(module->leftExpander.producerMessage, module->leftExpander.consumerMessage);
464 module->leftExpander.messageFlipRequested = false;
465 }
466 if (module->rightExpander.messageFlipRequested) {
467 std::swap(module->rightExpander.producerMessage, module->rightExpander.consumerMessage);
468 module->rightExpander.messageFlipRequested = false;
469 }
470 }
471
472 internal->frame++;
473}
474
475
476static void Engine_refreshParamHandleCache(Engine* that) {

Callers 1

stepBlockMethod · 0.85

Calls 4

Engine_stepWorkerFunction · 0.85
Engine_stepFrameCablesFunction · 0.85
setValueMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected