diff --git a/libs/temporal/tempo.cc b/libs/temporal/tempo.cc index ae3726c96c..e85b18886c 100644 --- a/libs/temporal/tempo.cc +++ b/libs/temporal/tempo.cc @@ -1971,6 +1971,16 @@ TempoMap::get_grid (TempoMapPoints& ret, superclock_t start, superclock_t end, u DEBUG_TRACE (DEBUG::Grid, "<<< GRID DONE\n"); } +uint32_t +TempoMap::count_bars (Beats const & start, Beats const & end) +{ + TempoMapPoints bar_grid; + superclock_t s (superclock_at (start)); + superclock_t e (superclock_at (end)); + get_grid (bar_grid, s, e, 1); + return bar_grid.size(); +} + std::ostream& std::operator<<(std::ostream& str, Meter const & m) { diff --git a/libs/temporal/temporal/tempo.h b/libs/temporal/temporal/tempo.h index 8f379c48fb..4f8cfe2572 100644 --- a/libs/temporal/temporal/tempo.h +++ b/libs/temporal/temporal/tempo.h @@ -787,6 +787,7 @@ class LIBTEMPORAL_API TempoMap : public PBD::StatefulDestructible BBT_Time bbt_walk (BBT_Time const &, BBT_Offset const &) const; void get_grid (TempoMapPoints& points, superclock_t start, superclock_t end, uint32_t bar_mod = 0); + uint32_t count_bars (Beats const & start, Beats const & end); struct EmptyTempoMapException : public std::exception { virtual const char* what() const throw() { return "TempoMap is empty"; }