diff options
author | David Robillard <d@drobilla.net> | 2010-12-22 00:48:59 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-12-22 00:48:59 +0000 |
commit | 19fc040be16a1ddab2dfc2fe96b6c36498074d86 (patch) | |
tree | 5daa2d7fcf1b662b7c643c15e55f3e83b3590c8e /libs/ardour/midi_region.cc | |
parent | 9e5550254c0f7f3681a0d182c53e5e9ee0adde08 (diff) |
Calculate length_beats of split MIDI regions from 'parent' region.
This is probably less than ideal, since setting the properties later will
recompute from frames values. It is, however, slightly more rightish :)
Seemingly correct cases (i.e. where length_beats is correct):
* Recording a new MIDI region
* Splitting said region
Broken:
* Loading a region from XML
Untested:
* Import
git-svn-id: svn://localhost/ardour2/branches/3.0@8324 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/midi_region.cc')
-rw-r--r-- | libs/ardour/midi_region.cc | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index afae8eadc8..f4058377b6 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -82,7 +82,6 @@ MidiRegion::MidiRegion (const SourceList& srcs) assert(_type == DataType::MIDI); } -/** Create a new MidiRegion, that is part of an existing one */ MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other) : Region (other) , _length_beats (Properties::length_beats, (Evoral::MusicalTime) 0) @@ -100,7 +99,11 @@ MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other, frameoffset_t : Region (other, offset) , _length_beats (Properties::length_beats, (Evoral::MusicalTime) 0) { - update_length_beats (); + BeatsFramesConverter bfc (_session.tempo_map(), _position); + Evoral::MusicalTime const offset_beats = bfc.from (offset); + + _length_beats = other->_length_beats - offset_beats; + register_properties (); assert(_name.val().find("/") == string::npos); @@ -222,13 +225,13 @@ MidiRegion::_read_at (const SourceList& /*srcs*/, Evoral::EventSink<framepos_t>& boost::shared_ptr<MidiSource> src = midi_source(chan_n); src->set_note_mode(mode); - /* - cerr << "MR read @ " << position << " * " << to_read - << " _position = " << _position - << " _start = " << _start - << " intoffset = " << internal_offset - << endl; - */ + /* + cerr << "MR read @ " << position << " * " << to_read + << " _position = " << _position + << " _start = " << _start + << " intoffset = " << internal_offset + << endl; + */ /* This call reads events from a source and writes them to `dst' timed in session frames */ @@ -270,7 +273,7 @@ void MidiRegion::recompute_at_end () { /* our length has changed - * so what? stuck notes are dealt with via a note state tracker + * so what? stuck notes are dealt with via a note state tracker */ } @@ -332,8 +335,8 @@ MidiRegion::model_changed () _model_connection, boost::bind (&MidiRegion::model_automation_state_changed, this, _1) ); - model()->ContentsChanged.connect_same_thread ( - _model_contents_connection, boost::bind (&MidiRegion::model_contents_changed, this)); + model()->ContentsChanged.connect_same_thread ( + _model_contents_connection, boost::bind (&MidiRegion::model_contents_changed, this)); } void |