Add a window that shows DSP usage of all plugins

Currently hidden, use
  Editor:access_action("Window", "toggle-plugin-dsp-load")
This commit is contained in:
Robin Gareus 2018-09-25 00:12:42 +02:00
parent f7b93ee7b9
commit d71dfdfd6a
7 changed files with 213 additions and 0 deletions

View file

@ -167,6 +167,7 @@ typedef uint64_t microseconds_t;
#include "nsm.h"
#include "opts.h"
#include "pingback.h"
#include "plugin_dspload_window.h"
#include "processor_box.h"
#include "public_editor.h"
#include "rc_option_editor.h"
@ -316,6 +317,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
, export_video_dialog (X_("video-export"), _("Video Export Dialog"))
, lua_script_window (X_("script-manager"), _("Script Manager"))
, idleometer (X_("idle-o-meter"), _("Idle'o'Meter"))
, plugin_dsp_load_window (X_("plugin-dsp-load"), _("Plugin DSP Load"))
, transport_masters_window (X_("transport-masters"), _("Transport Masters"))
, session_option_editor (X_("session-options-editor"), _("Properties"), boost::bind (&ARDOUR_UI::create_session_option_editor, this))
, add_video_dialog (X_("add-video"), _("Add Video"), boost::bind (&ARDOUR_UI::create_add_video_dialog, this))
@ -476,6 +478,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
export_video_dialog.set_state (*ui_xml, 0);
lua_script_window.set_state (*ui_xml, 0);
idleometer.set_state (*ui_xml, 0);
plugin_dsp_load_window.set_state (*ui_xml, 0);
transport_masters_window.set_state (*ui_xml, 0);
}
@ -498,6 +501,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
WM::Manager::instance().register_window (&audio_port_matrix);
WM::Manager::instance().register_window (&midi_port_matrix);
WM::Manager::instance().register_window (&idleometer);
WM::Manager::instance().register_window (&plugin_dsp_load_window);
WM::Manager::instance().register_window (&transport_masters_window);
/* do not retain position for add route dialog */

View file

@ -96,6 +96,7 @@
#include "keyeditor.h"
#include "location_ui.h"
#include "lua_script_manager.h"
#include "plugin_dspload_window.h"
#include "rc_option_editor.h"
#include "route_dialogs.h"
#include "route_params_ui.h"
@ -120,6 +121,7 @@ class SessionOptionEditor;
class SpeakerDialog;
class GlobalPortMatrixWindow;
class IdleOMeter;
class PluginDSPLoadWindow;
class TransportMastersWindow;
#endif
@ -682,6 +684,7 @@ private:
WM::Proxy<ExportVideoDialog> export_video_dialog;
WM::Proxy<LuaScriptManager> lua_script_window;
WM::Proxy<IdleOMeter> idleometer;
WM::Proxy<PluginDSPLoadWindow> plugin_dsp_load_window;
WM::Proxy<TransportMastersWindow> transport_masters_window;
/* Windows/Dialogs that require a creator method */

View file

@ -61,6 +61,7 @@
#include "midi_tracer.h"
#include "mini_timeline.h"
#include "mixer_ui.h"
#include "plugin_dspload_window.h"
#include "public_editor.h"
#include "processor_box.h"
#include "rc_option_editor.h"
@ -128,6 +129,7 @@ ARDOUR_UI::set_session (Session *s)
big_clock->set_session (s);
video_timeline->set_session (s);
lua_script_window->set_session (s);
plugin_dsp_load_window->set_session (s);
transport_masters_window->set_session (s);
rc_option_editor->set_session (s);

View file

