GUI: add audio load meter to statistics

This commit is contained in:
tildearrow 2022-05-03 02:29:12 -05:00
parent 3d541682e6
commit b8a2c90b61
4 changed files with 19 additions and 2 deletions

View file

@ -28,6 +28,5 @@
- store edit/followOrders/followPattern state in config - store edit/followOrders/followPattern state in config
- add ability to select a column by double clicking - add ability to select a column by double clicking
- add ability to move selection by dragging - add ability to move selection by dragging
- settings: OK/Cancel buttons should be always visible
- Apply button in settings - Apply button in settings
- find and replace - find and replace

View file

@ -26,6 +26,7 @@
#include "safeWriter.h" #include "safeWriter.h"
#include "../audio/taAudio.h" #include "../audio/taAudio.h"
#include "blip_buf.h" #include "blip_buf.h"
#include <atomic>
#include <functional> #include <functional>
#include <initializer_list> #include <initializer_list>
#include <thread> #include <thread>
@ -416,6 +417,7 @@ class DivEngine {
float oscSize; float oscSize;
int oscReadPos, oscWritePos; int oscReadPos, oscWritePos;
int tickMult; int tickMult;
std::atomic<size_t> processTime;
void runExportThread(); void runExportThread();
void nextBuf(float** in, float** out, int inChans, int outChans, unsigned int size); void nextBuf(float** in, float** out, int inChans, int outChans, unsigned int size);
@ -923,7 +925,8 @@ class DivEngine {
oscSize(1), oscSize(1),
oscReadPos(0), oscReadPos(0),
oscWritePos(0), oscWritePos(0),
tickMult(1) { tickMult(1),
processTime(0) {
memset(isMuted,0,DIV_MAX_CHANS*sizeof(bool)); memset(isMuted,0,DIV_MAX_CHANS*sizeof(bool));
memset(keyHit,0,DIV_MAX_CHANS*sizeof(bool)); memset(keyHit,0,DIV_MAX_CHANS*sizeof(bool));
memset(dispatchChanOfChan,0,DIV_MAX_CHANS*sizeof(int)); memset(dispatchChanOfChan,0,DIV_MAX_CHANS*sizeof(int));

View file

@ -17,6 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include <chrono>
#define _USE_MATH_DEFINES #define _USE_MATH_DEFINES
#include "dispatch.h" #include "dispatch.h"
#include "engine.h" #include "engine.h"
@ -1060,6 +1061,8 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
} }
got.bufsize=size; got.bufsize=size;
std::chrono::steady_clock::time_point ts_processBegin=std::chrono::steady_clock::now();
// process MIDI events (TODO: everything) // process MIDI events (TODO: everything)
if (output) if (output->midiIn) while (!output->midiIn->queue.empty()) { if (output) if (output->midiIn) while (!output->midiIn->queue.empty()) {
TAMidiMessage& msg=output->midiIn->queue.front(); TAMidiMessage& msg=output->midiIn->queue.front();
@ -1338,4 +1341,8 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
} }
} }
isBusy.unlock(); isBusy.unlock();
std::chrono::steady_clock::time_point ts_processEnd=std::chrono::steady_clock::now();
processTime=std::chrono::duration_cast<std::chrono::nanoseconds>(ts_processEnd-ts_processBegin).count();
} }

View file

@ -19,6 +19,7 @@
#include "gui.h" #include "gui.h"
#include <fmt/printf.h> #include <fmt/printf.h>
#include <imgui.h>
void FurnaceGUI::drawStats() { void FurnaceGUI::drawStats() {
if (nextWindow==GUI_WINDOW_STATS) { if (nextWindow==GUI_WINDOW_STATS) {
@ -28,6 +29,13 @@ void FurnaceGUI::drawStats() {
} }
if (!statsOpen) return; if (!statsOpen) return;
if (ImGui::Begin("Statistics",&statsOpen)) { if (ImGui::Begin("Statistics",&statsOpen)) {
size_t lastProcTime=e->processTime;
double maxGot=1000000000.0*(double)e->getAudioDescGot().bufsize/(double)e->getAudioDescGot().rate;
String procStr=fmt::sprintf("%.1f%%",100.0*((double)lastProcTime/(double)maxGot));
ImGui::Text("Audio load");
ImGui::SameLine();
ImGui::ProgressBar((double)lastProcTime/maxGot,ImVec2(-FLT_MIN,0),procStr.c_str());
ImGui::Separator();
for (int i=0; i<e->song.systemLen; i++) { for (int i=0; i<e->song.systemLen; i++) {
DivDispatch* dispatch=e->getDispatch(i); DivDispatch* dispatch=e->getDispatch(i);
for (int j=0; dispatch!=NULL && dispatch->getSampleMemCapacity(j)>0; j++) { for (int j=0; dispatch!=NULL && dispatch->getSampleMemCapacity(j)>0; j++) {