Browse Source

Add WIP Engine::step() timer. Fix module timer.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
11721cab00
3 changed files with 10 additions and 3 deletions
  1. +2
    -2
      include/system.hpp
  2. +1
    -0
      src/app/ModuleWidget.cpp
  3. +7
    -1
      src/engine/Engine.cpp

+ 2
- 2
include/system.hpp View File

@@ -106,10 +106,10 @@ Examples:
std::string getExtension(const std::string& path);

/** Compresses the contents of a folder (recursively) to an archive.
Currently supports the "ustar zstd" format (.tar.zst)
Uses the Unix Standard TAR + Zstandard format (.tar.zst).
An equivalent shell command is

tar -cf archivePath --zstd -C folderPath .
ZSTD_CLEVEL=1 tar -cf archivePath --zstd -C folderPath .
*/
void archiveFolder(const std::string& archivePath, const std::string& folderPath, int compressionLevel = 1);
/** Extracts an archive into a folder.


+ 1
- 0
src/app/ModuleWidget.cpp View File

@@ -505,6 +505,7 @@ void ModuleWidget::onHoverKey(const event::HoverKey& e) {
void ModuleWidget::onDragStart(const event::DragStart& e) {
if (e.button == GLFW_MOUSE_BUTTON_LEFT) {
internal->dragPos = APP->scene->rack->mousePos.minus(box.pos);
DEBUG("drag (%f, %f)", VEC_ARGS(internal->dragPos));
APP->scene->rack->updateModuleOldPositions();
}
}


+ 7
- 1
src/engine/Engine.cpp View File

@@ -352,7 +352,7 @@ static void Engine_stepModulesWorker(Engine* that, int threadId) {
// Stop CPU timer
if (cpuMeter) {
double endTime = system::getTime();
float duration = (endTime - startTime) / 1e9;
float duration = endTime - startTime;

// Smooth CPU time
const float cpuTau = 2.f /* seconds */;
@@ -571,6 +571,7 @@ void Engine::step(int frames) {
if (internal->sampleRate != settings::sampleRate) {
internal->sampleRate = settings::sampleRate;
internal->sampleTime = 1.f / internal->sampleRate;
// Trigger SampleRateChangeEvent
Module::SampleRateChangeEvent e;
e.sampleRate = internal->sampleRate;
e.sampleTime = internal->sampleTime;
@@ -594,6 +595,11 @@ void Engine::step(int frames) {
}

yieldWorkers();

double endTime = system::getTime();
float duration = endTime - internal->stepTime;
float stepDuration = internal->stepFrames * internal->sampleTime;
DEBUG("%d %f / %f = %f%%", internal->stepFrames, duration, stepDuration, duration / stepDuration * 100.f);
}




Loading…
Cancel
Save