diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2006-10-31 18:08:16 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2006-10-31 18:08:16 +0000 |
commit | 1987df571c861e89fa96dd1622bdc9908d0d768d (patch) | |
tree | 4b84b575c35d9fec0e67f47b7c0b0d80808313c5 /libs/ardour/redirect.cc | |
parent | 8856a12bb89d78461b3d9ae384e9efc1bc64e4d6 (diff) |
support for old-school automation loading
git-svn-id: svn://localhost/ardour2/trunk@1039 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/redirect.cc')
-rw-r--r-- | libs/ardour/redirect.cc | 78 |
1 files changed, 77 insertions, 1 deletions
diff --git a/libs/ardour/redirect.cc b/libs/ardour/redirect.cc index 5623e5d510..0f3e9adce3 100644 --- a/libs/ardour/redirect.cc +++ b/libs/ardour/redirect.cc @@ -244,10 +244,11 @@ Redirect::set_state (const XMLNode& node) } else if ((*niter)->name() == X_("Automation")) { + XMLProperty *prop; if ((prop = (*niter)->property ("path")) != 0) { - warning << string_compose (_("old automation data found for %1, ignored"), _name) << endmsg; + old_set_automation_state (*(*niter)); } else { set_automation_state (*(*niter)); } @@ -298,6 +299,81 @@ Redirect::set_state (const XMLNode& node) return 0; } +int +Redirect::old_set_automation_state (const XMLNode& node) +{ + const XMLProperty *prop; + + if ((prop = node.property ("path")) != 0) { + load_automation (prop->value()); + } else { + warning << string_compose(_("%1: Automation node has no path property"), _name) << endmsg; + } + + if ((prop = node.property ("visible")) != 0) { + uint32_t what; + stringstream sstr; + + visible_parameter_automation.clear (); + + sstr << prop->value(); + while (1) { + sstr >> what; + if (sstr.fail()) { + break; + } + mark_automation_visible (what, true); + } + } + + return 0; +} + +int +Redirect::load_automation (string path) +{ + string fullpath; + + if (path[0] == '/') { // legacy + fullpath = path; + } else { + fullpath = _session.automation_dir(); + fullpath += path; + } + ifstream in (fullpath.c_str()); + + if (!in) { + warning << string_compose(_("%1: cannot open %2 to load automation data (%3)"), _name, fullpath, strerror (errno)) << endmsg; + return 1; + } + + Glib::Mutex::Lock lm (_automation_lock); + set<uint32_t> tosave; + parameter_automation.clear (); + + while (in) { + double when; + double value; + uint32_t port; + + in >> port; if (!in) break; + in >> when; if (!in) goto bad; + in >> value; if (!in) goto bad; + + AutomationList& al = automation_list (port); + al.add (when, value); + tosave.insert (port); + } + + return 0; + + bad: + error << string_compose(_("%1: cannot load automation data from %2"), _name, fullpath) << endmsg; + parameter_automation.clear (); + return -1; +} + + void Redirect::what_has_automation (set<uint32_t>& s) const { |