@ -41,6 +41,7 @@ PluginLoadStatsGui::PluginLoadStatsGui (boost::shared_ptr<ARDOUR::PluginInsert>
_reset_button.signal_clicked.connect (sigc::mem_fun (*this, &PluginLoadStatsGui::clear_stats));
_darea.signal_expose_event ().connect (sigc::mem_fun (*this, &PluginLoadStatsGui::draw_bar));
set_size_request_to_display_given_text (_lbl_dev, string_compose (_("%1 [ms]"), 99.123), 0, 0);
_darea.set_size_request (360, 32); // TODO max (320, 360 * UIConfiguration::instance().get_ui_scale ())
attach (*manage (new Gtk::Label (_("Minimum"), ALIGN_RIGHT, ALIGN_CENTER)),
0, 1, 0, 1, Gtk::FILL, Gtk::SHRINK, 2, 0);

View file

@ -0,0 +1,139 @@
/*
* Copyright (C) 2018 Robin Gareus <robin@gareus.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <gtkmm/frame.h>
#include <gtkmm/label.h>
#include <gtkmm/viewport.h>
#include "ardour/session.h"
#include "gtkmm2ext/gui_thread.h"
#include "plugin_dspload_ui.h"
#include "plugin_dspload_window.h"
#include "pbd/i18n.h"
using namespace ARDOUR;
PluginDSPLoadWindow::PluginDSPLoadWindow ()
: ArdourWindow (_("Plugin DSP Load"))
{
_scroller.set_border_width (0);
_scroller.set_shadow_type (Gtk::SHADOW_NONE);
_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
_scroller.add (_box);
add (_scroller);
_box.show ();
_scroller.show ();
Gtk::Viewport* viewport = (Gtk::Viewport*) _scroller.get_child();
viewport->set_shadow_type(Gtk::SHADOW_NONE);
viewport->set_border_width(0);
}
PluginDSPLoadWindow::~PluginDSPLoadWindow ()
{
drop_references ();
}
void
PluginDSPLoadWindow::set_session (Session* s)
{
ArdourWindow::set_session (s);
if (!s) {
drop_references ();
}
}
void
PluginDSPLoadWindow::session_going_away ()
{
ENSURE_GUI_THREAD (*this, &PluginDSPLoadWindow::session_going_away);
ArdourWindow::session_going_away ();
drop_references ();
}
void
PluginDSPLoadWindow::on_show ()
{
ArdourWindow::on_show ();
refill_processors ();
}
void
PluginDSPLoadWindow::on_hide ()
{
ArdourWindow::on_hide ();
drop_references ();
}
void
PluginDSPLoadWindow::drop_references ()
{
std::list<Gtk::Widget*> children = _box.get_children ();
for (std::list<Gtk::Widget*>::iterator child = children.begin(); child != children.end(); ++child) {
(*child)->hide ();
_box.remove (**child);
delete *child;
}
}
void
PluginDSPLoadWindow::refill_processors ()
{
drop_references ();
RouteList routes = _session->get_routelist ();
for (RouteList::const_iterator i = routes.begin(); i != routes.end(); ++i) {
(*i)->foreach_processor (sigc::bind (sigc::mem_fun (*this, &PluginDSPLoadWindow::add_processor_to_display), (*i)->name()));
(*i)->processors_changed.connect (
_route_connections, invalidator (*this), boost::bind (&PluginDSPLoadWindow::refill_processors, this), gui_context()
);
(*i)->DropReferences.connect (
_route_connections, invalidator (*this), boost::bind (&PluginDSPLoadWindow::drop_references, this), gui_context()
);
}
if (_box.get_children().size() == 0) {
_box.add (*Gtk::manage (new Gtk::Label (_("No Plugins"))));
_box.show_all ();
}
}
void
PluginDSPLoadWindow::add_processor_to_display (boost::weak_ptr<Processor> w, std::string const& route_name)
{
boost::shared_ptr<Processor> p = w.lock ();
boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (p);
if (!pi) {
return;
}
p->DropReferences.connect (_processor_connections, MISSING_INVALIDATOR, boost::bind (&PluginDSPLoadWindow::drop_references, this), gui_context());
PluginLoadStatsGui* plsg = new PluginLoadStatsGui (pi);
std::string name = route_name + " - " + pi->name();
Gtk::Frame* frame = new Gtk::Frame (name.c_str());
frame->add (*Gtk::manage (plsg));
_box.pack_start (*frame, Gtk::PACK_SHRINK, 2);
plsg->start_updating ();
frame->show_all ();
}

View file

@ -0,0 +1,63 @@
/*
* Copyright (C) 2018 Robin Gareus <robin@gareus.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __ardour_plugin_dspload_window_h__
#define __ardour_plugin_dspload_window_h__
#include <boost/weak_ptr.hpp>
#include <gtkmm/box.h>
#include <gtkmm/scrolledwindow.h>
#include "pbd/signals.h"
#include "ardour_window.h"
namespace ARDOUR {
class Processor;
}
class PluginLoadStatsGui;
class PluginDSPLoadWindow : public ArdourWindow
{
public:
PluginDSPLoadWindow ();
~PluginDSPLoadWindow ();
void set_session (ARDOUR::Session*);
protected:
void session_going_away();
void on_show ();
void on_hide ();
private:
void refill_processors ();
void drop_references ();
void add_processor_to_display (boost::weak_ptr<ARDOUR::Processor>, std::string const&);
Gtk::ScrolledWindow _scroller;
Gtk::VBox _box;
PBD::ScopedConnectionList _processor_connections;
PBD::ScopedConnectionList _route_connections;
};
#endif

View file

@ -190,6 +190,7 @@ gtk2_ardour_sources = [
'plugin_selector.cc',
'plugin_ui.cc',
'plugin_dspload_ui.cc',
'plugin_dspload_window.cc',
'port_group.cc',
'port_insert_ui.cc',
'port_matrix.cc',