temporal: hide superclock_t variant of TempoMap::metric_at()
This fixes several callsites that were passing samplepos_t to get a TempoMetric, some of them somewhat significant (e.g. VST plugins that want tempo information). Bad API design on my part, apologies. This commit combines libs/ and gtk2_ardour because the new private status of the ::metric_at() call would be a blocking point for git bisect
This commit is contained in:
parent
12c3daa46b
commit
50232a23a7
|
@ -284,7 +284,7 @@ AutomationController::set_freq_beats(double beats)
|
|||
const ARDOUR::ParameterDescriptor& desc = _controllable->desc();
|
||||
const ARDOUR::Session& session = _controllable->session();
|
||||
const samplepos_t pos = session.transport_sample();
|
||||
const Temporal::Tempo& tempo = Temporal::TempoMap::use()->metric_at (pos).tempo();
|
||||
const Temporal::Tempo& tempo = Temporal::TempoMap::use()->metric_at (timepos_t (pos)).tempo();
|
||||
const double bpm = tempo.note_types_per_minute();
|
||||
const double bps = bpm / 60.0;
|
||||
const double freq = bps / beats;
|
||||
|
|
|
@ -623,7 +623,7 @@ Editor::edit_meter_section (Temporal::MeterPoint& section)
|
|||
return;
|
||||
}
|
||||
|
||||
Temporal::TempoMetric tm (TempoMap::use()->metric_at (section.sclock()));
|
||||
Temporal::TempoMetric tm (TempoMap::use()->metric_at (timepos_t (section.sample(TEMPORAL_SAMPLE_RATE))));
|
||||
Temporal::MeterPoint const * mpp (TempoMap::use()->previous_meter (tm.meter()));
|
||||
|
||||
double bpb = meter_dialog.get_bpb ();
|
||||
|
@ -702,7 +702,7 @@ Editor::edit_tempo_section (TempoPoint& section)
|
|||
return;
|
||||
}
|
||||
|
||||
Temporal::TempoMetric tm (TempoMap::use()->metric_at (section.sclock()));
|
||||
Temporal::TempoMetric tm (TempoMap::use()->metric_at (timepos_t (section.sample (TEMPORAL_SAMPLE_RATE))));
|
||||
Temporal::TempoPoint const * tpp (TempoMap::use()->previous_tempo (tm.tempo()));
|
||||
|
||||
double bpm = tempo_dialog.get_bpm ();
|
||||
|
|
|
@ -145,7 +145,7 @@ VerboseCursor::set_duration (samplepos_t start, samplepos_t end)
|
|||
Timecode::Time timecode;
|
||||
Temporal::BBT_Time sbbt;
|
||||
Temporal::BBT_Time ebbt;
|
||||
Meter const & meter_at_start (TempoMap::use()->metric_at (start).meter());
|
||||
Meter const & meter_at_start (TempoMap::use()->metric_at (timepos_t (start)).meter());
|
||||
|
||||
if (_editor->_session == 0) {
|
||||
return;
|
||||
|
|
|
@ -2767,7 +2767,7 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
|
|||
samplepos_t start0 = std::max (samplepos_t (0), start);
|
||||
|
||||
TempoMap::SharedPtr tmap (TempoMap::use());
|
||||
TempoMetric metric (tmap->metric_at (samples_to_superclock (start0, TEMPORAL_SAMPLE_RATE)));
|
||||
TempoMetric metric (tmap->metric_at (timepos_t (start0)));
|
||||
|
||||
TempoMapPoints tempo_map_points;
|
||||
tmap->get_grid (tempo_map_points,
|
||||
|
|
|
@ -155,7 +155,7 @@ MIDIClock_TransportMaster::pre_process (MIDI::pframes_t nframes, samplepos_t now
|
|||
void
|
||||
MIDIClock_TransportMaster::calculate_one_ppqn_in_samples_at(samplepos_t time)
|
||||
{
|
||||
const Temporal::TempoMetric& metric = Temporal::TempoMap::use()->metric_at (time);
|
||||
const Temporal::TempoMetric& metric = Temporal::TempoMap::use()->metric_at (timepos_t (time));
|
||||
const double samples_per_quarter_note = metric.tempo().samples_per_quarter_note (ENGINE->sample_rate());
|
||||
|
||||
one_ppqn_in_samples = samples_per_quarter_note / double (ppqn);
|
||||
|
|
|
@ -2128,7 +2128,7 @@ Session::preroll_samples (samplepos_t pos) const
|
|||
{
|
||||
const float pr = Config->get_preroll_seconds();
|
||||
if (pos >= 0 && pr < 0) {
|
||||
Temporal::TempoMetric const & metric (TempoMap::use()->metric_at (pos));
|
||||
Temporal::TempoMetric const & metric (TempoMap::use()->metric_at (timepos_t (pos)));
|
||||
return metric.samples_per_bar (sample_rate()) * -pr;
|
||||
}
|
||||
if (pr < 0) {
|
||||
|
@ -7615,7 +7615,7 @@ Session::maybe_update_tempo_from_midiclock_tempo (float bpm)
|
|||
TempoMap::WritableSharedPtr tmap (TempoMap::write_copy());
|
||||
|
||||
if (tmap->n_tempos() == 1) {
|
||||
Temporal::TempoMetric const & metric (tmap->metric_at (0));
|
||||
Temporal::TempoMetric const & metric (tmap->metric_at (timepos_t (0)));
|
||||
if (fabs (metric.tempo().note_types_per_minute() - bpm) >= Config->get_midi_clock_resolution()) {
|
||||
/* fix note type as quarters, because that's how MIDI clock works */
|
||||
tmap->change_tempo (metric.get_editable_tempo(), Tempo (bpm, bpm, 4.0));
|
||||
|
|
|
@ -560,7 +560,7 @@ Session::start_transport (bool after_loop)
|
|||
* - use [fixed] tempo/meter at _transport_sample
|
||||
* - calc duration of 1 bar + time-to-beat before or at transport_sample
|
||||
*/
|
||||
TempoMetric const & tempometric = tmap->metric_at (_transport_sample);
|
||||
TempoMetric const & tempometric = tmap->metric_at (timepos_t (_transport_sample));
|
||||
|
||||
const double num = tempometric.divisions_per_bar ();
|
||||
/* XXX possible optimization: get meter and BBT time in one call */
|
||||
|
|
|
@ -317,7 +317,7 @@ intptr_t Session::vst_callback (
|
|||
// returns tempo (in bpm * 10000) at sample sample location passed in <value>
|
||||
if (session) {
|
||||
TempoMap::SharedPtr tmap (TempoMap::fetch());
|
||||
const Tempo& t (tmap->metric_at (value).tempo());
|
||||
const Tempo& t (tmap->metric_at (timepos_t (value)).tempo());
|
||||
return t.quarter_notes_per_minute() * 1000;
|
||||
} else {
|
||||
return 0;
|
||||
|
|
|
@ -218,7 +218,7 @@ out:
|
|||
double
|
||||
MidiClockTicker::one_ppqn_in_samples (samplepos_t transport_position) const
|
||||
{
|
||||
Tempo const & tempo (TempoMap::use()->metric_at (transport_position).tempo());
|
||||
Tempo const & tempo (TempoMap::use()->metric_at (timepos_t (transport_position)).tempo());
|
||||
const double samples_per_quarter_note = tempo.samples_per_quarter_note (_session.nominal_sample_rate());
|
||||
return samples_per_quarter_note / 24.0;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ using namespace Temporal;
|
|||
double
|
||||
ArdourTransport::tempo () const
|
||||
{
|
||||
const Tempo& tempo (TempoMap::fetch()->metric_at (0).tempo());
|
||||
const Tempo& tempo (TempoMap::fetch()->metric_at (timepos_t (0)).tempo());
|
||||
return tempo.note_types_per_minute ();
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ ArdourTransport::set_tempo (double bpm)
|
|||
|
||||
TempoMap::WritableSharedPtr tmap (TempoMap::write_copy());
|
||||
|
||||
Tempo tempo (bpm, tmap->metric_at (0).tempo().note_type ());
|
||||
Tempo tempo (bpm, tmap->metric_at (timepos_t (0)).tempo().note_type ());
|
||||
|
||||
tmap->set_tempo (tempo, timepos_t());
|
||||
TempoMap::update (tmap);
|
||||
|
|
|
@ -814,7 +814,6 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible
|
|||
Meter at the given time. If can_match is false, the TempoMetric will
|
||||
only refer to the Tempo or Metric preceding the given time.
|
||||
*/
|
||||
LIBTEMPORAL_API TempoMetric metric_at (superclock_t, bool can_match = true) const;
|
||||
LIBTEMPORAL_API TempoMetric metric_at (Beats const &, bool can_match = true) const;
|
||||
LIBTEMPORAL_API TempoMetric metric_at (BBT_Argument const &, bool can_match = true) const;
|
||||
|
||||
|
@ -1091,6 +1090,13 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible
|
|||
return _get_tempo_and_meter<const_traits<Beats const &, Beats> > (t, m, &Point::beats, b, _points.begin(), _points.end(), &_tempos.front(), &_meters.front(), can_match, ret_iterator_after_not_at);
|
||||
}
|
||||
|
||||
/* This is private, and should not be callable from outside the map
|
||||
because of potential confusion between samplepos_t and
|
||||
superclock_t. The timepos_t variant of ::metric_at() handles any
|
||||
samplepos_t-passing call.
|
||||
*/
|
||||
TempoMetric metric_at (superclock_t, bool can_match = true) const;
|
||||
|
||||
/* parsing legacy tempo maps */
|
||||
|
||||
struct LegacyTempoState
|
||||
|
|
Loading…
Reference in New Issue