From 20269df975f4c6edd127d0cb4a114f9e89b7a4e1 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 8 Aug 2025 15:41:32 -0600 Subject: [PATCH] Regions get their own tempo and meter This defaults to the usual 120bpm 4/4 but is also not used anywhere yet --- libs/ardour/ardour/region.h | 7 +++++++ libs/ardour/region.cc | 15 +++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h index d682ac9e0f..bccdbf78f0 100644 --- a/libs/ardour/ardour/region.h +++ b/libs/ardour/ardour/region.h @@ -29,6 +29,7 @@ #include "temporal/domain_swap.h" #include "temporal/timeline.h" #include "temporal/range.h" +#include "temporal/tempo.h" #include "pbd/undo.h" #include "pbd/signals.h" @@ -541,6 +542,9 @@ public: } } + Temporal::Tempo tempo() const { return _tempo; } + Temporal::Meter meter() const { return _meter; } + protected: virtual XMLNode& state () const; @@ -593,6 +597,9 @@ protected: uint32_t _fx_tail; RegionFxList _plugins; + Temporal::Tempo _tempo; + Temporal::Meter _meter; + PBD::Property _sync_marked; PBD::Property _left_of_split; PBD::Property _right_of_split; diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index ac7d2ab2b6..6da010e635 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -228,7 +228,9 @@ Region::register_properties () } #define REGION_DEFAULT_STATE(s,l) \ - _sync_marked (Properties::sync_marked, false) \ + _tempo (120, 4) \ + , _meter (4, 4) \ + , _sync_marked (Properties::sync_marked, false) \ , _left_of_split (Properties::left_of_split, false) \ , _right_of_split (Properties::right_of_split, false) \ , _valid_transients (Properties::valid_transients, false) \ @@ -259,7 +261,9 @@ Region::register_properties () , _contents (Properties::contents, false) #define REGION_COPY_STATE(other) \ - _sync_marked (Properties::sync_marked, other->_sync_marked) \ + _tempo (other->_tempo) \ + , _meter (other->_meter) \ + , _sync_marked (Properties::sync_marked, other->_sync_marked) \ , _left_of_split (Properties::left_of_split, other->_left_of_split) \ , _right_of_split (Properties::right_of_split, other->_right_of_split) \ , _valid_transients (Properties::valid_transients, other->_valid_transients) \ @@ -1420,6 +1424,9 @@ Region::state () const node->set_property ("id", id ()); node->set_property ("type", _type); + node->add_child_nocopy (_tempo.get_state()); + node->add_child_nocopy (_meter.get_state()); + std::string fe; switch (_first_edit) { @@ -1619,6 +1626,10 @@ Region::_set_state (const XMLNode& node, int version, PropertyChange& what_chang } _plugins.push_back (rfx); changed = true; + } else if (child->name() == Temporal::Tempo::xml_node_name) { + _tempo.set_state (*child, version); + } else if (child->name() == Temporal::Meter::xml_node_name) { + _meter.set_state (*child, version); } } lm.release ();