MidiRegion _start/_length beats are frame based only when lock style is Audiotime
authornick_m <mainsbridge@gmail.com>
Sun, 30 Oct 2016 12:42:06 +0000 (23:42 +1100)
committernick_m <mainsbridge@gmail.com>
Thu, 10 Nov 2016 16:37:08 +0000 (03:37 +1100)
gtk2_ardour/editor_tempodisplay.cc
libs/ardour/midi_region.cc

index cd12a4e872aa5a1d8131e1b23dfb5c488c48a085..27578e329aa93df47654433ef1e8230891c26acc 100644 (file)
@@ -362,7 +362,7 @@ Editor::mouse_add_new_tempo_event (framepos_t frame)
        TempoMap& map(_session->tempo_map());
 
        begin_reversible_command (_("add tempo mark"));
-       const double pulse = map.pulse_at_frame (frame);
+       const double pulse = map.exact_qn_at_frame (frame, get_grid_music_divisions (0)) / 4.0;
 
        if (pulse > 0.0) {
                XMLNode &before = map.get_state();
index cff7ab2ed8577da96fd293172b402d12c408e217..ec0cd95c8b076ea210677b74537a170d3d73ee3f 100644 (file)
@@ -213,8 +213,10 @@ MidiRegion::post_set (const PropertyChange& pc)
                   so disallow (this has been set from XML state anyway).
                */
                if (!_session.loading()) {
-                       /* update non-musically */
-                       update_length_beats (0);
+                       /* ensure this only updates non-musical regions */
+                       if (position_lock_style() == AudioTime) {
+                               update_length_beats (0);
+                       }
                }
        } else if (pc.contains (Properties::start) && !pc.contains (Properties::start_beats)) {
                set_start_beats_from_start_frames ();
@@ -224,7 +226,9 @@ MidiRegion::post_set (const PropertyChange& pc)
 void
 MidiRegion::set_start_beats_from_start_frames ()
 {
-       _start_beats = (pulse() * 4.0) - _session.tempo_map().quarter_note_at_frame (_position - _start);
+       if (position_lock_style() == AudioTime) {
+               _start_beats = (pulse() * 4.0) - _session.tempo_map().quarter_note_at_frame (_position - _start);
+       }
 }
 
 void
@@ -451,13 +455,6 @@ MidiRegion::set_state (const XMLNode& node, int version)
 {
        int ret = Region::set_state (node, version);
 
-       if (ret == 0) {
-               /* set length beats to the frame (non-musical) */
-               if (position_lock_style() == AudioTime) {
-                       update_length_beats (0);
-               }
-       }
-
        return ret;
 }
 
@@ -605,9 +602,7 @@ void
 MidiRegion::set_start_internal (framecnt_t s, const int32_t sub_num)
 {
        Region::set_start_internal (s, sub_num);
-       if (position_lock_style() == AudioTime) {
-               set_start_beats_from_start_frames ();
-       }
+       set_start_beats_from_start_frames ();
 }
 
 void