From 045cf7709fde99a15ee022df86cae2482c39124f Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Tue, 30 Nov 2021 12:15:04 -0600 Subject: [PATCH] Add New Region Properties for Clips --- libs/ardour/ardour/region.h | 22 ++++++++++++++++++++ libs/ardour/region.cc | 40 +++++++++++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h index 9032c14c34..5d94931ed8 100644 --- a/libs/ardour/ardour/region.h +++ b/libs/ardour/ardour/region.h @@ -75,6 +75,12 @@ namespace Properties { LIBARDOUR_API extern PBD::PropertyDescriptor tags; LIBARDOUR_API extern PBD::PropertyDescriptor contents; // type doesn't matter here LIBARDOUR_API extern PBD::PropertyDescriptor time_domain; + LIBARDOUR_API extern PBD::PropertyDescriptor bpm; + LIBARDOUR_API extern PBD::PropertyDescriptor metrum_numerator; //pulses per bar (typically 4) + LIBARDOUR_API extern PBD::PropertyDescriptor metrum_divisor; //divisor note type (typically 4 = quarter-note) + LIBARDOUR_API extern PBD::PropertyDescriptor sync_to_bbt; + LIBARDOUR_API extern PBD::PropertyDescriptor loop_enabled; + LIBARDOUR_API extern PBD::PropertyDescriptor loop_start; }; class Playlist; @@ -124,6 +130,14 @@ public: timepos_t end() const; timepos_t nt_last() const { return end().decrement(); } + /** Note: these values are currently only used when the region is in a trigger slot */ + float bpm () const { return _bpm; } + uint8_t metrum_numerator () const { return _metrum_numerator; } + uint8_t metrum_divisor () const { return _metrum_divisor; } + bool sync_to_bbt () const { return _sync_to_bbt; } + bool loop_enabled () const { return _loop_enabled; } + timepos_t loop_start () const { return _loop_start.val(); } + timepos_t source_position () const; timepos_t source_relative_position (Temporal::timepos_t const &) const; timepos_t region_relative_position (Temporal::timepos_t const &) const; @@ -521,6 +535,14 @@ private: PBD::Property _tags; PBD::Property _contents; // type is irrelevant + /* these properties are (currently) only used when the region is in a trigger slot */ + PBD::Property _bpm; + PBD::Property _metrum_numerator; //pulses per bar (typically 4) + PBD::Property _metrum_divisor; //divisor note type (typically 4 = quarter-note) + PBD::Property _sync_to_bbt; + PBD::Property _loop_enabled; + PBD::Property _loop_start; + timecnt_t _last_length; mutable RegionEditState _first_edit; layer_t _layer; diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index 5661badd03..b6e9933827 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -83,6 +83,12 @@ namespace ARDOUR { PBD::PropertyDescriptor tags; PBD::PropertyDescriptor contents; PBD::PropertyDescriptor time_domain; + PBD::PropertyDescriptor bpm; + PBD::PropertyDescriptor metrum_numerator; + PBD::PropertyDescriptor metrum_divisor; + PBD::PropertyDescriptor sync_to_bbt; + PBD::PropertyDescriptor loop_enabled; + PBD::PropertyDescriptor loop_start; } } @@ -143,6 +149,18 @@ Region::make_property_quarks () DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for tags = %1\n", Properties::tags.property_id)); Properties::contents.property_id = g_quark_from_static_string (X_("contents")); DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for contents = %1\n", Properties::contents.property_id)); + Properties::bpm.property_id = g_quark_from_static_string (X_("bpm")); + DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for bpm = %1\n", Properties::bpm.property_id)); + Properties::metrum_numerator.property_id = g_quark_from_static_string (X_("metrum_numerator")); + DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for metrum_numerator = %1\n", Properties::metrum_numerator.property_id)); + Properties::metrum_divisor.property_id = g_quark_from_static_string (X_("metrum_divisor")); + DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for metrum_divisor = %1\n", Properties::metrum_divisor.property_id)); + Properties::sync_to_bbt.property_id = g_quark_from_static_string (X_("sync_to_bbt")); + DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for sync_to_bbt = %1\n", Properties::sync_to_bbt.property_id)); + Properties::loop_enabled.property_id = g_quark_from_static_string (X_("loop_enabled")); + DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for loop_enabled = %1\n", Properties::loop_enabled.property_id)); + Properties::loop_start.property_id = g_quark_from_static_string (X_("loop_start")); + DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for loop_start = %1\n", Properties::loop_start.property_id)); } void @@ -174,6 +192,12 @@ Region::register_properties () add_property (_layering_index); add_property (_tags); add_property (_contents); + add_property (_bpm); + add_property (_metrum_numerator); + add_property (_metrum_divisor); + add_property (_sync_to_bbt); + add_property (_loop_enabled); + add_property (_loop_start); } #define REGION_DEFAULT_STATE(s,l) \ @@ -204,7 +228,13 @@ Region::register_properties () , _shift (Properties::shift, 1.0) \ , _layering_index (Properties::layering_index, 0) \ , _tags (Properties::tags, "") \ - , _contents (Properties::contents, false) + , _contents (Properties::contents, false) \ + , _bpm (Properties::bpm, 110) \ + , _metrum_numerator (Properties::metrum_numerator, 4) \ + , _metrum_divisor (Properties::metrum_divisor, 4) \ + , _sync_to_bbt (Properties::sync_to_bbt, false) \ + , _loop_enabled (Properties::loop_enabled, false) \ + , _loop_start (Properties::loop_start, (s)) #define REGION_COPY_STATE(other) \ _sync_marked (Properties::sync_marked, other->_sync_marked) \ @@ -236,7 +266,13 @@ Region::register_properties () , _shift (Properties::shift, other->_shift) \ , _layering_index (Properties::layering_index, other->_layering_index) \ , _tags (Properties::tags, other->_tags) \ - , _contents (Properties::contents, other->_contents) + , _contents (Properties::contents, other->_contents) \ + , _bpm (Properties::bpm, other->_bpm) \ + , _metrum_numerator (Properties::metrum_numerator, other->_metrum_numerator) \ + , _metrum_divisor (Properties::metrum_divisor, other->_metrum_divisor) \ + , _sync_to_bbt (Properties::sync_to_bbt, other->_sync_to_bbt) \ + , _loop_enabled (Properties::loop_enabled, other->_loop_enabled) \ + , _loop_start (Properties::loop_start, other->_loop_start) /* derived-from-derived constructor (no sources in constructor) */ Region::Region (Session& s, timepos_t const & start, timecnt_t const & length, const string& name, DataType type)