mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 14:54:56 +01:00
Revert "tempo map: use lookup tables to speed up time conversions"
This reverts commit 644ebe37a8.
Adding entries to the lookup table is (a) not thread safe (b) not appropriate
from RT context.
This commit is contained in:
parent
cfb31e3257
commit
5b6bc3f358
1 changed files with 16 additions and 69 deletions
|
|
@ -489,13 +489,6 @@ TempoPoint::superclock_at (Temporal::Beats const & qn) const
|
|||
assert (qn >= _quarters);
|
||||
}
|
||||
|
||||
bool found;
|
||||
superclock_t sc = _map->superclock_lookup (qn, found);
|
||||
|
||||
if (found) {
|
||||
return sc;
|
||||
}
|
||||
|
||||
if (!actually_ramped()) {
|
||||
/* not ramped, use linear */
|
||||
const Beats delta = qn - _quarters;
|
||||
|
|
@ -503,36 +496,36 @@ TempoPoint::superclock_at (Temporal::Beats const & qn) const
|
|||
return _sclock + (spqn * delta.get_beats()) + int_div_round ((spqn * delta.get_ticks()), superclock_t (Temporal::ticks_per_beat));
|
||||
}
|
||||
|
||||
superclock_t r;
|
||||
const double log_expr = superclocks_per_quarter_note() * _omega * DoubleableBeats (qn - _quarters).to_double();
|
||||
|
||||
if (log_expr < -1) {
|
||||
sc = _sclock + llrint (log (-log_expr - 1.0) / -_omega);
|
||||
r = _sclock + llrint (log (-log_expr - 1.0) / -_omega);
|
||||
|
||||
if (sc < 0) {
|
||||
if (r < 0) {
|
||||
std::cerr << "CASE 1: " << *this << endl << " scpqn = " << superclocks_per_quarter_note() << std::endl;
|
||||
std::cerr << " for " << qn << " @ " << _quarters << " | " << _sclock << " + log (" << log_expr << ") "
|
||||
<< log (-log_expr - 1.0)
|
||||
<< " - omega = " << -_omega
|
||||
<< " => "
|
||||
<< sc << std::endl;
|
||||
<< r << std::endl;
|
||||
abort ();
|
||||
}
|
||||
|
||||
} else {
|
||||
sc = _sclock + llrint (log1p (log_expr) / _omega);
|
||||
r = _sclock + llrint (log1p (log_expr) / _omega);
|
||||
|
||||
if (sc < 0) {
|
||||
if (r < 0) {
|
||||
std::cerr << "CASE 2: scpqn = " << superclocks_per_quarter_note() << std::endl;
|
||||
std::cerr << " for " << qn << " @ " << _quarters << " | " << _sclock << " + log1p (" << superclocks_per_quarter_note() * _omega * DoubleableBeats (qn - _quarters).to_double() << " = "
|
||||
<< log1p (superclocks_per_quarter_note() * _omega * DoubleableBeats (qn - _quarters).to_double())
|
||||
<< " => "
|
||||
<< sc << std::endl;
|
||||
<< r << std::endl;
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
_map->beat_to_superclock_store (qn, sc);
|
||||
return sc;
|
||||
return r;
|
||||
}
|
||||
|
||||
superclock_t
|
||||
|
|
@ -564,13 +557,6 @@ TempoPoint::quarters_at_superclock (superclock_t sc) const
|
|||
return std::numeric_limits<Beats>::max();
|
||||
}
|
||||
|
||||
bool found;
|
||||
Beats beats = _map->beat_lookup (sc, found);
|
||||
|
||||
if (found) {
|
||||
return beats;
|
||||
}
|
||||
|
||||
if (!actually_ramped()) {
|
||||
|
||||
// assert (sc >= _sclock);
|
||||
|
|
@ -603,16 +589,11 @@ TempoPoint::quarters_at_superclock (superclock_t sc) const
|
|||
return std::numeric_limits<Beats>::max();
|
||||
}
|
||||
|
||||
_map->superclock_to_beat_store (sc, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
const double b = (exp (_omega * (sc - _sclock)) - 1) / (superclocks_per_quarter_note() * _omega);
|
||||
beats = _quarters + Beats::from_double (b);
|
||||
|
||||
_map->superclock_to_beat_store (sc, beats);
|
||||
|
||||
return beats;
|
||||
return _quarters + Beats::from_double (b);
|
||||
}
|
||||
|
||||
MeterPoint::MeterPoint (TempoMap const & map, XMLNode const & node)
|
||||
|
|
@ -644,9 +625,7 @@ MeterPoint::quarters_at (Temporal::BBT_Time const & bbt) const
|
|||
Temporal::BBT_Time
|
||||
MeterPoint::bbt_at (Temporal::Beats const & qn) const
|
||||
{
|
||||
BBT_Time bbt (bbt_add (_bbt, Temporal::BBT_Offset (0, 0, (qn - _quarters).to_ticks())));
|
||||
_map->beat_to_bbt_store (qn, bbt);
|
||||
return bbt;
|
||||
return bbt_add (_bbt, Temporal::BBT_Offset (0, 0, (qn - _quarters).to_ticks()));
|
||||
}
|
||||
|
||||
XMLNode&
|
||||
|
|
@ -695,13 +674,6 @@ TempoMetric::bbt_at (timepos_t const & pos) const
|
|||
|
||||
superclock_t sc = pos.superclocks();
|
||||
|
||||
bool found;
|
||||
BBT_Time bbt = _meter->map().bbt_lookup (sc, found);
|
||||
|
||||
if (found) {
|
||||
return BBT_Argument (reftime(), bbt);
|
||||
}
|
||||
|
||||
/* Use the later of the tempo or meter as the reference point to
|
||||
* compute the BBT distance. All map points are fully defined by all 3
|
||||
* time types, but we need the latest one to avoid incorrect
|
||||
|
|
@ -732,10 +704,9 @@ TempoMetric::bbt_at (timepos_t const & pos) const
|
|||
|
||||
DEBUG_TRACE (DEBUG::TemporalMap, string_compose ("BBT offset from %3 @ %1: %2\n", (_tempo->beats() < _meter->beats() ? _meter->bbt() : _tempo->bbt()), bbt_offset,
|
||||
(_tempo->beats() < _meter->beats() ? "meter" : "tempo")));
|
||||
timepos_t ref (std::min (_meter->sclock(), _tempo->sclock()));
|
||||
|
||||
bbt = _meter->bbt_add (reference_point->bbt(), bbt_offset);
|
||||
_meter->map().superclock_to_bbt_store (sc, bbt);
|
||||
return BBT_Argument (reftime(), bbt);
|
||||
return BBT_Argument (ref, _meter->bbt_add (reference_point->bbt(), bbt_offset));
|
||||
}
|
||||
|
||||
superclock_t
|
||||
|
|
@ -896,8 +867,6 @@ TempoMap::set_tempo (Tempo const & t, timepos_t const & time)
|
|||
|
||||
DEBUG_TRACE (DEBUG::TemporalMap, string_compose ("Set tempo @ %1 to %2\n", time, t));
|
||||
|
||||
drop_lookup_table ();
|
||||
|
||||
if (time.is_beats()) {
|
||||
|
||||
|
||||
|
|
@ -948,8 +917,6 @@ TempoMap::set_tempo (Tempo const & t, timepos_t const & time)
|
|||
void
|
||||
TempoMap::core_add_point (Point* pp)
|
||||
{
|
||||
drop_lookup_table ();
|
||||
|
||||
Points::iterator p;
|
||||
const Beats beats_limit = pp->beats();
|
||||
|
||||
|
|
@ -960,8 +927,6 @@ TempoMap::core_add_point (Point* pp)
|
|||
TempoPoint*
|
||||
TempoMap::core_add_tempo (TempoPoint* tp, bool& replaced)
|
||||
{
|
||||
drop_lookup_table ();
|
||||
|
||||
Tempos::iterator t;
|
||||
const superclock_t sclock_limit = tp->sclock();
|
||||
const Beats beats_limit = tp->beats ();
|
||||
|
|
@ -988,8 +953,6 @@ TempoMap::core_add_tempo (TempoPoint* tp, bool& replaced)
|
|||
MeterPoint*
|
||||
TempoMap::core_add_meter (MeterPoint* mp, bool& replaced)
|
||||
{
|
||||
drop_lookup_table ();
|
||||
|
||||
Meters::iterator m;
|
||||
const superclock_t sclock_limit = mp->sclock();
|
||||
const Beats beats_limit = mp->beats ();
|
||||
|
|
@ -1013,8 +976,6 @@ TempoMap::core_add_meter (MeterPoint* mp, bool& replaced)
|
|||
MusicTimePoint*
|
||||
TempoMap::core_add_bartime (MusicTimePoint* mtp, bool& replaced)
|
||||
{
|
||||
drop_lookup_table ();
|
||||
|
||||
MusicTimes::iterator m;
|
||||
const superclock_t sclock_limit = mtp->sclock();
|
||||
|
||||
|
|
@ -1060,8 +1021,6 @@ TempoMap::remove_tempo (TempoPoint const & tp, bool with_reset)
|
|||
return;
|
||||
}
|
||||
|
||||
drop_lookup_table ();
|
||||
|
||||
superclock_t sc (tp.sclock());
|
||||
Tempos::iterator t;
|
||||
|
||||
|
|
@ -1179,8 +1138,6 @@ TempoMap::remove_bartime (MusicTimePoint const & tp, bool with_reset)
|
|||
return;
|
||||
}
|
||||
|
||||
drop_lookup_table ();
|
||||
|
||||
_bartimes.erase (m);
|
||||
remove_point (*m);
|
||||
if (with_reset) {
|
||||
|
|
@ -1214,8 +1171,6 @@ TempoMap::remove_point (Point const & point)
|
|||
void
|
||||
TempoMap::reset_starting_at (superclock_t sc)
|
||||
{
|
||||
drop_lookup_table ();
|
||||
|
||||
DEBUG_TRACE (DEBUG::MapReset, string_compose ("reset starting at %1\n", sc));
|
||||
#ifndef NDEBUG
|
||||
if (DEBUG_ENABLED(DEBUG::MapReset)) {
|
||||
|
|
@ -1461,8 +1416,6 @@ TempoMap::move_meter (MeterPoint const & mp, timepos_t const & when, bool earlie
|
|||
return false;
|
||||
}
|
||||
|
||||
drop_lookup_table ();
|
||||
|
||||
const superclock_t old_sc = mp.sclock();
|
||||
|
||||
/* reset position of this meter */
|
||||
|
|
@ -1565,8 +1518,6 @@ TempoMap::move_tempo (TempoPoint const & tp, timepos_t const & when, bool push)
|
|||
return false;
|
||||
}
|
||||
|
||||
drop_lookup_table ();
|
||||
|
||||
/* If the previous tempo is ramped, we need to recompute its omega
|
||||
* constant to cover the (new) duration of the ramp.
|
||||
*/
|
||||
|
|
@ -1754,13 +1705,11 @@ TempoMap::bbt_at (timepos_t const & pos) const
|
|||
}
|
||||
|
||||
Temporal::BBT_Argument
|
||||
TempoMap::bbt_at (superclock_t sc) const
|
||||
TempoMap::bbt_at (superclock_t s) const
|
||||
{
|
||||
TempoMetric metric (metric_at (sc));
|
||||
TempoMetric metric (metric_at (s));
|
||||
timepos_t ref (std::min (metric.tempo().sclock(), metric.meter().sclock()));
|
||||
BBT_Time bbt (metric.bbt_at (timepos_t::from_superclock (sc)));
|
||||
superclock_to_bbt_store (sc, bbt);
|
||||
return BBT_Argument (ref, bbt);
|
||||
return BBT_Argument (ref, metric.bbt_at (timepos_t::from_superclock (s)));
|
||||
}
|
||||
|
||||
Temporal::BBT_Argument
|
||||
|
|
@ -1768,9 +1717,7 @@ TempoMap::bbt_at (Temporal::Beats const & qn) const
|
|||
{
|
||||
TempoMetric metric (metric_at (qn));
|
||||
timepos_t ref (std::min (metric.tempo().sclock(), metric.meter().sclock()));
|
||||
BBT_Time bbt (metric.bbt_at (qn));
|
||||
beat_to_bbt_store (qn, bbt);
|
||||
return BBT_Argument (ref, bbt);
|
||||
return BBT_Argument (ref, metric.bbt_at (qn));
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue