add haupauge-1657 dual usb capture support, add deinterlace to recordmonitor, asset...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / tracksedit.C
index 1129502accdb7e1d8b62caf010991a644dd21bf5..7f46fcb228d10ed4a7c50d3ae9de87d12fd5fbaf 100644 (file)
@@ -120,6 +120,33 @@ void Tracks::clear_transitions(double start, double end)
        }
 }
 
+int Tracks::clear_hard_edges(double start, double end)
+{
+       for( Track *track=first; track; track=track->next ) {
+               if( !track->record ) continue;
+               int64_t start_units = track->to_units(start, 0);
+               int64_t end_units = track->to_units(end, 0);
+
+               for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
+                       int64_t pos = edit->startproject;
+                       if( pos > end_units ) break;
+                       if( pos >= start_units ) {
+                               edit->hard_left = 0;
+                               if( edit->previous )
+                                       edit->previous->hard_right = 0;
+                       }
+                       pos += edit->length;
+                       if( pos > end_units ) break;
+                       if( pos >= start_units ) {
+                               edit->hard_right = 0;
+                               if( edit->next )
+                                       edit->next->hard_left = 0;
+                       }
+               }
+       }
+       return 0;
+}
+
 void Tracks::shuffle_edits(double start, double end)
 {
 // This doesn't affect automation or effects
@@ -155,19 +182,17 @@ void Tracks::reverse_edits(double start, double end)
                }
        }
 }
+
 void Tracks::align_edits(double start, double end)
 {
 // This doesn't affect automation or effects
-       ArrayList<double> times;
-
-       for(Track *current_track = first;
-               current_track;
-               current_track = current_track->next)
-       {
-               if(current_track->record)
-               {
-                       current_track->align_edits(start, end, &times);
-               }
+       Track *master_track = 0;
+       for( Track *track=first; track; track=track->next ) {
+               if( !track->record ) continue;
+               if( !master_track )
+                       master_track = track;
+               else
+                       track->align_edits(start, end, master_track);
        }
 }
 
@@ -612,7 +637,7 @@ void Tracks::move_edits(ArrayList<Edit*> *in_edits, Track *track, double positio
                }
 
                FileXML track_xml;
-               source_track->copy(source_start, source_end, &track_xml, "");
+               source_track->copy(COPY_TRACKS, source_start, source_end, &track_xml, "");
                if( !track_xml.read_tag() )
                        clip_track->load(&track_xml, 0, LOAD_ALL);
 
@@ -800,27 +825,16 @@ void Tracks::change_plugins(SharedLocation &old_location, SharedLocation &new_lo
 // =========================================== EDL editing
 
 
-int Tracks::copy(double start,
-       double end,
-       int all,
-       FileXML *file,
-       const char *output_path)
+int Tracks::copy(int copy_flags, double start, double end,
+               FileXML *file, const char *output_path)
 {
-// nothing selected
-       if(start == end && !all) return 1;
-
-       Track* current;
-
-       for(current = first;
-               current;
-               current = NEXT)
-       {
-               if(current->record || all)
-               {
-                       current->copy(start, end, file,output_path);
-               }
+       int all = (copy_flags & COPY_ALL) ? 1 : 0;
+// if nothing selected
+       if( start == end && !all ) return 1;
+       for( Track *track=first; track; track=track->next ) {
+               if( track->record || all )
+                       track->copy(copy_flags, start, end, file, output_path);
        }
-
        return 0;
 }
 
@@ -862,24 +876,15 @@ int Tracks::move_track_down(Track *track)
 
 int Tracks::move_tracks_up()
 {
-       Track *track, *next_track;
        int result = 0;
-
-       for(track = first;
-               track;
-               track = next_track)
-       {
-               next_track = track->next;
-
-               if(track->record)
-               {
-                       if(track->previous)
-                       {
-                               change_modules(number_of(track->previous), number_of(track), 1);
-
-                               swap(track->previous, track);
-                               result = 1;
-                       }
+       Track *next = first;
+       while( next ) {
+               Track *track = next;  next = track->next;
+               if( !track->record ) continue;
+               if( track->previous ) {
+                       change_modules(number_of(track->previous), number_of(track), 1);
+                       swap(track->previous, track);
+                       result = 1;
                }
        }
 
@@ -888,24 +893,15 @@ int Tracks::move_tracks_up()
 
 int Tracks::move_tracks_down()
 {
-       Track *track, *previous_track;
        int result = 0;
-
-       for(track = last;
-               track;
-               track = previous_track)
-       {
-               previous_track = track->previous;
-
-               if(track->record)
-               {
-                       if(track->next)
-                       {
-                               change_modules(number_of(track), number_of(track->next), 1);
-
-                               swap(track, track->next);
-                               result = 1;
-                       }
+       Track *prev = last;
+       while( prev ) {
+               Track *track = prev;  prev = track->previous;
+               if( !track->record ) continue;
+               if( track->next ) {
+                       change_modules(number_of(track), number_of(track->next), 1);
+                       swap(track, track->next);
+                       result = 1;
                }
        }
 
@@ -913,7 +909,6 @@ int Tracks::move_tracks_down()
 }
 
 
-
 void Tracks::paste_audio_transition(PluginServer *server)
 {
        for(Track *current = first; current; current = NEXT)