From 6a622d86dca2c8af8993d85be8bd8a44debc5b8c Mon Sep 17 00:00:00 2001 From: nick_m Date: Tue, 7 Jun 2016 02:14:31 +1000 Subject: [PATCH] Fix midi region split, trim and move operations. - there is still the problem of being unable to drag a trimmed region to the left when it's source (not it's position) would end up on a negative beat. --- libs/ardour/midi_region.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index b1c332072e..05037d4af3 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -107,11 +107,11 @@ MidiRegion::MidiRegion (boost::shared_ptr other, frameoffset_t , _start_beats (Properties::start_beats, Evoral::Beats()) , _length_beats (Properties::length_beats, Evoral::Beats()) { - BeatsFramesConverter bfc (_session.tempo_map(), _position); + BeatsFramesConverter bfc (_session.tempo_map(), other->_position); Evoral::Beats const offset_beats = bfc.from (offset); - _start_beats = other->_start_beats.val() + offset_beats; - _length_beats = other->_length_beats.val() - offset_beats; + _start_beats = other->_start_beats.val() + offset_beats; + _length_beats = Evoral::Beats (_session.tempo_map().beat_at_frame (other->length() - offset)); register_properties (); @@ -224,6 +224,9 @@ MidiRegion::set_position_internal (framepos_t pos, bool allow_bbt_recompute) { Region::set_position_internal (pos, allow_bbt_recompute); + /* set _start to new position in tempo map */ + _start = _position - _session.tempo_map().framepos_minus_beats (_position, _start_beats); + /* leave _length_beats alone, and change _length to reflect the state of things at the new position (tempo map may dictate a different number of frames). */