mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 14:54:56 +01:00
tempomap: provide improved reftime() method for TempoMetric
This now looks backwards in time for a BBT_Marker or the start of the tempo map, whichever comes first.
This commit is contained in:
parent
6cde958480
commit
92bd8461ca
2 changed files with 34 additions and 1 deletions
|
|
@ -636,6 +636,36 @@ MeterPoint::get_state () const
|
|||
return base;
|
||||
}
|
||||
|
||||
timepos_t
|
||||
TempoMetric::reftime() const
|
||||
{
|
||||
TempoMap::SharedPtr tmap (TempoMap::use ());
|
||||
return tmap->reftime (*this);
|
||||
}
|
||||
|
||||
timepos_t
|
||||
TempoMap::reftime (TempoMetric const &tm) const
|
||||
{
|
||||
Points::const_iterator pi;
|
||||
|
||||
if (tm.meter().sclock() < tm.tempo().sclock()) {
|
||||
pi = _points.s_iterator_to (*(static_cast<const Point*> (&tm.meter())));
|
||||
} else {
|
||||
pi = _points.s_iterator_to (*(static_cast<const Point*> (&tm.tempo())));
|
||||
}
|
||||
|
||||
/* Walk backwards through points to find a BBT markers, or the start */
|
||||
|
||||
while (pi != _points.begin()) {
|
||||
if (dynamic_cast<const MusicTimePoint*> (&*pi)) {
|
||||
break;
|
||||
}
|
||||
--pi;
|
||||
}
|
||||
|
||||
return timepos_t (pi->sclock());
|
||||
}
|
||||
|
||||
Temporal::BBT_Argument
|
||||
TempoMetric::bbt_at (timepos_t const & pos) const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -470,7 +470,7 @@ class LIBTEMPORAL_API TempoMetric
|
|||
TempoMetric (TempoPoint const & t, MeterPoint const & m) : _tempo (&t), _meter (&m) {}
|
||||
virtual ~TempoMetric () {}
|
||||
|
||||
timepos_t reftime() const { return timepos_t (std::min (_tempo->sclock(), _meter->sclock())); }
|
||||
timepos_t reftime() const;
|
||||
|
||||
TempoPoint const & tempo() const { return *_tempo; }
|
||||
MeterPoint const & meter() const { return *_meter; }
|
||||
|
|
@ -711,6 +711,9 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible
|
|||
|
||||
LIBTEMPORAL_API static WritableSharedPtr fetch_writable() { _tempo_map_p = write_copy(); return _tempo_map_p; }
|
||||
|
||||
/* not part of public API */
|
||||
timepos_t reftime(TempoMetric const &) const;
|
||||
|
||||
/* and now on with the rest of the show ... */
|
||||
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue