diff options
Diffstat (limited to 'libs/ardour/midi_region.cc')
-rw-r--r-- | libs/ardour/midi_region.cc | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index 7511aadce8..3c885a8d99 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -102,20 +102,20 @@ MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other) } /** Create a new MidiRegion that is part of an existing one */ -MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other, frameoffset_t offset, const int32_t sub_num) - : Region (other, offset, sub_num) +MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other, MusicFrame offset) + : Region (other, offset) , _start_beats (Properties::start_beats, other->_start_beats) , _length_beats (Properties::length_beats, other->_length_beats) { - if (offset != 0) { - _start_beats = (_session.tempo_map().exact_qn_at_frame (other->_position + offset, sub_num) - other->_quarter_note) + other->_start_beats; - update_length_beats (sub_num); - /* we've potentially shifted _start_beats, now reset _start frames to match */ - _start = _session.tempo_map().frames_between_quarter_notes (_quarter_note - _start_beats, _quarter_note); - } register_properties (); + const double offset_quarter_note = _session.tempo_map().exact_qn_at_frame (other->_position + offset.frame, offset.division) - other->_quarter_note; + if (offset.frame != 0) { + _start_beats = other->_start_beats + offset_quarter_note; + _length_beats = other->_length_beats - offset_quarter_note; + } + assert(_name.val().find("/") == string::npos); midi_source(0)->ModelChanged.connect_same_thread (_source_connection, boost::bind (&MidiRegion::model_changed, this)); model_changed (); @@ -345,6 +345,24 @@ MidiRegion::set_position_internal (framepos_t pos, bool allow_bbt_recompute, con } } +void +MidiRegion::set_position_music_internal (double qn) +{ + Region::set_position_music_internal (qn); + /* set _start to new position in tempo map */ + _start = _session.tempo_map().frames_between_quarter_notes (quarter_note() - start_beats(), quarter_note()); + + if (position_lock_style() == AudioTime) { + _length_beats = _session.tempo_map().quarter_note_at_frame (_position + _length) - quarter_note(); + + } else { + /* 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). + */ + _length = _session.tempo_map().frames_between_quarter_notes (quarter_note(), quarter_note() + length_beats()); + } +} + framecnt_t MidiRegion::read_at (Evoral::EventSink<framepos_t>& out, framepos_t position, |