#include <gtkmm2ext/barcontroller.h>
#include <gtkmm2ext/utils.h>
#include <boost/algorithm/string.hpp>
-#include <boost/lexical_cast.hpp>
#include "pbd/error.h"
#include "pbd/memento_command.h"
#include "pbd/stacktrace.h"
+#include "pbd/string_convert.h"
+#include "pbd/types_convert.h"
#include "ardour/automation_control.h"
+#include "ardour/beats_frames_converter.h"
#include "ardour/event_type_map.h"
#include "ardour/parameter_types.h"
#include "ardour/profile.h"
counts.increase_n_lines(_parameter);
/* add multi-paste offset if applicable */
- pos += _editor.get_paste_offset(pos, paste_count, (*p)->length());
+ AutomationType src_type = (AutomationType)(*p)->parameter().type ();
+ double len = (*p)->length();
+
+ if (parameter_is_midi (src_type)) {
+ // convert length to samples (incl tempo-ramps)
+ len = DoubleBeatsFramesConverter (_session->tempo_map(), pos).to (len * paste_count);
+ pos += _editor.get_paste_offset (pos, paste_count > 0 ? 1 : 0, len);
+ } else {
+ pos += _editor.get_paste_offset (pos, paste_count, len);
+ }
+
+ /* convert sample-position to model's unit and position */
double const model_pos = _line->time_converter().from (pos - _line->time_converter().origin_b ());
XMLNode &before = alist->get_state();
- alist->paste (**p, model_pos, times);
+ alist->paste (**p, model_pos, DoubleBeatsFramesConverter (_session->tempo_map(), pos));
_session->add_command (new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
return true;
AutomationTimeAxisView::state_id() const
{
if (_automatable != _route && _control) {
- return string_compose ("automation %1", _control->id().to_s());
+ return string("automation ") + _control->id().to_s();
} else if (_parameter) {
- return string_compose ("automation %1 %2/%3/%4",
- _route->id(),
- _parameter.type(),
- _parameter.id(),
- (int) _parameter.channel());
+ const string parameter_str = PBD::to_string (_parameter.type()) + "/" +
+ PBD::to_string (_parameter.id()) + "/" +
+ PBD::to_string (_parameter.channel ());
+
+ return string("automation ") + PBD::to_string(_route->id()) + " " + parameter_str;
} else {
error << "Automation time axis has no state ID" << endmsg;
return "";
bool & has_parameter,
Evoral::Parameter & parameter)
{
- stringstream s;
- s << state_id;
+ stringstream ss;
+ ss << state_id;
string a, b, c;
- s >> a >> b >> c;
+ ss >> a >> b >> c;
if (a != X_("automation")) {
return false;
assert (p.size() == 3);
parameter = Evoral::Parameter (
- boost::lexical_cast<int> (p[0]),
- boost::lexical_cast<int> (p[2]),
- boost::lexical_cast<int> (p[1])
+ PBD::string_to<uint32_t>(p[0]), // type
+ PBD::string_to<uint8_t>(p[2]), // channel
+ PBD::string_to<uint32_t>(p[1]) // id
);
return true;
{
return gdk_color_from_rgb (_route->presentation_info().color());
}
+