From 11721cab00e25b832bbb03bef79617f9035c68d0 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sat, 19 Dec 2020 04:11:27 -0500 Subject: [PATCH] Add WIP Engine::step() timer. Fix module timer. --- include/system.hpp | 4 ++-- src/app/ModuleWidget.cpp | 1 + src/engine/Engine.cpp | 8 +++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/system.hpp b/include/system.hpp index 7ad0d481..18cbb362 100644 --- a/include/system.hpp +++ b/include/system.hpp @@ -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. diff --git a/src/app/ModuleWidget.cpp b/src/app/ModuleWidget.cpp index 1e1674c0..26d8aefb 100644 --- a/src/app/ModuleWidget.cpp +++ b/src/app/ModuleWidget.cpp @@ -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(); } } diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index 9953b4cf..8cd4df3c 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -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); }