diff options
author | nick_m <mainsbridge@gmail.com> | 2016-09-06 00:04:00 +1000 |
---|---|---|
committer | nick_m <mainsbridge@gmail.com> | 2016-09-06 00:04:00 +1000 |
commit | 5186c69bac29e7b5c542ec98ccf1fb9a7fdac8ea (patch) | |
tree | 88ceb18bac71fc9389770195ebf0553d2ff3ff54 /libs/ardour/midi_region.cc | |
parent | 74a604d261b1ecb0f20ee0c69aef7648da3a1d86 (diff) |
Set start_pulse and length_pulse from state, neither need to be a PBD::Property.
Diffstat (limited to 'libs/ardour/midi_region.cc')
-rw-r--r-- | libs/ardour/midi_region.cc | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index 57c78e312f..cf72379211 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -55,8 +55,6 @@ namespace ARDOUR { namespace Properties { PBD::PropertyDescriptor<Evoral::Beats> start_beats; PBD::PropertyDescriptor<Evoral::Beats> length_beats; - PBD::PropertyDescriptor<double> start_pulse; - PBD::PropertyDescriptor<double> length_pulse; } } @@ -67,10 +65,6 @@ MidiRegion::make_property_quarks () DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for start-beats = %1\n", Properties::start_beats.property_id)); Properties::length_beats.property_id = g_quark_from_static_string (X_("length-beats")); DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for length-beats = %1\n", Properties::length_beats.property_id)); - Properties::start_pulse.property_id = g_quark_from_static_string (X_("start-pulse")); - DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for start-pulse = %1\n", Properties::start_pulse.property_id)); - Properties::length_pulse.property_id = g_quark_from_static_string (X_("length-pulse")); - DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for length-pulse = %1\n", Properties::length_pulse.property_id)); } void @@ -78,8 +72,6 @@ MidiRegion::register_properties () { add_property (_start_beats); add_property (_length_beats); - add_property (_start_pulse); - add_property (_length_pulse); } /* Basic MidiRegion constructor (many channels) */ @@ -87,11 +79,10 @@ MidiRegion::MidiRegion (const SourceList& srcs) : Region (srcs) , _start_beats (Properties::start_beats, Evoral::Beats()) , _length_beats (Properties::length_beats, midi_source(0)->length_beats()) - , _start_pulse (Properties::start_pulse, 0) - , _length_pulse (Properties::length_pulse, midi_source(0)->length_pulse()) + , _start_pulse (0) + , _length_pulse (midi_source(0)->length_pulse()) { register_properties (); - midi_source(0)->ModelChanged.connect_same_thread (_source_connection, boost::bind (&MidiRegion::model_changed, this)); model_changed (); assert(_name.val().find("/") == string::npos); @@ -102,8 +93,8 @@ MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other) : Region (other) , _start_beats (Properties::start_beats, other->_start_beats) , _length_beats (Properties::length_beats, other->_length_beats) - , _start_pulse (Properties::start_pulse, other->_start_pulse) - , _length_pulse (Properties::length_pulse, other->_length_pulse) + , _start_pulse (other->_start_pulse) + , _length_pulse (other->_length_pulse) { //update_length_beats (); register_properties (); @@ -118,8 +109,8 @@ MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other, frameoffset_t : Region (other, offset, sub_num) , _start_beats (Properties::start_beats, Evoral::Beats()) , _length_beats (Properties::length_beats, other->_length_beats) - , _start_pulse (Properties::start_pulse, 0) - , _length_pulse (Properties::length_pulse, other->_length_pulse) + , _start_pulse (0) + , _length_pulse (other->_length_pulse) { _start_beats = Evoral::Beats (_session.tempo_map().exact_beat_at_frame (other->_position + offset, sub_num) - other->beat()) + other->_start_beats; _start_pulse = ((_session.tempo_map().exact_qn_at_frame (other->_position + offset, sub_num) / 4.0) - other->_pulse) + other->_start_pulse; @@ -207,13 +198,13 @@ MidiRegion::clone (boost::shared_ptr<MidiSource> newsrc) const plist.add (Properties::start_beats, _start_beats); plist.add (Properties::length, _length); plist.add (Properties::length_beats, _length_beats); - plist.add (Properties::start_pulse, _start_pulse); - plist.add (Properties::length_pulse, _length_pulse); plist.add (Properties::layer, 0); boost::shared_ptr<MidiRegion> ret (boost::dynamic_pointer_cast<MidiRegion> (RegionFactory::create (newsrc, plist, true))); ret->set_beat (beat()); ret->set_pulse (pulse()); + ret->set_start_pulse (start_pulse()); + ret->set_length_pulse (length_pulse()); return ret; } @@ -280,7 +271,7 @@ MidiRegion::update_after_tempo_map_change (bool /* send */) _start = _position - _session.tempo_map().frame_at_beat (beat() - _start_beats.val().to_double()); /* _length doesn't change for audio-locked regions. update length_beats to match. */ - _length_beats = Evoral::Beats (_session.tempo_map().beat_at_frame (_position + _length) - _session.tempo_map().beat_at_frame (_position)); + _length_beats = Evoral::Beats (_session.tempo_map().quarter_note_at_frame (_position + _length) - _session.tempo_map().quarter_note_at_frame (_position)); _length_pulse = _session.tempo_map().pulse_at_frame (_position + _length) - _session.tempo_map().pulse_at_frame (_position); s_and_l.add (Properties::start); @@ -311,7 +302,7 @@ MidiRegion::update_after_tempo_map_change (bool /* send */) void MidiRegion::update_length_beats (const int32_t sub_num) { - _length_beats = Evoral::Beats (_session.tempo_map().exact_beat_at_frame (_position + _length, sub_num) - beat()); + _length_beats = Evoral::Beats (_session.tempo_map().exact_qn_at_frame (_position + _length, sub_num) - (pulse() * 4.0)); _length_pulse = (_session.tempo_map().exact_qn_at_frame (_position + _length, sub_num) / 4.0) - pulse(); } @@ -329,7 +320,7 @@ MidiRegion::set_position_internal (framepos_t pos, bool allow_bbt_recompute, con } if (position_lock_style() == AudioTime) { - _length_beats = Evoral::Beats (_session.tempo_map().beat_at_frame (_position + _length) - _session.tempo_map().beat_at_frame (_position)); + _length_beats = Evoral::Beats (_session.tempo_map().quarter_note_at_frame (_position + _length) - _session.tempo_map().quarter_note_at_frame (_position)); _length_pulse = _session.tempo_map().pulse_at_frame (_position + _length) - _session.tempo_map().pulse_at_frame (_position); } else { /* leave _length_beats alone, and change _length to reflect the state of things @@ -450,6 +441,9 @@ MidiRegion::set_state (const XMLNode& node, int version) } } + _start_pulse = _start_beats.val().to_double() / 4.0; + _length_pulse = _length_beats.val().to_double() / 4.0; + return ret; } @@ -630,7 +624,6 @@ MidiRegion::trim_to_internal (framepos_t position, framecnt_t length, const int3 what_changed.add (Properties::start_beats); _start_pulse = new_start_pulse; - what_changed.add (Properties::start_pulse); set_start_internal (new_start, sub_num); what_changed.add (Properties::start); |