diff options
author | Robin Gareus <robin@gareus.org> | 2017-04-26 16:21:39 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2017-04-26 23:37:27 +0200 |
commit | 0b5db91ee91afbd61a3ab11cb99796132f1b74b9 (patch) | |
tree | 6771f6e96b0c5fe961c3117c90d52090006906f0 /libs | |
parent | 8bb26628e392429c8a868af3d92cb79ee52a0fc7 (diff) |
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.
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/automation_list.h | 2 | ||||
-rw-r--r-- | libs/ardour/automation_list.cc | 27 | ||||
-rw-r--r-- | libs/evoral/evoral/ControlList.hpp | 2 | ||||
-rw-r--r-- | libs/evoral/src/ControlList.cpp | 2 |
4 files changed, 31 insertions, 2 deletions
diff --git a/libs/ardour/ardour/automation_list.h b/libs/ardour/ardour/automation_list.h index ca72f5f01f..3f4d3f2f52 100644 --- a/libs/ardour/ardour/automation_list.h +++ b/libs/ardour/ardour/automation_list.h @@ -40,6 +40,7 @@ namespace ARDOUR { class AutomationList; +class DoubleBeatsFramesConverter; /** A SharedStatefulProperty for AutomationLists */ class LIBARDOUR_API AutomationListProperty : public PBD::SharedStatefulProperty<AutomationList> @@ -81,6 +82,7 @@ class LIBARDOUR_API AutomationList : public Evoral::ControlList, public PBD::Sta AutomationList& operator= (const AutomationList&); void thaw (); + bool paste (const ControlList&, double, DoubleBeatsFramesConverter const&); void set_automation_state (AutoState); AutoState automation_state() const { return _state; } 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 <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" @@ -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) { diff --git a/libs/evoral/evoral/ControlList.hpp b/libs/evoral/evoral/ControlList.hpp index 8e72c21c48..b58c186c21 100644 --- a/libs/evoral/evoral/ControlList.hpp +++ b/libs/evoral/evoral/ControlList.hpp @@ -172,7 +172,7 @@ public: */ void clear (double start, double end); - bool paste (const ControlList&, double position, float times); + bool paste (const ControlList&, double position); void set_yrange (double min, double max) { _min_yval = min; diff --git a/libs/evoral/src/ControlList.cpp b/libs/evoral/src/ControlList.cpp index 0b2184a972..ce8ea89fc9 100644 --- a/libs/evoral/src/ControlList.cpp +++ b/libs/evoral/src/ControlList.cpp @@ -1652,7 +1652,7 @@ ControlList::clear (double start, double end) /** @param pos Position in model coordinates */ bool -ControlList::paste (const ControlList& alist, double pos, float /*times*/) +ControlList::paste (const ControlList& alist, double pos) { if (alist._events.empty()) { return false; |