temporal: fix a bug in BBT_Time::round_up_to_bar()
Also remove Meter:: versions of related methods, because they are not necessary. We only need metrical information for operations like ::round_to_bar()
This commit is contained in:
parent
076ad9a9b6
commit
cc6a437faf
@ -23,6 +23,20 @@
|
||||
|
||||
using namespace Temporal;
|
||||
|
||||
BBT_Time
|
||||
BBT_Time::round_up_to_bar() const
|
||||
{
|
||||
if (ticks == 0 && beats == 1) {
|
||||
return *this;
|
||||
}
|
||||
BBT_Time b = round_up_to_beat ();
|
||||
if (b.beats > 1) {
|
||||
b.bars += 1;
|
||||
b.beats = 1;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
BBT_Offset::BBT_Offset (double dbeats)
|
||||
{
|
||||
/* NOTE: this does not construct a BBT time in a canonical form,
|
||||
|
@ -49,12 +49,12 @@ Beats::round_to_subdivision (int subdivision, RoundMode dir) const {
|
||||
if (dir == RoundDownAlways && bbt.ticks == 0) {
|
||||
bbt = metric.bbt_subtract (bbt, Temporal::BBT_Offset (0, 0, 1));
|
||||
}
|
||||
bbt = metric.meter().round_down_to_bar (bbt);
|
||||
bbt = bbt.round_down_to_bar ();
|
||||
} if (dir > 0) {
|
||||
if (dir == RoundUpAlways && bbt.ticks == 0) {
|
||||
bbt.ticks += 1;
|
||||
}
|
||||
bbt = metric.meter().round_up_to_bar (bbt);
|
||||
bbt = bbt.round_up_to_bar ();
|
||||
} else {
|
||||
bbt = metric.meter().round_to_bar (bbt);
|
||||
}
|
||||
|
@ -355,33 +355,6 @@ Meter::round_to_bar (Temporal::BBT_Time const & bbt) const
|
||||
return BBT_Time (bbt.bars, 1, 0);
|
||||
}
|
||||
|
||||
Temporal::BBT_Time
|
||||
Meter::round_up_to_bar (Temporal::BBT_Time const & bbt) const
|
||||
{
|
||||
if (bbt.ticks == 0 && bbt.beats == 1) {
|
||||
return bbt;
|
||||
}
|
||||
BBT_Time b = bbt.round_up_to_beat ();
|
||||
if (b.beats > 1) {
|
||||
b.bars += 1;
|
||||
b.beats = 1;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
Temporal::BBT_Time
|
||||
Meter::round_down_to_bar (Temporal::BBT_Time const & bbt) const
|
||||
{
|
||||
if (bbt.ticks == 0 && bbt.beats == 1) {
|
||||
return bbt;
|
||||
}
|
||||
BBT_Time b = bbt.round_down_to_beat ();
|
||||
if (b.beats > 1) {
|
||||
b.beats = 1;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
Temporal::BBT_Time
|
||||
Meter::round_up_to_beat (Temporal::BBT_Time const & bbt) const
|
||||
{
|
||||
@ -1322,9 +1295,9 @@ TempoMap::move_meter (MeterPoint const & mp, timepos_t const & when, bool earlie
|
||||
bbt = metric.bbt_at (beats);
|
||||
|
||||
if (round_up) {
|
||||
bbt = metric.meter().round_up_to_bar (bbt);
|
||||
bbt = bbt.round_up_to_bar ();
|
||||
} else {
|
||||
bbt = metric.meter().round_down_to_bar (bbt);
|
||||
bbt = bbt.round_down_to_bar ();
|
||||
}
|
||||
|
||||
for (t = _tempos.begin(), prev_t = _tempos.end(); t != _tempos.end() && t->bbt() < bbt; ++t) { prev_t = t; }
|
||||
|
@ -119,7 +119,7 @@ struct LIBTEMPORAL_API BBT_Time
|
||||
* next bar time.
|
||||
*/
|
||||
|
||||
BBT_Time round_up_to_bar () const { return beats > 1 ? BBT_Time (bars+1, 1, 0) : BBT_Time (bars, 1, 0); }
|
||||
BBT_Time round_up_to_bar () const;
|
||||
BBT_Time round_down_to_bar () const { return BBT_Time (bars, 1, 0); }
|
||||
BBT_Time next_bar () const { return (bars == -1) ? BBT_Time (1, 1, 0) : BBT_Time (bars+1, 1, 0); }
|
||||
BBT_Time prev_bar () const { return (bars == 1) ? BBT_Time (-1, 1, 0) : BBT_Time (bars-1, 1, 0); }
|
||||
|
@ -332,10 +332,7 @@ class LIBTEMPORAL_API Meter {
|
||||
BBT_Time bbt_add (BBT_Time const & bbt, BBT_Offset const & add) const;
|
||||
BBT_Time bbt_subtract (BBT_Time const & bbt, BBT_Offset const & sub) const;
|
||||
BBT_Time round_to_bar (BBT_Time const &) const;
|
||||
BBT_Time round_down_to_bar (BBT_Time const &) const;
|
||||
BBT_Time round_up_to_bar (BBT_Time const &) const;
|
||||
BBT_Time round_up_to_beat (BBT_Time const &) const;
|
||||
BBT_Time round_to_beat (BBT_Time const &) const;
|
||||
Beats to_quarters (BBT_Offset const &) const;
|
||||
|
||||
XMLNode& get_state () const;
|
||||
|
Loading…
Reference in New Issue
Block a user