#include <sstream>
#include <algorithm>
#include "ardour/automation_list.h"
+#include "ardour/beats_frames_converter.h"
#include "ardour/event_type_map.h"
#include "ardour/parameter_descriptor.h"
+#include "ardour/parameter_types.h"
#include "ardour/evoral_types_convert.h"
#include "ardour/types_convert.h"
#include "evoral/Curve.hpp"
}
AutomationList::AutomationList (const AutomationList& other)
- : StatefulDestructible()
- , ControlList(other)
+ : ControlList(other)
+ , StatefulDestructible()
, _before (0)
{
_style = other._style;
}
}
+bool
+AutomationList::paste (const ControlList& alist, double pos, DoubleBeatsFramesConverter const& bfc)
+{
+ AutomationType src_type = (AutomationType)alist.parameter().type();
+ AutomationType dst_type = (AutomationType)_parameter.type();
+
+ if (parameter_is_midi (src_type) == parameter_is_midi (dst_type)) {
+ return ControlList::paste (alist, pos);
+ }
+ bool to_frame = parameter_is_midi (src_type);
+
+ ControlList cl (alist);
+ cl.clear ();
+ for (const_iterator i = alist.begin ();i != alist.end (); ++i) {
+ double when = (*i)->when;
+ if (to_frame) {
+ when = bfc.to ((*i)->when);
+ } else {
+ when = bfc.from ((*i)->when);
+ }
+ cl.fast_simple_add (when, (*i)->value);
+ }
+ return ControlList::paste (cl, pos);
+}
+
Command*
AutomationList::memento_command (XMLNode* before, XMLNode* after)
{
XMLNode* node = new XMLNode (X_("events"));
stringstream str;
- str.precision(15); //10 digits is enough digits for 24 hours at 96kHz
-
for (iterator xx = _events.begin(); xx != _events.end(); ++xx) {
- str << (double) (*xx)->when;
+ str << PBD::to_string ((*xx)->when);
str << ' ';
- str <<(double) (*xx)->value;
+ str << PBD::to_string ((*xx)->value);
str << '\n';
}
stringstream str (content_node->content());
+ std::string x_str;
+ std::string y_str;
double x;
double y;
bool ok = true;
while (str) {
- str >> x;
- if (!str) {
+ str >> x_str;
+ if (!str || !PBD::string_to<double> (x_str, x)) {
break;
}
- str >> y;
- if (!str) {
+ str >> y_str;
+ if (!str || !PBD::string_to<double> (y_str, y)) {
ok = false;
break;
}