From 136b8ed74721957e9617885fe156e6b8657116bd Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 7 Sep 2010 23:26:21 +0000 Subject: [PATCH] Fix restore of fader automation from 2.X sessions. git-svn-id: svn://localhost/ardour2/branches/3.0@7754 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/automation_time_axis.cc | 29 ++++++++++++++++++++++++++--- gtk2_ardour/automation_time_axis.h | 3 +++ gtk2_ardour/route_time_axis.h | 2 +- gtk2_ardour/route_ui.cc | 15 +++++++++++---- gtk2_ardour/route_ui.h | 2 +- gtk2_ardour/time_axis_view.h | 2 +- libs/ardour/route.cc | 5 ++++- 7 files changed, 47 insertions(+), 11 deletions(-) diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc index 4a4045f823..b356ce7595 100644 --- a/gtk2_ardour/automation_time_axis.cc +++ b/gtk2_ardour/automation_time_axis.cc @@ -194,7 +194,8 @@ AutomationTimeAxisView::AutomationTimeAxisView (Session* s, boost::shared_ptrget_automation_child_xml_node ( - _control->parameter()); + _control->parameter(), Stateful::loading_state_version + ); if (xml_node) { set_state (*xml_node, Stateful::loading_state_version); @@ -403,7 +404,7 @@ AutomationTimeAxisView::set_height (uint32_t h) TimeAxisView* state_parent = get_parent_with_state (); assert(state_parent); - XMLNode* xml_node = state_parent->get_automation_child_xml_node (_control->parameter()); + XMLNode* xml_node = state_parent->get_automation_child_xml_node (_control->parameter(), Stateful::loading_state_version); TimeAxisView::set_height (h); _base_rect->property_y2() = h; @@ -950,6 +951,10 @@ AutomationTimeAxisView::set_state (const XMLNode& node, int version) { TimeAxisView::set_state (node, version); + if (version < 3000) { + return set_state_2X (node, version); + } + XMLProperty const * type = node.property ("automation-id"); if (type && type->value () == ARDOUR::EventTypeMap::instance().to_symbol (_control->parameter())) { XMLProperty const * shown = node.property ("shown"); @@ -966,13 +971,31 @@ AutomationTimeAxisView::set_state (const XMLNode& node, int version) return 0; } +int +AutomationTimeAxisView::set_state_2X (const XMLNode& node, int version) +{ + if (node.name() == X_("gain") && _control->parameter() == Evoral::Parameter (GainAutomation)) { + XMLProperty const * shown = node.property (X_("shown")); + if (shown && string_is_affirmative (shown->value ())) { + set_marked_for_display (true); + _canvas_display->show (); /* FIXME: necessary? show_at? */ + } + } + + if (!_marked_for_display) { + hide (); + } + + return 0; +} + XMLNode* AutomationTimeAxisView::get_state_node () { TimeAxisView* state_parent = get_parent_with_state (); if (state_parent) { - return state_parent->get_automation_child_xml_node (_control->parameter()); + return state_parent->get_automation_child_xml_node (_control->parameter(), Stateful::loading_state_version); } else { return 0; } diff --git a/gtk2_ardour/automation_time_axis.h b/gtk2_ardour/automation_time_axis.h index c4132269f1..55fcb14202 100644 --- a/gtk2_ardour/automation_time_axis.h +++ b/gtk2_ardour/automation_time_axis.h @@ -175,6 +175,9 @@ class AutomationTimeAxisView : public TimeAxisView { static Pango::FontDescription* name_font; static bool have_name_font; + +private: + int set_state_2X (const XMLNode &, int); }; #endif /* __ardour_gtk_automation_time_axis_h__ */ diff --git a/gtk2_ardour/route_time_axis.h b/gtk2_ardour/route_time_axis.h index 840b18ed14..90cc4aa48c 100644 --- a/gtk2_ardour/route_time_axis.h +++ b/gtk2_ardour/route_time_axis.h @@ -117,7 +117,7 @@ public: /* make sure we get the right version of this */ - XMLNode* get_automation_child_xml_node (Evoral::Parameter param) { return RouteUI::get_automation_child_xml_node (param); } + XMLNode* get_automation_child_xml_node (Evoral::Parameter param, int version) { return RouteUI::get_automation_child_xml_node (param, version); } typedef std::map > AutomationTracks; AutomationTracks automation_tracks() { return _automation_tracks; } diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 60d6f5f263..4222b40a93 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -1271,7 +1271,7 @@ RouteUI::ensure_xml_node () } XMLNode* -RouteUI::get_automation_child_xml_node (Evoral::Parameter param) +RouteUI::get_automation_child_xml_node (Evoral::Parameter param, int version) { ensure_xml_node (); @@ -1281,10 +1281,17 @@ RouteUI::get_automation_child_xml_node (Evoral::Parameter param) const string sym = ARDOUR::EventTypeMap::instance().to_symbol(param); for (iter = kids.begin(); iter != kids.end(); ++iter) { - if ((*iter)->name() == AutomationTimeAxisView::state_node_name) { - XMLProperty* type = (*iter)->property("automation-id"); - if (type && type->value() == sym) + + if (version < 3000) { + if ((*iter)->name() == sym) { return *iter; + } + } else { + if ((*iter)->name() == AutomationTimeAxisView::state_node_name) { + XMLProperty* type = (*iter)->property("automation-id"); + if (type && type->value() == sym) + return *iter; + } } } diff --git a/gtk2_ardour/route_ui.h b/gtk2_ardour/route_ui.h index 3ba0635fd7..952b39a433 100644 --- a/gtk2_ardour/route_ui.h +++ b/gtk2_ardour/route_ui.h @@ -111,7 +111,7 @@ class RouteUI : public virtual AxisView XMLNode *xml_node; void ensure_xml_node (); - virtual XMLNode* get_automation_child_xml_node (Evoral::Parameter param); + virtual XMLNode* get_automation_child_xml_node (Evoral::Parameter, int); bool mute_press(GdkEventButton*); bool mute_release(GdkEventButton*); diff --git a/gtk2_ardour/time_axis_view.h b/gtk2_ardour/time_axis_view.h index f8a30d5778..f01aa508ae 100644 --- a/gtk2_ardour/time_axis_view.h +++ b/gtk2_ardour/time_axis_view.h @@ -206,7 +206,7 @@ class TimeAxisView : public virtual AxisView, public PBD::Stateful /* call this on the parent */ - virtual XMLNode* get_automation_child_xml_node (Evoral::Parameter /*param*/) { return 0; } + virtual XMLNode* get_automation_child_xml_node (Evoral::Parameter, int) { return 0; } virtual LayerDisplay layer_display () const { return Overlaid; } virtual StreamView* view () const { return 0; } diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 4c3881f4e0..9369cf887b 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -2160,6 +2160,9 @@ Route::_set_state_2X (const XMLNode& node, int version) if (io_child->name() == X_("Panner")) { _main_outs->panner()->set_state(*io_child, version); + } else if (io_child->name() == X_("Automation")) { + /* IO's automation is for the fader */ + _amp->set_automation_state (*io_child, Evoral::Parameter (GainAutomation)); } } } @@ -2189,7 +2192,7 @@ Route::_set_state_2X (const XMLNode& node, int version) XMLNode *cmt = *(child->children().begin()); _comment = cmt->content(); - } else if (child->name() == X_("Extra")) { + } else if (child->name() == X_("extra")) { _extra_xml = new XMLNode (*child);