add TempoMap::count_bars() to allow bar counting even with position (BBT) markers in the tempo map
This just reuses the algorithm in TempoMap::get_grid() by asking for just the bar grid, and counting the size of the result
This commit is contained in:
parent
f05b2ed93b
commit
991a7bf8a7
@ -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)
|
||||
{
|
||||
|
@ -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"; }
|
||||
|
Loading…
Reference in New Issue
Block a user