summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-11-16 01:05:21 -0500
committerDavid Robillard <d@drobilla.net>2014-11-16 22:35:45 -0500
commitfd9ccc7058cf7cfadbfa1dfb9676e2de3a14e1b0 (patch)
treeb65c03818c9eded429651ca621773d728f9e1976 /libs
parent9c5e63bcc69290e1df84ea345b1899a241b7655e (diff)
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.
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/tempo.h9
-rw-r--r--libs/ardour/ardour/types.h6
-rw-r--r--libs/ardour/tempo.cc8
3 files changed, 14 insertions, 9 deletions
diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h
index 8fa5ed45a0..15cd1662f0 100644
--- a/libs/ardour/ardour/tempo.h
+++ b/libs/ardour/ardour/tempo.h
@@ -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);
diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h
index 165afd0dd9..1b0ba5ea3c 100644
--- a/libs/ardour/ardour/types.h
+++ b/libs/ardour/ardour/types.h
@@ -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 {
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index 6f3f734116..77128bd0c2 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -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);