From 6eaf11ed7a7c99594d02eaae38b289225e66a9ae Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Wed, 25 Jan 2023 19:39:53 -0500 Subject: [PATCH] Remove Engine::setFrame(). Guarantee that Engine frame only increases by 1 with no jumps. --- include/engine/Engine.hpp | 16 +++++----------- src/engine/Engine.cpp | 11 +++-------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/include/engine/Engine.hpp b/include/engine/Engine.hpp index 68aa3ada..88ecd417 100644 --- a/include/engine/Engine.hpp +++ b/include/engine/Engine.hpp @@ -63,29 +63,23 @@ struct Engine { Call this in your Module::stepBlock() method to hint that the operation will take more than ~0.1 ms. */ void yieldWorkers(); - /** Returns the number of stepBlock() calls since the Engine was created. - */ - int64_t getBlock(); - /** Returns the frame counter which increases every sample step. - Not necessarily monotonically increasing. Can be reset at any time. + /** Returns the number of sample frames since the Engine was created. */ int64_t getFrame(); - /** Sets the frame counter. - Useful for when the DAW playhead position jumps to a new position. - Rack plugins and standalone Rack should not call this function. + /** Returns the number of stepBlock() calls since the Engine was created. */ - void setFrame(int64_t frame); + int64_t getBlock(); /** Returns the frame when stepBlock() was last called. */ int64_t getBlockFrame(); /** Returns the time in seconds when stepBlock() was last called. */ double getBlockTime(); - /** Returns the total number of frames in the current stepBlock() call. + /** Returns the number of frames requested by the last stepBlock() call. */ int getBlockFrames(); /** Returns the total time that stepBlock() is advancing, in seconds. - Calculated by `stepFrames / sampleRate`. + Calculated by `blockFrames / sampleRate`. */ double getBlockDuration(); /** Returns the average block processing time divided by block time in the last T seconds. diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index 453a4a09..4790f26b 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -201,8 +201,8 @@ struct Engine::Internal { float sampleRate = 0.f; float sampleTime = 0.f; - int64_t block = 0; int64_t frame = 0; + int64_t block = 0; int64_t blockFrame = 0; double blockTime = 0.0; int blockFrames = 0; @@ -674,18 +674,13 @@ void Engine::yieldWorkers() { } -int64_t Engine::getBlock() { - return internal->block; -} - - int64_t Engine::getFrame() { return internal->frame; } -void Engine::setFrame(int64_t frame) { - internal->frame = frame; +int64_t Engine::getBlock() { + return internal->block; }