From 3918ee2ed69d3bac4f6b66d4bbed00f9b19842e3 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Tue, 30 Nov 2021 12:15:04 -0600 Subject: [PATCH] Add New Region variables for Clips Properties are created for announcing changes, but values are not actually stored as undo-able properties. --- libs/ardour/ardour/region.h | 31 +++++++++++++++++++++++++++++++ libs/ardour/region.cc | 31 +++++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h index 9032c14c34..8ee3d56509 100644 --- a/libs/ardour/ardour/region.h +++ b/libs/ardour/ardour/region.h @@ -74,7 +74,15 @@ namespace Properties { LIBARDOUR_API extern PBD::PropertyDescriptor layering_index; LIBARDOUR_API extern PBD::PropertyDescriptor tags; LIBARDOUR_API extern PBD::PropertyDescriptor contents; // type doesn't matter here + + /* these properties are used as a convenience for announcing changes to state, but aren't stored as properties */ 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 +132,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; } + 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; @@ -279,6 +295,13 @@ public: void set_video_locked (bool yn); void set_position_locked (bool yn); + void set_bpm (float bpm); + void set_metrum_numerator (uint8_t num); + void set_metrum_divisor (uint8_t div); + void set_sync_to_bbt (bool sync); + void set_loop_enabled (bool en); + void set_loop_start (timepos_t); + Temporal::timepos_t region_beats_to_absolute_time(Temporal::Beats beats) const; /** Convert a timestamp in beats into timepos_t (both relative to region position) */ Temporal::timepos_t region_beats_to_region_time (Temporal::Beats beats) const { @@ -521,6 +544,14 @@ private: PBD::Property _tags; PBD::Property _contents; // type is irrelevant + /* these values are (currently) only used when the region is in a trigger slot */ + float _bpm; + uint8_t _metrum_numerator; //pulses per bar (typically 4) + uint8_t _metrum_divisor; //divisor note type (typically 4 = quarter-note) + bool _sync_to_bbt; + bool _loop_enabled; + timepos_t _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..0ab17936fc 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -82,7 +82,15 @@ namespace ARDOUR { PBD::PropertyDescriptor layering_index; PBD::PropertyDescriptor tags; PBD::PropertyDescriptor contents; + + /* these properties are used as a convenience for announcing changes to state, but aren't stored as properties */ 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; } } @@ -204,7 +212,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 (110) \ + , _metrum_numerator (4) \ + , _metrum_divisor (4) \ + , _sync_to_bbt (false) \ + , _loop_enabled (false) \ + , _loop_start (0) #define REGION_COPY_STATE(other) \ _sync_marked (Properties::sync_marked, other->_sync_marked) \ @@ -236,7 +250,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 (other->_bpm) \ + , _metrum_numerator (other->_metrum_numerator) \ + , _metrum_divisor (other->_metrum_divisor) \ + , _sync_to_bbt (other->_sync_to_bbt) \ + , _loop_enabled (other->_loop_enabled) \ + , _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) @@ -583,6 +603,13 @@ Region::set_position_time_domain (Temporal::TimeDomain td) } } +void Region::set_bpm (float bpm) { _bpm = bpm; send_change (Properties::bpm);} +void Region::set_metrum_numerator (uint8_t num) { _metrum_numerator = num; send_change (Properties::metrum_numerator);} +void Region::set_metrum_divisor (uint8_t div) { _metrum_divisor = div; send_change (Properties::metrum_divisor);} +void Region::set_sync_to_bbt (bool sync) { _sync_to_bbt = sync; send_change (Properties::sync_to_bbt);} +void Region::set_loop_enabled (bool en) { _loop_enabled = en; send_change (Properties::loop_enabled);} +void Region::set_loop_start (timepos_t ls) { _loop_start = ls; send_change (Properties::loop_start);} + void Region::recompute_position_from_time_domain () {