mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 06:44:57 +01:00
clean up/improve API used in 5ebf8152e
This commit is contained in:
parent
ca9f41c4b2
commit
99ba22a4a4
2 changed files with 16 additions and 4 deletions
|
|
@ -346,6 +346,12 @@ Meter::bbt_subtract (Temporal::BBT_Time const & bbt, Temporal::BBT_Offset const
|
|||
return Temporal::BBT_Time (r.bars, r.beats, r.ticks);
|
||||
}
|
||||
|
||||
Temporal::Beats
|
||||
Meter::round_to_beat (Temporal::Beats const & b) const
|
||||
{
|
||||
return b.round_to_multiple (Beats::ticks (ticks_per_grid()));
|
||||
}
|
||||
|
||||
Temporal::BBT_Time
|
||||
Meter::round_to_bar (Temporal::BBT_Time const & bbt) const
|
||||
{
|
||||
|
|
@ -1353,12 +1359,15 @@ TempoMap::set_tempo (Tempo const & t, timepos_t const & time)
|
|||
|
||||
/* tempo changes are required to be on-beat */
|
||||
|
||||
TempoMetric metric (metric_at (time.beats(), false));
|
||||
Beats on_beat = time.beats().round_to_multiple (Beats::ticks (metric.meter().ticks_per_grid()));
|
||||
Beats on_beat = metric_at (time.beats(), false).round_to_beat (time.beats());
|
||||
superclock_t sc;
|
||||
BBT_Time bbt;
|
||||
|
||||
metric = metric_at (on_beat, false);
|
||||
/* the metric for the on-beat position may be different than
|
||||
* the one for the raw time, so look it up again.
|
||||
*/
|
||||
|
||||
TempoMetric metric (metric_at (on_beat, false));
|
||||
|
||||
bbt = metric.bbt_at (on_beat);
|
||||
sc = metric.superclock_at (on_beat);
|
||||
|
|
@ -1376,7 +1385,7 @@ TempoMap::set_tempo (Tempo const & t, timepos_t const & time)
|
|||
|
||||
/* tempo changes must be on beat */
|
||||
|
||||
beats = tm.quarters_at_superclock (sc).round_to_multiple (Beats::ticks (tm.meter().ticks_per_grid()));
|
||||
beats = tm.round_to_beat (tm.quarters_at_superclock (sc));
|
||||
bbt = tm.bbt_at (beats);
|
||||
|
||||
/* recompute superclock position of rounded beat */
|
||||
|
|
|
|||
|
|
@ -310,6 +310,8 @@ class LIBTEMPORAL_API Meter {
|
|||
BBT_Time round_to_beat (BBT_Time const &) const;
|
||||
Beats to_quarters (BBT_Offset const &) const;
|
||||
|
||||
Beats round_to_beat (Beats const &) const;
|
||||
|
||||
XMLNode& get_state () const;
|
||||
int set_state (XMLNode const&, int version);
|
||||
|
||||
|
|
@ -472,6 +474,7 @@ class LIBTEMPORAL_API TempoMetric
|
|||
BBT_Argument bbt_subtract (BBT_Time const & bbt, BBT_Offset const & sub) const { return BBT_Argument (reftime(), _meter->bbt_subtract (bbt, sub)); }
|
||||
BBT_Argument round_to_bar (BBT_Time const & bbt) const { return BBT_Argument (reftime(), _meter->round_to_bar (bbt)); }
|
||||
Beats to_quarters (BBT_Offset const & bbo) const { return _meter->to_quarters (bbo); }
|
||||
Beats round_to_beat (Beats const & b) const { return _meter->round_to_beat (b); }
|
||||
|
||||
/* combination methods that require both tempo and meter information */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue