fix get_auto_at_position equivalence test, fix KeySpeedAutoEdge init toggle value...
authorGood Guy <good1.2guy@gmail.com>
Wed, 26 Aug 2020 01:50:31 +0000 (19:50 -0600)
committerGood Guy <good1.2guy@gmail.com>
Wed, 26 Aug 2020 01:50:31 +0000 (19:50 -0600)
cinelerra-5.1/cinelerra/automation.inc
cinelerra-5.1/cinelerra/autos.C
cinelerra-5.1/cinelerra/keyframepopup.C
cinelerra-5.1/cinelerra/mwindowedit.C

index 31f58a663016158b04d187f74e74a286e8fadf80..53e498d13e95ffa97b147b0581d17dbd8af0f1f8 100644 (file)
@@ -43,6 +43,7 @@ enum
        AUTOMATION_PAN,
        AUTOMATION_MODE,
        AUTOMATION_MASK,
+// must be last or autos move when pasted due to speed pos shifts
        AUTOMATION_SPEED,
        AUTOMATION_TOTAL
 };
index d08aae57aef58e609e4962bea2ac48ebc76c69f9..a2914d82e274573704b6f1332e3039b8e24b4cc9 100644 (file)
@@ -265,16 +265,11 @@ int Autos::auto_exists_for_editing(double position)
 
 Auto* Autos::get_auto_at_position(double position)
 {
-       int64_t unit_position = track->to_units(position, 1);
 
-       for(Auto *current = first;
-               current;
-               current = NEXT)
-       {
-               if(edl->equivalent(current->position, unit_position))
-               {
+       for( Auto *current=first; current; current=NEXT ) {
+               double pos = track->from_units(current->position);
+               if( edl->equivalent(position, pos) )
                        return current;
-               }
        }
        return 0;
 }
index b94ae1521bc94d7094715c80b7f09e6d43cf29ed..8c8e582b8bd1d3a6a9578b240be3f0eaa377541f 100644 (file)
@@ -770,7 +770,7 @@ int KeySpeedSlider::handle_event()
 KeySpeedAutoEdge::KeySpeedAutoEdge(MWindow *mwindow,
                KeySpeedPatch *patch, int x, int y)
  : BC_Toggle(x, y, mwindow->theme->get_image_set("bump_edge"),
-                patch->gui->span,_("Edge"))
+                patch->gui->edge,_("Edge"))
 {
        this->mwindow = mwindow;
        this->patch = patch;
index 47b29ee891e06898cc2ce14dbad0e2a5a36d1117..eac3c656fd7c20d4bd8750732d6156b597e319c2 100644 (file)
@@ -2630,7 +2630,50 @@ int MWindow::normalize_speed(EDL *old_edl, EDL *new_edl)
                        }
                        first_track = 0;
                }
