diff --git a/libs/ardour/ardour/midi_region.h b/libs/ardour/ardour/midi_region.h index 48706ee7d9..03166bb0c3 100644 --- a/libs/ardour/ardour/midi_region.h +++ b/libs/ardour/ardour/midi_region.h @@ -34,8 +34,6 @@ namespace ARDOUR { namespace Properties { LIBARDOUR_API extern PBD::PropertyDescriptor start_beats; LIBARDOUR_API extern PBD::PropertyDescriptor length_beats; - LIBARDOUR_API extern PBD::PropertyDescriptor start_pulse; - LIBARDOUR_API extern PBD::PropertyDescriptor length_pulse; } } @@ -108,7 +106,9 @@ class LIBARDOUR_API MidiRegion : public Region Evoral::Beats start_beats () {return _start_beats.val(); } Evoral::Beats length_beats () {return _length_beats.val(); } double start_pulse () const {return _start_pulse; } + void set_start_pulse (const double start_pulse) {_start_pulse = start_pulse; } double length_pulse () const {return _length_pulse; } + void set_length_pulse (const double length_pulse) {_length_pulse = length_pulse; } protected: virtual bool can_trim_start_before_source_start () const { @@ -119,8 +119,9 @@ class LIBARDOUR_API MidiRegion : public Region friend class RegionFactory; PBD::Property _start_beats; PBD::Property _length_beats; - PBD::Property _start_pulse; - PBD::Property _length_pulse; + + double _start_pulse; + double _length_pulse; MidiRegion (const SourceList&); MidiRegion (boost::shared_ptr); 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 start_beats; PBD::PropertyDescriptor length_beats; - PBD::PropertyDescriptor start_pulse; - PBD::PropertyDescriptor 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 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 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 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 ret (boost::dynamic_pointer_cast (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);