From 434bd2486ed457cafed13f15b51997936ad50c26 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 12 Jun 2021 09:20:58 -0600 Subject: [PATCH] start showing some DSP stats in the perf meter window Lots of work to be done to decide what data to show and how to best present it --- gtk2_ardour/dsp_stats_ui.cc | 88 ++++++++++++++++++++++++++++++--- gtk2_ardour/dsp_stats_ui.h | 3 +- gtk2_ardour/dsp_stats_window.cc | 10 ++++ gtk2_ardour/dsp_stats_window.h | 3 +- 4 files changed, 94 insertions(+), 10 deletions(-) diff --git a/gtk2_ardour/dsp_stats_ui.cc b/gtk2_ardour/dsp_stats_ui.cc index 6757f09e85..a8acd2e1c8 100644 --- a/gtk2_ardour/dsp_stats_ui.cc +++ b/gtk2_ardour/dsp_stats_ui.cc @@ -31,20 +31,40 @@ using namespace ARDOUR; using namespace Gtkmm2ext; using namespace Gtk; -DspStatisticsGUI::DspStatisticsGUI (Session* s) - : SessionHandlePtr (s) +DspStatisticsGUI::DspStatisticsGUI () + : buffer_size_label ("", ALIGN_RIGHT, ALIGN_CENTER) { const size_t nlabels = Session::NTT + AudioEngine::NTT + AudioBackend::NTT; labels = new Label*[nlabels]; for (size_t n = 0; n < nlabels; ++n) { labels[n] = new Label ("", ALIGN_RIGHT, ALIGN_CENTER); - set_size_request_to_display_given_text (*labels[n], string_compose (_("%1 [ms]"), 99.123), 0, 0); + set_size_request_to_display_given_text (*labels[n], string_compose (_("%1 (%2 - %3 .. %4 "), 10000, 1000, 10000, 1000), 0, 0); } - // attach (*manage (new Gtk::Label (_("Minimum"), ALIGN_RIGHT, ALIGN_CENTER)), - // 0, 1, 0, 1, Gtk::FILL, Gtk::SHRINK, 2, 0); - //attach (_lbl_min, 1, 2, 0, 1, Gtk::FILL, Gtk::SHRINK, 2, 0); + int row = 0; + + attach (*manage (new Gtk::Label (_("Buffer size: "), ALIGN_RIGHT, ALIGN_CENTER)), 0, 1, row, row+1, Gtk::FILL, Gtk::SHRINK, 2, 0); + attach (buffer_size_label, 1, 2, row, row+1, Gtk::FILL, Gtk::SHRINK, 2, 0); + row++; + + attach (*manage (new Gtk::Label (_("Device Wait: "), ALIGN_RIGHT, ALIGN_CENTER)), 0, 1, row, row+1, Gtk::FILL, Gtk::SHRINK, 2, 0); + attach (*labels[AudioEngine::NTT + Session::NTT + AudioBackend::DeviceWait], 1, 2, row, row+1, Gtk::FILL, Gtk::SHRINK, 2, 0); + row++; + + attach (*manage (new Gtk::Label (_("Backend process: "), ALIGN_RIGHT, ALIGN_CENTER)), 0, 1, row, row+1, Gtk::FILL, Gtk::SHRINK, 2, 0); + attach (*labels[AudioEngine::NTT + Session::NTT + AudioBackend::ProcessCallback], 1, 2, row, row+1, Gtk::FILL, Gtk::SHRINK, 2, 0); + row++; + + attach (*manage (new Gtk::Label (_("Engine: "), ALIGN_RIGHT, ALIGN_CENTER)), 0, 1, row, row+1, Gtk::FILL, Gtk::SHRINK, 2, 0); + attach (*labels[AudioEngine::ProcessCallback], 1, 2, row, row+1, Gtk::FILL, Gtk::SHRINK, 2, 0); + row++; + + attach (*manage (new Gtk::Label (_("Session: "), ALIGN_RIGHT, ALIGN_CENTER)), 0, 1, row, row+1, Gtk::FILL, Gtk::SHRINK, 2, 0); + attach (*labels[AudioEngine::NTT + Session::OverallProcess], 1, 2, row, row+1, Gtk::FILL, Gtk::SHRINK, 2, 0); + row++; + + show_all (); } void @@ -60,9 +80,61 @@ DspStatisticsGUI::stop_updating () update_connection.disconnect (); } - void DspStatisticsGUI::update () { -} + uint64_t min; + uint64_t max; + double avg; + double dev; + double minf; + double maxf; + char buf[64]; + int bufsize = AudioEngine::instance()->raw_buffer_size (DataType::AUDIO); + double bufsize_msecs = (bufsize * 1000.0) / AudioEngine::instance()->sample_rate(); + snprintf (buf, sizeof (buf), "%d samples / %5.2f msecs", bufsize, bufsize_msecs); + buffer_size_label.set_text (buf); + + AudioEngine::instance()->dsp_stats[AudioEngine::ProcessCallback].get_stats (min, max, avg, dev); + + minf = floor (min / 1000.0); + maxf = floor (max / 1000.0); + avg /= 1000.0; + dev /= 1000.0; + + snprintf (buf, sizeof (buf), "%7.2g msec %5.2g%% (%7.4g - %-7.2g .. %7.2g)", avg, (100.0 * avg) / bufsize_msecs, minf, maxf, dev); + labels[AudioEngine::ProcessCallback]->set_text (buf); + + AudioEngine::instance()->current_backend()->dsp_stats[AudioBackend::DeviceWait].get_stats (min, max, avg, dev); + + minf = floor (min / 1000.0); + maxf = floor (max / 1000.0); + avg /= 1000.0; + dev /= 1000.0; + + snprintf (buf, sizeof (buf), "%7.2g msec %5.2g%% (%7.4g - %-7.2g .. %7.2g)", avg, (100.0 * avg) / bufsize_msecs, minf, maxf, dev); + labels[AudioEngine::NTT + Session::NTT + AudioBackend::DeviceWait]->set_text (buf); + + AudioEngine::instance()->current_backend()->dsp_stats[AudioBackend::ProcessCallback].get_stats (min, max, avg, dev); + + minf = floor (min / 1000.0); + maxf = floor (max / 1000.0); + avg /= 1000.0; + dev /= 1000.0; + + snprintf (buf, sizeof (buf), "%7.2g msec %5.2g%% (%7.4g - %-7.2g .. %7.2g)", avg, (100.0 * avg) / bufsize_msecs, minf, maxf, dev); + labels[AudioEngine::NTT + Session::NTT + AudioBackend::ProcessCallback]->set_text (buf); + + if (_session) { + _session->dsp_stats[AudioEngine::ProcessCallback].get_stats (min, max, avg, dev); + + min = (uint64_t) floor (min / 1000.0); + max = (uint64_t) floor (max / 1000.0); + avg /= 1000.0; + dev /= 1000.0; + + snprintf (buf, sizeof (buf), "%7.2g msec %5.2g%% (%7.4g - %-7.2g .. %7.2g)", avg, (100.0 * avg) / bufsize_msecs, minf, maxf, dev); + labels[AudioEngine::NTT + Session::OverallProcess]->set_text (buf); + } +} diff --git a/gtk2_ardour/dsp_stats_ui.h b/gtk2_ardour/dsp_stats_ui.h index 8fdf9b901e..c90c34f1a3 100644 --- a/gtk2_ardour/dsp_stats_ui.h +++ b/gtk2_ardour/dsp_stats_ui.h @@ -28,7 +28,7 @@ class DspStatisticsGUI : public Gtk::Table, public ARDOUR::SessionHandlePtr { public: - DspStatisticsGUI (ARDOUR::Session* s); + DspStatisticsGUI (); void start_updating (); void stop_updating (); @@ -38,6 +38,7 @@ private: sigc::connection update_connection; + Gtk::Label buffer_size_label; Gtk::Label** labels; }; diff --git a/gtk2_ardour/dsp_stats_window.cc b/gtk2_ardour/dsp_stats_window.cc index 1ffa938b38..81cdd82310 100644 --- a/gtk2_ardour/dsp_stats_window.cc +++ b/gtk2_ardour/dsp_stats_window.cc @@ -16,6 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "dsp_stats_ui.h" #include "dsp_stats_window.h" #include "pbd/i18n.h" @@ -26,24 +27,33 @@ using namespace Gtk; DspStatisticsWindow::DspStatisticsWindow() : ArdourWindow (_("Performance Meters")) + , ui (new DspStatisticsGUI) { + ui->show (); + add (*ui); } DspStatisticsWindow::~DspStatisticsWindow () { + delete ui; } void DspStatisticsWindow::set_session (Session* s) { + ui->set_session (s); } void DspStatisticsWindow::on_show () { + ArdourWindow::on_show (); + ui->start_updating (); } void DspStatisticsWindow::on_hide () { + ArdourWindow::on_hide (); + ui->stop_updating (); } diff --git a/gtk2_ardour/dsp_stats_window.h b/gtk2_ardour/dsp_stats_window.h index 1da2c0884c..a94bcc503c 100644 --- a/gtk2_ardour/dsp_stats_window.h +++ b/gtk2_ardour/dsp_stats_window.h @@ -22,7 +22,7 @@ #include "ardour_window.h" -class PluginLoadStatsGui; +class DspStatisticsGUI; class DspStatisticsWindow : public ArdourWindow { @@ -38,6 +38,7 @@ protected: void on_hide (); private: + DspStatisticsGUI* ui; }; #endif