From 0b5db91ee91afbd61a3ab11cb99796132f1b74b9 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 26 Apr 2017 16:21:39 +0200 Subject: AutomationLine time-unit conversion and paste API update This fixes copy/paste of MIDI automation (time-unit: beat) from/to Parameter automation (time-unit: samples). It also fixes repeatedly pasting with tempo-ramps: pre-multiply length before converting to samples. --- libs/ardour/automation_list.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'libs/ardour/automation_list.cc') diff --git a/libs/ardour/automation_list.cc b/libs/ardour/automation_list.cc index c397323767..0d43298610 100644 --- a/libs/ardour/automation_list.cc +++ b/libs/ardour/automation_list.cc @@ -24,8 +24,10 @@ #include #include #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" @@ -289,6 +291,31 @@ AutomationList::thaw () } } +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) { -- cgit v1.2.3