summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour/types.h
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2017-01-27 00:41:17 +1100
committernick_m <mainsbridge@gmail.com>2017-02-04 22:57:36 +1100
commit59daffea1d78cb55b35fe19c135cc4ab472bd01d (patch)
tree45e514f2e4f5a1935e360fd4fa3e2475ec217006 /libs/ardour/ardour/types.h
parenta21a414615505269bf770ad2358482e698e841af (diff)
rework snap
snap now fills in a struct (MusicFrame) which contins a snapped frame along with a music divisor. this gives useful information wrt magnetic snap which may or may not have rounded to an exact musical position. region position may now be set musically (using quarter notes for now). this patch fixes several problems in the current code: - dragging a list of music-locked regions now maintains correct musical offsets within the list. - splitting regions using magnetic snap works correctly (#7192) - cut drag should now work correctly with magnetic snap. - musical length of split midi regions is no longer frame based.
Diffstat (limited to 'libs/ardour/ardour/types.h')
-rw-r--r--libs/ardour/ardour/types.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h
index 46ef2bade9..0a2fd62f7b 100644
--- a/libs/ardour/ardour/types.h
+++ b/libs/ardour/ardour/types.h
@@ -319,6 +319,27 @@ namespace ARDOUR {
}
};
+ /* used for translating audio frames to an exact musical position using a note divisor.
+ an exact musical position almost never falls exactly on an audio frame, but for sub-sample
+ musical accuracy we need to derive exact musical locations from a frame position
+ the division follows TempoMap::exact_beat_at_frame().
+ division
+ -1 musical location is the bar closest to frame
+ 0 musical location is the musical position of the frame
+ 1 musical location is the BBT beat closest to frame
+ n musical location is the quarter-note division n closest to frame
+ */
+ struct MusicFrame {
+ framepos_t frame;
+ int32_t division;
+
+ MusicFrame (framepos_t f, int32_t d) : frame (f), division (d) {}
+
+ void set (framepos_t f, int32_t d) {frame = f; division = d; }
+
+ MusicFrame operator- (MusicFrame other) { return MusicFrame (frame - other.frame, 0); }
+ };
+
/* XXX: slightly unfortunate that there is this and Evoral::Range<>,
but this has a uint32_t id which Evoral::Range<> does not.
*/