temporal: add optional with_reset arg to all map ::remove_*() methods

This commit is contained in:
Paul Davis 2022-12-20 21:54:05 -07:00
parent 0ee0226776
commit 818c30a98d
2 changed files with 16 additions and 10 deletions

View file

@ -817,7 +817,7 @@ TempoMap::change_tempo (TempoPoint & p, Tempo const & t)
void void
TempoMap::replace_tempo (TempoPoint const & old, Tempo const & t, timepos_t const & time) TempoMap::replace_tempo (TempoPoint const & old, Tempo const & t, timepos_t const & time)
{ {
remove_tempo (old); remove_tempo (old, false);
set_tempo (t, time); set_tempo (t, time);
} }
@ -983,7 +983,7 @@ TempoMap::add_tempo (TempoPoint * tp)
} }
void void
TempoMap::remove_tempo (TempoPoint const & tp) TempoMap::remove_tempo (TempoPoint const & tp, bool with_reset)
{ {
if (_tempos.size() < 2) { if (_tempos.size() < 2) {
return; return;
@ -1040,8 +1040,10 @@ TempoMap::remove_tempo (TempoPoint const & tp)
if (prev != _tempos.end() && was_end) { if (prev != _tempos.end() && was_end) {
prev->set_end_npm (prev->note_types_per_minute()); /* remove any ramp */ prev->set_end_npm (prev->note_types_per_minute()); /* remove any ramp */
} else { } else {
if (with_reset) {
reset_starting_at (sc); reset_starting_at (sc);
} }
}
} }
void void
@ -1077,7 +1079,7 @@ TempoMap::add_or_replace_bartime (MusicTimePoint* mtp)
} }
void void
TempoMap::remove_bartime (MusicTimePoint const & tp) TempoMap::remove_bartime (MusicTimePoint const & tp, bool with_reset)
{ {
superclock_t sc (tp.sclock()); superclock_t sc (tp.sclock());
MusicTimes::iterator m; MusicTimes::iterator m;
@ -1106,7 +1108,9 @@ TempoMap::remove_bartime (MusicTimePoint const & tp)
_bartimes.erase (m); _bartimes.erase (m);
remove_point (*m); remove_point (*m);
if (with_reset) {
reset_starting_at (sc); reset_starting_at (sc);
}
} }
void void
@ -1616,7 +1620,7 @@ TempoMap::set_meter (Meter const & t, BBT_Time const & bbt)
} }
void void
TempoMap::remove_meter (MeterPoint const & mp) TempoMap::remove_meter (MeterPoint const & mp, bool with_reset)
{ {
if (_meters.size() < 2) { if (_meters.size() < 2) {
return; return;
@ -1654,7 +1658,9 @@ TempoMap::remove_meter (MeterPoint const & mp)
_meters.erase (m); _meters.erase (m);
remove_point (*m); remove_point (*m);
if (with_reset) {
reset_starting_at (sc); reset_starting_at (sc);
}
} }
Temporal::BBT_Time Temporal::BBT_Time

View file

@ -734,7 +734,7 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible
LIBTEMPORAL_API void change_tempo (TempoPoint&, Tempo const&); LIBTEMPORAL_API void change_tempo (TempoPoint&, Tempo const&);
LIBTEMPORAL_API void set_bartime (BBT_Time const &, timepos_t const &, std::string name = std::string()); LIBTEMPORAL_API void set_bartime (BBT_Time const &, timepos_t const &, std::string name = std::string());
LIBTEMPORAL_API void remove_bartime (MusicTimePoint const & tp); LIBTEMPORAL_API void remove_bartime (MusicTimePoint const & tp, bool with_reset = true);
LIBTEMPORAL_API TempoPoint& set_tempo (Tempo const &, BBT_Time const &); LIBTEMPORAL_API TempoPoint& set_tempo (Tempo const &, BBT_Time const &);
LIBTEMPORAL_API TempoPoint& set_tempo (Tempo const &, timepos_t const &); LIBTEMPORAL_API TempoPoint& set_tempo (Tempo const &, timepos_t const &);
@ -744,8 +744,8 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible
LIBTEMPORAL_API MeterPoint& set_meter (Meter const &, BBT_Time const &); LIBTEMPORAL_API MeterPoint& set_meter (Meter const &, BBT_Time const &);
LIBTEMPORAL_API MeterPoint& set_meter (Meter const &, timepos_t const &); LIBTEMPORAL_API MeterPoint& set_meter (Meter const &, timepos_t const &);
LIBTEMPORAL_API void remove_tempo (TempoPoint const &); LIBTEMPORAL_API void remove_tempo (TempoPoint const &, bool with_reset = true);
LIBTEMPORAL_API void remove_meter (MeterPoint const &); LIBTEMPORAL_API void remove_meter (MeterPoint const &, bool with_reset = true);
/* these are a convenience method that just wrap some odd semantics */ /* these are a convenience method that just wrap some odd semantics */
LIBTEMPORAL_API bool move_tempo (TempoPoint const & point, timepos_t const & destination, bool push = false); LIBTEMPORAL_API bool move_tempo (TempoPoint const & point, timepos_t const & destination, bool push = false);