From 6698f5f686bef82b0c9568558c83a3b9b3344700 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 1 Aug 2007 22:18:46 +0000 Subject: use XML state to store processors in mixer (strips) and fixup crash caused by missing AutomationController for integer LADSPA plugin params git-svn-id: svn://localhost/ardour2/trunk@2215 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour_ui.cc | 7 +- gtk2_ardour/ardour_ui.h | 1 + gtk2_ardour/ardour_ui2.cc | 6 +- gtk2_ardour/ardour_ui_dependents.cc | 2 + gtk2_ardour/ardour_ui_ed.cc | 1 - gtk2_ardour/ladspa_pluginui.cc | 5 +- gtk2_ardour/processor_box.cc | 115 ++++++++++++++++--------------- gtk2_ardour/processor_box.h | 3 +- gtk2_ardour/processor_selection.h | 43 +++++++++--- gtk2_ardour/route_processor_selection.cc | 62 +++-------------- gtk2_ardour/route_processor_selection.h | 7 +- gtk2_ardour/selection.cc | 57 +-------------- gtk2_ardour/selection.h | 7 -- libs/ardour/ardour/plugin.h | 10 ++- libs/ardour/automatable.cc | 3 - libs/ardour/plugin_insert.cc | 2 +- 16 files changed, 136 insertions(+), 195 deletions(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index b58990b0d6..cd0f412692 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -197,6 +197,11 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[]) keybindings_path = key_bindings_file.to_string(); + /* store all bindings changes in per-user file, no matter where they were loaded from */ + user_keybindings_path = user_config_directory().to_string (); + user_keybindings_path += '/'; + user_keybindings_path += "ardour.bindings"; + can_save_keybindings = false; last_configure_time.tv_sec = 0; @@ -2724,7 +2729,7 @@ void ARDOUR_UI::save_keybindings () { if (can_save_keybindings) { - AccelMap::save (keybindings_path); + AccelMap::save (user_keybindings_path); } } diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 42f0ae2143..39bd8db4a6 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -577,6 +577,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI void we_have_dependents (); std::string keybindings_path; + std::string user_keybindings_path; void setup_keybindings (); void setup_session_options (); diff --git a/gtk2_ardour/ardour_ui2.cc b/gtk2_ardour/ardour_ui2.cc index be7fbb5f09..5a4c676cad 100644 --- a/gtk2_ardour/ardour_ui2.cc +++ b/gtk2_ardour/ardour_ui2.cc @@ -835,7 +835,11 @@ void ARDOUR_UI::sync_option_changed () { if (session) { - session->request_slave_source (string_to_slave_source (sync_option_combo.get_active_text())); + ustring txt = sync_option_combo.get_active_text (); + if (txt.length()) { + cerr << "Changing to slave source based on " << txt << endl; + session->request_slave_source (string_to_slave_source (txt)); + } } } diff --git a/gtk2_ardour/ardour_ui_dependents.cc b/gtk2_ardour/ardour_ui_dependents.cc index 89abebf9cb..4e9f84d072 100644 --- a/gtk2_ardour/ardour_ui_dependents.cc +++ b/gtk2_ardour/ardour_ui_dependents.cc @@ -90,6 +90,8 @@ ARDOUR_UI::setup_keybindings () GtkAccelMap* accelmap = gtk_accel_map_get(); g_signal_connect (accelmap, "changed", (GCallback) accel_map_changed, this); + + } void diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index 6aedb3d8df..41665cffbb 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -80,7 +80,6 @@ ARDOUR_UI::install_actions () /* menus + submenus that need action items */ ActionManager::register_action (main_actions, X_("Session"), _("Session")); - ActionManager::register_action (main_actions, X_("Export"), _("Export")); ActionManager::register_action (main_actions, X_("Cleanup"), _("Cleanup")); ActionManager::register_action (main_actions, X_("Sync"), _("Sync")); ActionManager::register_action (main_actions, X_("Options"), _("Options")); diff --git a/gtk2_ardour/ladspa_pluginui.cc b/gtk2_ardour/ladspa_pluginui.cc index 7abee4fe23..ad1f8fbc7e 100644 --- a/gtk2_ardour/ladspa_pluginui.cc +++ b/gtk2_ardour/ladspa_pluginui.cc @@ -423,7 +423,11 @@ LadspaPluginUI::build_control_ui (guint32 port_index, boost::shared_ptrcontroller = AutomationController::create(insert, mcontrol->list(), mcontrol); + /* XXX this code is not right yet, because it doesn't handle the absence of bounds in any sensible fashion. */ @@ -456,7 +460,6 @@ LadspaPluginUI::build_control_ui (guint32 port_index, boost::shared_ptr pslot = sigc::bind (mem_fun(*this, &LadspaPluginUI::print_parameter), (uint32_t) port_index); - control_ui->controller = AutomationController::create(insert, mcontrol->list(), mcontrol); control_ui->controller->set_size_request (200, req.height); control_ui->controller->set_name (X_("PluginSlider")); control_ui->controller->set_style (BarController::LeftToRight); diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index 068a3896f3..fc264c661f 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -739,39 +739,38 @@ void ProcessorBox::cut_processors () { vector > to_be_removed; - + XMLNode* node = new XMLNode (X_("cut")); + get_selected_processors (to_be_removed); if (to_be_removed.empty()) { return; } - /* this essentially transfers ownership of the processor - of the processor from the route to the mixer - selection. - */ - - _rr_selection.set (to_be_removed); - no_processor_redisplay = true; for (vector >::iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) { - // Do not cut processors or sends + // Do not cut inserts or sends + if (boost::dynamic_pointer_cast((*i)) != 0) { void* gui = (*i)->get_gui (); if (gui) { static_cast(gui)->hide (); } - - if (_route->remove_processor (*i)) { - /* removal failed */ - _rr_selection.remove (*i); - } - } else { - _rr_selection.remove (*i); - } + + XMLNode& child ((*i)->get_state()); + if (_route->remove_processor (*i) == 0) { + /* success */ + node->add_child_nocopy (child); + } else { + delete &child; + } + } } + + _rr_selection.set (node); + no_processor_redisplay = false; redisplay_processors (); } @@ -780,7 +779,7 @@ void ProcessorBox::copy_processors () { vector > to_be_copied; - vector > copies; + XMLNode* node = new XMLNode (X_("copy")); get_selected_processors (to_be_copied); @@ -791,12 +790,11 @@ ProcessorBox::copy_processors () for (vector >::iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) { // Do not copy processors or sends if (boost::dynamic_pointer_cast((*i)) != 0) { - copies.push_back (Processor::clone (*i)); + node->add_child_nocopy ((*i)->get_state()); } } - _rr_selection.set (copies); - + _rr_selection.set (node); } void @@ -869,57 +867,64 @@ ProcessorBox::rename_processor (boost::shared_ptr processor) } void -ProcessorBox::cut_processor (boost::shared_ptr processor) +ProcessorBox::paste_processors () { - /* this essentially transfers ownership of the processor - of the processor from the route to the mixer - selection. - */ + if (_rr_selection.processors.empty()) { + return; + } - _rr_selection.add (processor); - - void* gui = processor->get_gui (); + cerr << "paste from node called " << _rr_selection.processors.get_node().name() << endl; - if (gui) { - static_cast(gui)->hide (); - } - - no_processor_redisplay = true; - if (_route->remove_processor (processor)) { - _rr_selection.remove (processor); - } - no_processor_redisplay = false; - redisplay_processors (); + paste_processor_state (_rr_selection.processors.get_node()); } void -ProcessorBox::copy_processor (boost::shared_ptr processor) +ProcessorBox::paste_processor_list (list >& processors) { - boost::shared_ptr copy = Processor::clone (processor); - _rr_selection.add (copy); -} + list > copies; + + for (list >::iterator i = processors.begin(); i != processors.end(); ++i) { + + boost::shared_ptr copy = Processor::clone (*i); + + copy->set_placement (_placement); + copies.push_back (copy); + } -void -ProcessorBox::paste_processors () -{ - if (_rr_selection.processors.empty()) { - return; - } + if (_route->add_processors (copies)) { - paste_processor_list (_rr_selection.processors); + string msg = _( + "Copying the set of processors on the clipboard failed,\n\ +probably because the I/O configuration of the plugins\n\ +could not match the configuration of this track."); + MessageDialog am (msg); + am.run (); + } } void -ProcessorBox::paste_processor_list (list >& processors) +ProcessorBox::paste_processor_state (const XMLNode& node) { + XMLNodeList nlist; + XMLNodeConstIterator niter; list > copies; - for (list >::iterator i = processors.begin(); i != processors.end(); ++i) { + nlist = node.children(); - boost::shared_ptr copy = Processor::clone (*i); + cerr << "Pasting processor selection containing " << nlist.size() << endl; - copy->set_placement (_placement); - copies.push_back (copy); + if (nlist.empty()) { + return; + } + + for (niter = nlist.begin(); niter != nlist.end(); ++niter) { + cerr << "try using " << (*niter)->name() << endl; + try { + copies.push_back (boost::shared_ptr (new PluginInsert (_session, **niter))); + } + catch (...) { + cerr << "plugin insert constructor failed\n"; + } } if (_route->add_processors (copies)) { diff --git a/gtk2_ardour/processor_box.h b/gtk2_ardour/processor_box.h index e4d0fca365..1ed0bcb39e 100644 --- a/gtk2_ardour/processor_box.h +++ b/gtk2_ardour/processor_box.h @@ -186,11 +186,10 @@ class ProcessorBox : public Gtk::HBox static Glib::RefPtr paste_action; void paste_processor_list (std::list >& processors); + void paste_processor_state (const XMLNode&); void activate_processor (boost::shared_ptr); void deactivate_processor (boost::shared_ptr); - void cut_processor (boost::shared_ptr); - void copy_processor (boost::shared_ptr); void edit_processor (boost::shared_ptr); void hide_processor_editor (boost::shared_ptr); void rename_processor (boost::shared_ptr); diff --git a/gtk2_ardour/processor_selection.h b/gtk2_ardour/processor_selection.h index e9abcea2dc..59354c05ac 100644 --- a/gtk2_ardour/processor_selection.h +++ b/gtk2_ardour/processor_selection.h @@ -20,13 +20,40 @@ #ifndef __ardour_gtk_processor_selection_h__ #define __ardour_gtk_processor_selection_h__ -#include -#include - -namespace ARDOUR { - class Processor; -} - -struct ProcessorSelection : list > {}; +#include + +class ProcessorSelection { + public: + ProcessorSelection() : node (0) {} + ~ProcessorSelection() { if (node) { delete node; } } + + void set (XMLNode* n) { + if (node) { + delete node; + } + node = n; + } + + void add (XMLNode* newchild) { + if (!node) { + node = new XMLNode ("add"); + } + node->add_child_nocopy (*newchild); + } + + void clear () { + if (node) { + delete node; + node = 0; + } + } + + bool empty () const { return node == 0 || node->children().empty(); } + + const XMLNode& get_node() const { return *node; } + + private: + XMLNode* node; +}; #endif /* __ardour_gtk_processor_selection_h__ */ diff --git a/gtk2_ardour/route_processor_selection.cc b/gtk2_ardour/route_processor_selection.cc index 33dd1bfe7b..552de1b412 100644 --- a/gtk2_ardour/route_processor_selection.cc +++ b/gtk2_ardour/route_processor_selection.cc @@ -46,8 +46,8 @@ RouteRedirectSelection::operator= (const RouteRedirectSelection& other) bool operator== (const RouteRedirectSelection& a, const RouteRedirectSelection& b) { - return a.processors == b.processors && - a.routes == b.routes; + // XXX MUST TEST PROCESSORS SOMEHOW + return a.routes == b.routes; } void @@ -72,63 +72,19 @@ RouteRedirectSelection::clear_routes () } void -RouteRedirectSelection::add (boost::shared_ptr r) +RouteRedirectSelection::add (XMLNode* node) { - if (find (processors.begin(), processors.end(), r) == processors.end()) { - processors.push_back (r); - - // XXX SHAREDPTR FIXME - // void (RouteRedirectSelection::*pmf)(Redirect*) = &RouteRedirectSelection::remove; - // r->GoingAway.connect (mem_fun(*this, pmf)); - - ProcessorsChanged(); - } -} - -void -RouteRedirectSelection::add (const vector >& rlist) -{ - bool changed = false; - - for (vector >::const_iterator i = rlist.begin(); i != rlist.end(); ++i) { - if (find (processors.begin(), processors.end(), *i) == processors.end()) { - processors.push_back (*i); - - // XXX SHAREDPTR FIXME - - //void (RouteRedirectSelection::*pmf)(Redirect*) = &RouteRedirectSelection::remove; - // (*i)->GoingAway.connect (mem_fun(*this, pmf)); - changed = true; - } - } - - if (changed) { - ProcessorsChanged(); - } + // XXX check for duplicate + processors.add (node); + ProcessorsChanged(); } void -RouteRedirectSelection::remove (boost::shared_ptr r) -{ - list >::iterator i; - if ((i = find (processors.begin(), processors.end(), r)) != processors.end()) { - processors.erase (i); - ProcessorsChanged (); - } -} - -void -RouteRedirectSelection::set (boost::shared_ptr r) +RouteRedirectSelection::set (XMLNode* node) { clear_processors (); - add (r); -} - -void -RouteRedirectSelection::set (const vector >& rlist) -{ - clear_processors (); - add (rlist); + processors.set (node); + ProcessorsChanged (); } void diff --git a/gtk2_ardour/route_processor_selection.h b/gtk2_ardour/route_processor_selection.h index 78f6ddca48..bb0e6701e1 100644 --- a/gtk2_ardour/route_processor_selection.h +++ b/gtk2_ardour/route_processor_selection.h @@ -42,11 +42,8 @@ class RouteRedirectSelection : public sigc::trackable void clear (); bool empty(); - void set (boost::shared_ptr); - void set (const std::vector >&); - void add (boost::shared_ptr); - void add (const std::vector >&); - void remove (boost::shared_ptr); + void set (XMLNode* node); + void add (XMLNode* node); void set (boost::shared_ptr); void add (boost::shared_ptr); diff --git a/gtk2_ardour/selection.cc b/gtk2_ardour/selection.cc index 43dd75df61..b9c44bea13 100644 --- a/gtk2_ardour/selection.cc +++ b/gtk2_ardour/selection.cc @@ -63,8 +63,7 @@ operator== (const Selection& a, const Selection& b) a.time.group == b.time.group && a.time == b.time && a.lines == b.lines && - a.playlists == b.playlists && - a.processors == b.processors; + a.playlists == b.playlists; } /** Clear everything from the Selection */ @@ -77,7 +76,6 @@ Selection::clear () clear_lines(); clear_time (); clear_playlists (); - clear_processors (); } void @@ -90,15 +88,6 @@ Selection::dump_region_layers() } -void -Selection::clear_processors () -{ - if (!processors.empty()) { - processors.clear (); - ProcessorsChanged (); - } -} - void Selection::clear_regions () { @@ -153,20 +142,6 @@ Selection::clear_lines () } } -void -Selection::toggle (boost::shared_ptr r) -{ - ProcessorSelection::iterator i; - - if ((i = find (processors.begin(), processors.end(), r)) == processors.end()) { - processors.push_back (r); - } else { - processors.erase (i); - } - ProcessorsChanged(); - -} - void Selection::toggle (boost::shared_ptr pl) { @@ -252,16 +227,6 @@ Selection::toggle (nframes_t start, nframes_t end) return next_time_id - 1; } - -void -Selection::add (boost::shared_ptr i) -{ - if (find (processors.begin(), processors.end(), i) == processors.end()) { - processors.push_back (i); - ProcessorsChanged(); - } -} - void Selection::add (boost::shared_ptr pl) { @@ -394,16 +359,6 @@ Selection::add (AutomationList* ac) } } -void -Selection::remove (boost::shared_ptr r) -{ - ProcessorSelection::iterator i; - if ((i = find (processors.begin(), processors.end(), r)) != processors.end()) { - processors.erase (i); - ProcessorsChanged (); - } -} - void Selection::remove (TimeAxisView* track) { @@ -509,13 +464,6 @@ Selection::remove (AutomationList *ac) } } -void -Selection::set (boost::shared_ptr i) -{ - clear_processors (); - add (i); -} - void Selection::set (TimeAxisView* track) { @@ -624,8 +572,7 @@ Selection::empty () playlists.empty () && lines.empty () && time.empty () && - playlists.empty () && - processors.empty () + playlists.empty () ; } diff --git a/gtk2_ardour/selection.h b/gtk2_ardour/selection.h index 4ffb2bb9b0..a8f298434a 100644 --- a/gtk2_ardour/selection.h +++ b/gtk2_ardour/selection.h @@ -69,7 +69,6 @@ class Selection : public sigc::trackable TimeSelection time; AutomationSelection lines; PlaylistSelection playlists; - ProcessorSelection processors; PointSelection points; Selection() { @@ -84,7 +83,6 @@ class Selection : public sigc::trackable sigc::signal TimeChanged; sigc::signal LinesChanged; sigc::signal PlaylistsChanged; - sigc::signal ProcessorsChanged; sigc::signal PointsChanged; void clear (); @@ -107,7 +105,6 @@ class Selection : public sigc::trackable void set (ARDOUR::AutomationList*); void set (boost::shared_ptr); void set (const std::list >&); - void set (boost::shared_ptr); void set (AutomationSelectable*); void toggle (TimeAxisView*); @@ -118,7 +115,6 @@ class Selection : public sigc::trackable void toggle (ARDOUR::AutomationList*); void toggle (boost::shared_ptr); void toggle (const std::list >&); - void toggle (boost::shared_ptr); void toggle (const std::vector&); void add (TimeAxisView*); @@ -129,7 +125,6 @@ class Selection : public sigc::trackable void add (ARDOUR::AutomationList*); void add (boost::shared_ptr); void add (const std::list >&); - void add (boost::shared_ptr); void remove (TimeAxisView*); void remove (const std::list&); @@ -139,7 +134,6 @@ class Selection : public sigc::trackable void remove (ARDOUR::AutomationList*); void remove (boost::shared_ptr); void remove (const std::list >&); - void remove (boost::shared_ptr); void remove (const list&); void replace (uint32_t time_index, nframes_t start, nframes_t end); @@ -149,7 +143,6 @@ class Selection : public sigc::trackable void clear_time(); void clear_lines (); void clear_playlists (); - void clear_processors (); void clear_points (); void foreach_region (void (ARDOUR::Region::*method)(void)); diff --git a/libs/ardour/ardour/plugin.h b/libs/ardour/ardour/plugin.h index d4a65672ee..830ed7c025 100644 --- a/libs/ardour/ardour/plugin.h +++ b/libs/ardour/ardour/plugin.h @@ -59,8 +59,14 @@ class PluginInfo { public: PluginInfo () { } PluginInfo (const PluginInfo &o) - : name(o.name), n_inputs(o.n_inputs), n_outputs(o.n_outputs), - path (o.path), unique_id(o.unique_id), index(o.index) {} + : name(o.name), + category (o.category), + creator (o.creator), + path (o.path), + n_inputs(o.n_inputs), + n_outputs(o.n_outputs), + unique_id(o.unique_id), + index(o.index) {} virtual ~PluginInfo () { } string name; diff --git a/libs/ardour/automatable.cc b/libs/ardour/automatable.cc index b942a086e7..0609b8d380 100644 --- a/libs/ardour/automatable.cc +++ b/libs/ardour/automatable.cc @@ -125,8 +125,6 @@ Automatable::add_control(boost::shared_ptr ac) _controls[param] = ac; - cerr << _name << ": added parameter " << param.to_string() << endl; - _can_automate_list.insert(param); // Sync everything (derived classes) up to initial values @@ -459,7 +457,6 @@ Automatable::control_factory(boost::shared_ptr list) // FIXME: this will die horribly if this is not a MidiTrack return boost::shared_ptr(new MidiTrack::MidiControl((MidiTrack*)this, list)); } else { - cerr << "WARNING: Default AutomationControl created for " << list->parameter().to_string() << endl; return boost::shared_ptr(new AutomationControl(_session, list)); } } diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index 58009e6b5a..81c615aa11 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -76,7 +76,7 @@ PluginInsert::PluginInsert (Session& s, const XMLNode& node) throw failed_constructor(); } - set_automatable (); + // set_automatable (); { Glib::Mutex::Lock em (_session.engine().process_lock()); -- cgit v1.2.3