summaryrefslogtreecommitdiff
path: root/gtk2_ardour/automation_time_axis.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-04-26 16:21:39 +0200
committerRobin Gareus <robin@gareus.org>2017-04-26 23:37:27 +0200
commit0b5db91ee91afbd61a3ab11cb99796132f1b74b9 (patch)
tree6771f6e96b0c5fe961c3117c90d52090006906f0 /gtk2_ardour/automation_time_axis.cc
parent8bb26628e392429c8a868af3d92cb79ee52a0fc7 (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 'gtk2_ardour/automation_time_axis.cc')
-rw-r--r--gtk2_ardour/automation_time_axis.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc
index cb8456e062..0b71e423cd 100644
--- a/gtk2_ardour/automation_time_axis.cc
+++ b/gtk2_ardour/automation_time_axis.cc
@@ -29,6 +29,7 @@
#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"
@@ -695,12 +696,23 @@ AutomationTimeAxisView::paste_one (framepos_t pos, unsigned paste_count, float t
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;