Use an enum for RoundMode instead of magic numbers.
No functional changes in this one (for easier auditing), but towards having round up/down only if necessary modes, rather than kludging around that situation with a double round as we do currently.
This commit is contained in:
@@ -297,10 +297,9 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
|
||||
void replace_tempo (const TempoSection&, const Tempo&, const Timecode::BBT_Time& where);
|
||||
void replace_meter (const MeterSection&, const Meter&, const Timecode::BBT_Time& where);
|
||||
|
||||
framepos_t round_to_bar (framepos_t frame, int dir);
|
||||
framepos_t round_to_beat (framepos_t frame, int dir);
|
||||
framepos_t round_to_beat_subdivision (framepos_t fr, int sub_num, int dir);
|
||||
framepos_t round_to_tick (framepos_t frame, int dir);
|
||||
framepos_t round_to_bar (framepos_t frame, RoundMode dir);
|
||||
framepos_t round_to_beat (framepos_t frame, RoundMode dir);
|
||||
framepos_t round_to_beat_subdivision (framepos_t fr, int sub_num, RoundMode dir);
|
||||
|
||||
void set_length (framepos_t frames);
|
||||
|
||||
@@ -355,7 +354,7 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
|
||||
BBTPointList::const_iterator bbt_before_or_at (const Timecode::BBT_Time&);
|
||||
BBTPointList::const_iterator bbt_after_or_at (framepos_t);
|
||||
|
||||
framepos_t round_to_type (framepos_t fr, int dir, BBTPointType);
|
||||
framepos_t round_to_type (framepos_t fr, RoundMode dir, BBTPointType);
|
||||
void bbt_time (framepos_t, Timecode::BBT_Time&, const BBTPointList::const_iterator&);
|
||||
framecnt_t bbt_duration_at_unlocked (const Timecode::BBT_Time& when, const Timecode::BBT_Time& bbt, int dir);
|
||||
|
||||
|
||||
@@ -216,6 +216,12 @@ namespace ARDOUR {
|
||||
TrackColor
|
||||
};
|
||||
|
||||
enum RoundMode {
|
||||
RoundDownAlways = -1, ///< Always round down, even if on a division
|
||||
RoundNearest = 0, ///< Round to nearest
|
||||
RoundUpAlways = 1 ///< Always round up, even if on a division
|
||||
};
|
||||
|
||||
class AnyTime {
|
||||
public:
|
||||
enum Type {
|
||||
|
||||
@@ -1223,19 +1223,19 @@ TempoMap::bbt_duration_at_unlocked (const BBT_Time& when, const BBT_Time& bbt, i
|
||||
}
|
||||
|
||||
framepos_t
|
||||
TempoMap::round_to_bar (framepos_t fr, int dir)
|
||||
TempoMap::round_to_bar (framepos_t fr, RoundMode dir)
|
||||
{
|
||||
return round_to_type (fr, dir, Bar);
|
||||
}
|
||||
|
||||
framepos_t
|
||||
TempoMap::round_to_beat (framepos_t fr, int dir)
|
||||
TempoMap::round_to_beat (framepos_t fr, RoundMode dir)
|
||||
{
|
||||
return round_to_type (fr, dir, Beat);
|
||||
}
|
||||
|
||||
framepos_t
|
||||
TempoMap::round_to_beat_subdivision (framepos_t fr, int sub_num, int dir)
|
||||
TempoMap::round_to_beat_subdivision (framepos_t fr, int sub_num, RoundMode dir)
|
||||
{
|
||||
require_map_to (fr);
|
||||
|
||||
@@ -1354,7 +1354,7 @@ TempoMap::round_to_beat_subdivision (framepos_t fr, int sub_num, int dir)
|
||||
}
|
||||
|
||||
framepos_t
|
||||
TempoMap::round_to_type (framepos_t frame, int dir, BBTPointType type)
|
||||
TempoMap::round_to_type (framepos_t frame, RoundMode dir, BBTPointType type)
|
||||
{
|
||||
require_map_to (frame);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user