Update names of sidechains.
authorJohannes Mueller <github@johannes-mueller.org>
Sat, 27 Oct 2018 19:36:21 +0000 (21:36 +0200)
committerJohannes Mueller <github@johannes-mueller.org>
Thu, 1 Nov 2018 17:53:27 +0000 (18:53 +0100)
When a PluginInsert is created it does not have an owner right away. That's why
a we need to set the sidechains name once the owner is known, in order to
include owner's name into the name.

Furthermore we need to follow renames of the owner.

libs/ardour/ardour/plugin_insert.h
libs/ardour/plugin_insert.cc
libs/ardour/route.cc

index 70297f11b2834e3126977ffce8c3556e3a499158..a68110177fa2f50aaafb7efe9ecf95397400fd20 100644 (file)
@@ -170,6 +170,7 @@ public:
        bool set_preset_out (const ChanCount&);
        bool add_sidechain  (uint32_t n_audio = 1, uint32_t n_midi = 0);
        bool del_sidechain ();
+       void update_sidechain_name ();
        boost::shared_ptr<SideChain> sidechain () const { return _sidechain; }
        // end C++ class slavery!
 
index d5056e725990b996befa4e8ae2ae491675561b10..4fc97fb0c816ab0bcafaa9d7de0b82cead81b708 100644 (file)
@@ -206,10 +206,12 @@ PluginInsert::add_sidechain (uint32_t n_audio, uint32_t n_midi)
                return false;
        }
        std::ostringstream n;
-       if (n_audio > 0 || n_midi > 0) {
-               n << "Sidechain " << Session::next_name_id ();
-       } else {
+       if (n_audio == 0 && n_midi == 0) {
                n << "TO BE RESET FROM XML";
+       } else if (owner()) {
+               n << "SC " << owner()->name() << "/" << name() << " " << Session::next_name_id ();
+       } else {
+               n << "tobeRenamed";
        }
        SideChain *sc = new SideChain (_session, n.str ());
        _sidechain = boost::shared_ptr<SideChain> (sc);
@@ -237,6 +239,25 @@ PluginInsert::del_sidechain ()
        return true;
 }
 
+void
+PluginInsert::update_sidechain_name ()
+{
+       if (!_sidechain) {
+               return;
+       }
+
+       std::ostringstream n;
+
+       n << "SC ";
+       if (owner()) {
+               n << owner()->name() << "/";
+       }
+
+       n << name() << " " << Session::next_name_id ();
+
+       _sidechain->set_name (n.str());
+}
+
 void
 PluginInsert::control_list_automation_state_changed (Evoral::Parameter which, AutoState s)
 {
index 41a14b096e5127835941a95c26f18c88b4ecc14a..70c79a061c023ede61808c540fa0ad3c37f60991 100644 (file)
@@ -849,6 +849,11 @@ Route::add_processor (boost::shared_ptr<Processor> processor, boost::shared_ptr<
                processor->activate ();
        }
 
+       boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (processor);
+       if (pi) {
+               pi->update_sidechain_name ();
+       }
+
        return 0;
 }
 
@@ -4269,6 +4274,14 @@ Route::set_name (const string& str)
 
        SessionObject::set_name (newname);
 
+       for (uint32_t n = 0 ; ; ++n) {
+               boost::shared_ptr<PluginInsert> pi = boost::static_pointer_cast<PluginInsert> (nth_plugin (n));
+               if (!pi) {
+                       break;
+               }
+               pi->update_sidechain_name ();
+       }
+
        bool ret = (_input->set_name(newname) && _output->set_name(newname));
 
        if (ret) {