temporal: provide a map to get the BBT reference point before a superclock time

This commit is contained in:
Paul Davis
2026-01-01 19:19:23 -07:00
parent 52c7d6ab77
commit bbf5bd6043
2 changed files with 28 additions and 0 deletions

View File

@@ -1785,6 +1785,32 @@ TempoMap::set_bartime (BBT_Time const & bbt, timepos_t const & pos, std::string
add_or_replace_bartime (tp);
}
superclock_t
TempoMap::previous_bbt_reference_at_superclock (superclock_t sc) const
{
if (_bartimes.empty()) {
return 0;
}
if (_bartimes.size() == 1) {
if (_bartimes.front().sclock() > sc) {
return 0;
}
return _bartimes.front().sclock();
}
MusicTimes::const_iterator m;
for (m = _bartimes.begin(); m != _bartimes.end() && (*m).sclock() < sc; ++m);
if (m == _bartimes.end()) {
return _bartimes.back().sclock();
}
--m;
return (*m).sclock();
}
void
TempoMap::replace_bartime (MusicTimePoint & mtp, bool with_reset)
{

View File

@@ -825,6 +825,8 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible
LIBTEMPORAL_API void remove_bartime (MusicTimePoint const & tp, bool with_reset = true);
LIBTEMPORAL_API void replace_bartime (MusicTimePoint & tp, bool with_reset = true);
LIBTEMPORAL_API superclock_t previous_bbt_reference_at_superclock (superclock_t) const;
U
LIBTEMPORAL_API TempoPoint& set_tempo (Tempo const &, BBT_Argument const &);
LIBTEMPORAL_API TempoPoint& set_tempo (Tempo const &, timepos_t const &);