-               if( autos_follow_edits ) {
+               if( plugins_follow_edits ) {
+                       int old_size = old_track->plugin_set.size();
+                       int new_size = new_track->plugin_set.size();
+                       int n = bmin(old_size, new_size);
+                       for( int i=0; i<n; ++i ) {
+                               PluginSet *old_plugin_set = old_track->plugin_set[i];
+                               Plugin *old_plugin = (Plugin *)(old_plugin_set ? old_plugin_set->first : 0);
+                               PluginSet *new_plugin_set = new_track->plugin_set[i];
+                               Plugin *new_plugin = (Plugin *)(new_plugin_set ? new_plugin_set->first : 0);
+                               while( old_plugin && new_plugin ) {
+                                       int64_t plugin_start = old_plugin->startproject;
+                                       int64_t plugin_end = plugin_start + old_plugin->length;
+                                       if( old_speed || new_speed ) {
+                                               double orig_start = old_speeds->automation_integral(0, plugin_start, PLAY_FORWARD);
+                                               double orig_end   = old_speeds->automation_integral(0, plugin_end, PLAY_FORWARD);
+                                               plugin_start = new_track->frame_align(new_speeds->speed_position(orig_start), 1);
+                                               plugin_end = new_track->frame_align(new_speeds->speed_position(orig_end), 1);
+                                               result = 1;
+                                       }
+                                       new_plugin->startproject = plugin_start;
+                                       new_plugin->length = plugin_end - plugin_start;
+                                       if( autos_follow_edits ) {
+                                               KeyFrames *old_keyframes = old_plugin->keyframes;
+                                               Auto *old_auto = old_keyframes ? old_keyframes->first : 0;
+                                               KeyFrames *new_keyframes = new_plugin->keyframes;
+                                               Auto *new_auto = new_keyframes ? new_keyframes->first : 0;
+                                               while( old_auto && new_auto ) {
+                                                       int64_t auto_pos = old_auto->position;
+                                                       if( old_speed || new_speed ) {
+                                                               double orig_pos = old_speeds->automation_integral(0, auto_pos, PLAY_FORWARD);
+                                                               auto_pos = new_track->frame_align(new_speeds->speed_position(orig_pos), 1);
+                                                               result = 1;
+                                                       }
+                                                       new_auto->position = auto_pos;
+                                                       old_auto = old_auto->next;
+                                                       new_auto = new_auto->next;
+                                               }
+                                       }
+                                       old_plugin = (Plugin *)old_plugin->next;
+                                       new_plugin = (Plugin *)new_plugin->next;
+                               }
+                       }
+               }
+               if( autos_follow_edits ) { // must be last
                        for( int i=0; i<AUTOMATION_TOTAL; ++i ) {
                                Autos *old_autos = old_track->automation->autos[i];
                                Autos *new_autos = new_track->automation->autos[i];
@@ -2649,48 +2692,6 @@ int MWindow::normalize_speed(EDL *old_edl, EDL *new_edl)
                                }
                        }
                }
-               if( !plugins_follow_edits ) continue;
-               int old_size = old_track->plugin_set.size();
-               int new_size = new_track->plugin_set.size();
-               int n = bmin(old_size, new_size);
-               for( int i=0; i<n; ++i ) {
-                       PluginSet *old_plugin_set = old_track->plugin_set[i];
-                       Plugin *old_plugin = (Plugin *)(old_plugin_set ? old_plugin_set->first : 0);
-                       PluginSet *new_plugin_set = new_track->plugin_set[i];
-                       Plugin *new_plugin = (Plugin *)(new_plugin_set ? new_plugin_set->first : 0);
-                       while( old_plugin && new_plugin ) {
-                               int64_t plugin_start = old_plugin->startproject;
-                               int64_t plugin_end = plugin_start + old_plugin->length;
-                               if( old_speed || new_speed ) {
-                                       double orig_start = old_speeds->automation_integral(0, plugin_start, PLAY_FORWARD);
-                                       double orig_end   = old_speeds->automation_integral(0, plugin_end, PLAY_FORWARD);
-                                       plugin_start = new_track->frame_align(new_speeds->speed_position(orig_start), 1);
-                                       plugin_end = new_track->frame_align(new_speeds->speed_position(orig_end), 1);
-                                       result = 1;
-                               }
-                               new_plugin->startproject = plugin_start;
-                               new_plugin->length = plugin_end - plugin_start;
-                               if( autos_follow_edits ) {
-                                       KeyFrames *old_keyframes = old_plugin->keyframes;
-                                       Auto *old_auto = old_keyframes ? old_keyframes->first : 0;
-                                       KeyFrames *new_keyframes = new_plugin->keyframes;
-                                       Auto *new_auto = new_keyframes ? new_keyframes->first : 0;
-                                       while( old_auto && new_auto ) {
-                                               int64_t auto_pos = old_auto->position;
-                                               if( old_speed || new_speed ) {
-                                                       double orig_pos = old_speeds->automation_integral(0, auto_pos, PLAY_FORWARD);
-                                                       auto_pos = new_track->frame_align(new_speeds->speed_position(orig_pos), 1);
-                                                       result = 1;
-                                               }
-                                               new_auto->position = auto_pos;
-                                               old_auto = old_auto->next;
-                                               new_auto = new_auto->next;
-                                       }
-                               }
-                               old_plugin = (Plugin *)old_plugin->next;
-                               new_plugin = (Plugin *)new_plugin->next;
-                       }
-               }
        }
        return result;
 }