From b41bc2cf95af273467849a8ed0f2e4ee53749d05 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 29 Mar 2025 03:17:06 +0100 Subject: [PATCH] Outline RTA Manager API --- gtk2_ardour/ardour_ui_dependents.cc | 3 + gtk2_ardour/ardour_ui_ed.cc | 3 + gtk2_ardour/rta_manager.cc | 107 ++++++++++++++++++++++++++++ gtk2_ardour/rta_manager.h | 50 +++++++++++++ gtk2_ardour/wscript | 1 + 5 files changed, 164 insertions(+) create mode 100644 gtk2_ardour/rta_manager.cc create mode 100644 gtk2_ardour/rta_manager.h diff --git a/gtk2_ardour/ardour_ui_dependents.cc b/gtk2_ardour/ardour_ui_dependents.cc index 7f193c79d3..aa49ad736b 100644 --- a/gtk2_ardour/ardour_ui_dependents.cc +++ b/gtk2_ardour/ardour_ui_dependents.cc @@ -53,6 +53,7 @@ #include "keyboard.h" #include "keyeditor.h" #include "rc_option_editor.h" +#include "rta_manager.h" #include "route_params_ui.h" #include "trigger_ui.h" #include "step_entry.h" @@ -133,6 +134,8 @@ ARDOUR_UI::connect_dependents_to_session (ARDOUR::Session *s) trigger_page->set_session (s); meterbridge->set_session (s); + RTAManager::instance ()->set_session (s); + /* its safe to do this now */ BootMessage (_("Reload Session History")); diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index f09c0f7ad4..e6a34163eb 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -76,6 +76,7 @@ #include "location_ui.h" #include "main_clock.h" #include "rc_option_editor.h" +#include "rta_manager.h" #include "rta_window.h" #include "virtual_keyboard_window.h" @@ -1056,6 +1057,7 @@ ARDOUR_UI::save_ardour_state () vkstate.add_child_nocopy (virtual_keyboard_window.get_state ()); _session->add_instant_xml (vkstate); } + _session->add_instant_xml (RTAManager::instance()->get_state()); } /* save current Window settings and sizes for new sessions */ @@ -1079,6 +1081,7 @@ ARDOUR_UI::save_ardour_state () vkstate.add_child_nocopy (virtual_keyboard_window.get_state ()); Config->add_instant_xml (vkstate); } + Config->add_instant_xml (RTAManager::instance()->get_state()); } delete &enode; diff --git a/gtk2_ardour/rta_manager.cc b/gtk2_ardour/rta_manager.cc new file mode 100644 index 0000000000..51aab16fa9 --- /dev/null +++ b/gtk2_ardour/rta_manager.cc @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2025 Robin Gareus + * + * 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. + */ + +#ifdef WAF_BUILD +#include "gtk2ardour-config.h" +#endif + +#include "ardour/rt_safe_delete.h" +#include "ardour/session.h" + +#include "gui_thread.h" +#include "rta_manager.h" +#include "timers.h" +#include "ui_config.h" + +using namespace ARDOUR; + +RTAManager* RTAManager::_instance = 0; + +RTAManager* +RTAManager::instance () +{ + if (!_instance) { + _instance = new RTAManager; + } + return _instance; +} + +RTAManager::RTAManager () +{ +} + +RTAManager::~RTAManager () +{ +} + +XMLNode& +RTAManager::get_state () const +{ + XMLNode* node = new XMLNode ("RTAManager"); + return *node; +} + +void +RTAManager::set_session (ARDOUR::Session* s) +{ + if (!s) { + return; + } + SessionHandlePtr::set_session (s); + + if (_session->master_out ()) { + attach (_session->master_out ()); + } + _update_connection = Timers::super_rapid_connect (sigc::mem_fun (*this, &RTAManager::run_rta)); +} + +void +RTAManager::session_going_away () +{ + ENSURE_GUI_THREAD (*this, &RTAManager::session_going_away); + _update_connection.disconnect (); + + SessionHandlePtr::session_going_away (); + _session = 0; +} + +void +RTAManager::set_active (bool en) +{ +} + +void +RTAManager::attach (std::shared_ptr route) +{ +} + +void +RTAManager::remove (std::shared_ptr route) +{ +} + +bool +RTAManager::attached (std::shared_ptr route) const +{ + return false; +} + +void +RTAManager::run_rta () +{ +} diff --git a/gtk2_ardour/rta_manager.h b/gtk2_ardour/rta_manager.h new file mode 100644 index 0000000000..fe9950ccaf --- /dev/null +++ b/gtk2_ardour/rta_manager.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2025 Robin Gareus + * + * 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. + */ +#pragma once + +#include "ardour/ardour.h" +#include "ardour/dsp_filter.h" +#include "ardour/session_handle.h" +#include "ardour/types.h" + +class RTAManager + : public ARDOUR::SessionHandlePtr + , public PBD::ScopedConnectionList +{ +public: + static RTAManager* instance (); + ~RTAManager (); + + void set_session (ARDOUR::Session*); + XMLNode& get_state () const; + + void attach (std::shared_ptr); + void remove (std::shared_ptr); + bool attached (std::shared_ptr) const; + + void run_rta (); + void set_active (bool); + +private: + RTAManager (); + static RTAManager* _instance; + + void session_going_away (); + + sigc::connection _update_connection; +}; diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 334387b984..bdcb1995a4 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -268,6 +268,7 @@ gtk2_ardour_sources = [ 'route_processor_selection.cc', 'route_time_axis.cc', 'route_ui.cc', + 'rta_manager.cc', 'rta_window.cc', 'ruler_dialog.cc', 'save_as_dialog.cc',