new_grid: Rewrite of Snap and Grid. (squashed commit)
[ardour.git] / libs / ardour / ardour / types.h
index d3ed94e552bc57815eb656df541d5b8bdcbb355c..352c20ae9bdf55dccc27b46f0c2a4fe04990f202 100644 (file)
@@ -31,8 +31,9 @@
 
 #include <inttypes.h>
 
-#include "timecode/bbt_time.h"
-#include "timecode/time.h"
+#include "temporal/bbt_time.h"
+#include "temporal/time.h"
+#include "temporal/types.h"
 
 #include "pbd/id.h"
 
@@ -43,6 +44,9 @@
 
 #include <map>
 
+using Temporal::max_samplepos;
+using Temporal::max_samplecnt;
+
 #if __GNUC__ < 3
 typedef int intptr_t;
 #endif
@@ -65,23 +69,11 @@ namespace ARDOUR {
        typedef uint64_t microseconds_t;
        typedef uint32_t pframes_t;
 
-       /* Any position measured in audio samples.
-          Assumed to be non-negative but not enforced.
-       */
-       typedef int64_t samplepos_t;
-
-       /* Any distance from a given samplepos_t.
-          Maybe positive or negative.
-       */
-       typedef int64_t sampleoffset_t;
-
-       /* Any count of audio samples.
-          Assumed to be positive but not enforced.
-       */
-       typedef int64_t samplecnt_t;
+       /* rebind Temporal position types into ARDOUR namespace */
+       typedef Temporal::samplecnt_t samplecnt_t;
+       typedef Temporal::samplepos_t samplepos_t;
+       typedef Temporal::sampleoffset_t sampleoffset_t;
 
-       static const samplepos_t max_samplepos = INT64_MAX;
-       static const samplecnt_t max_samplecnt = INT64_MAX;
        static const layer_t    max_layer    = UINT32_MAX;
 
        // a set of (time) intervals: first of pair is the offset of the start within the region, second is the offset of the end
@@ -246,6 +238,11 @@ namespace ARDOUR {
                RoundUpMaybe    = 2    ///< Round up only if necessary
        };
 
+       enum SnapPref {
+               SnapToAny    = 0,   ///< Snaps to the closest of ( snap prefs, grid quantization )
+               SnapToGrid   = 1,   ///< Prefer snapping to the closest grid quantization, if a Grid selection is enabled
+       };
+
        class AnyTime {
        public:
                enum Type {
@@ -470,6 +467,12 @@ namespace ARDOUR {
                AFLFromAfterProcessors
        };
 
+       enum ClockDeltaMode {
+               NoDelta,
+               DeltaEditPoint,
+               DeltaOriginMarker
+       };
+
        enum DenormalModel {
                DenormalNone,
                DenormalFTZ,
@@ -720,38 +723,8 @@ namespace ARDOUR {
 
 } // namespace ARDOUR
 
-static inline ARDOUR::samplepos_t
-session_sample_to_track_sample (ARDOUR::samplepos_t session_sample, double speed)
-{
-       long double result = (long double) session_sample * (long double) speed;
-
-       if (result >= (long double) ARDOUR::max_samplepos) {
-               return ARDOUR::max_samplepos;
-       } else if (result <= (long double) (ARDOUR::max_samplepos) * (ARDOUR::samplepos_t)(-1)) {
-               return (ARDOUR::max_samplepos * (ARDOUR::samplepos_t)(-1));
-       } else {
-               return result;
-       }
-}
-
-static inline ARDOUR::samplepos_t
-track_sample_to_session_sample (ARDOUR::samplepos_t track_sample, double speed)
-{
-       /* NB - do we need a check for speed == 0 ??? */
-       long double result = (long double) track_sample / (long double) speed;
-
-       if (result >= (long double) ARDOUR::max_samplepos) {
-               return ARDOUR::max_samplepos;
-       } else if (result <= (long double) (ARDOUR::max_samplepos) * (ARDOUR::samplepos_t)(-1)) {
-               return (ARDOUR::max_samplepos * (ARDOUR::samplepos_t)(-1));
-       } else {
-               return result;
-       }
-}
-
 /* for now, break the rules and use "using" to make this "global" */
 
 using ARDOUR::samplepos_t;
 
-
 #endif /* __ardour_types_h__ */