no longer need ffmpeg patch0 which was for Termux
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / edl.C
index d033b8d5377c00401f16be10989748eb12494041..30e9e894dc2fafc267c7610756035d39ca4c0a87 100644 (file)
@@ -2,6 +2,7 @@
 /*
  * CINELERRA
  * Copyright (C) 1997-2012 Adam Williams <broadcast at earthling dot net>
+ * Copyright (C) 2003-2016 Cinelerra CV contributors
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 #include "edits.h"
 #include "edl.h"
 #include "edlsession.h"
+#include "file.h"
 #include "filexml.h"
 #include "floatauto.h"
 #include "floatautos.h"
 #include "guicast.h"
+#include "keyframe.h"
+#include "keyframes.h"
 #include "indexstate.h"
-#include "interlacemodes.h"
 #include "labels.h"
 #include "localsession.h"
 #include "maskautos.h"
@@ -210,7 +213,7 @@ int EDL::read_xml(FileXML *file, uint32_t load_flags)
                                file->tag.title_is("/CLIP_EDL") ||
                                file->tag.title_is("/NESTED_EDL") ||
                                file->tag.title_is("/VWINDOW_EDL") ) {
-                               result = 1;
+                               break;
                        }
                        else
                        if( file->tag.title_is("CLIPBOARD") ) {
@@ -268,8 +271,7 @@ int EDL::read_xml(FileXML *file, uint32_t load_flags)
                        }
                        else
                        if( file->tag.title_is("SESSION") ) {
-                               if( (load_flags & LOAD_SESSION) &&
-                                       !parent_edl )
+                               if( (load_flags & LOAD_SESSION) && !parent_edl )
                                        session->load_xml(file, 0, load_flags);
                                else
                                        result = file->skip_tag();
@@ -279,14 +281,13 @@ int EDL::read_xml(FileXML *file, uint32_t load_flags)
                                tracks->load(file, track_offset, load_flags);
                        }
                        else
-// Sub EDL.
-// Causes clip creation to fail because that involves an opening EDL tag.
-                       if( file->tag.title_is("CLIP_EDL") && !parent_edl ) {
+                       if( file->tag.title_is("CLIP_EDL") ) {
                                EDL *new_edl = new EDL(this);
                                new_edl->create_objects();
                                new_edl->read_xml(file, LOAD_ALL);
-                               if( (load_flags & LOAD_ALL) == LOAD_ALL )
+                               if( (load_flags & LOAD_ALL) == LOAD_ALL ) {
                                        clips.add_clip(new_edl);
+                               }
                                new_edl->remove_user();
                        }
                        else
@@ -299,27 +300,22 @@ int EDL::read_xml(FileXML *file, uint32_t load_flags)
                                nested_edl->remove_user();
                        }
                        else
-                       if( file->tag.title_is("VWINDOW_EDL") && !parent_edl ) {
-                               EDL *new_edl = new EDL(this);
-                               new_edl->create_objects();
-                               new_edl->read_xml(file, LOAD_ALL);
-
-
-                               if( (load_flags & LOAD_ALL) == LOAD_ALL ) {
-//                                             if( vwindow_edl && !vwindow_edl_shared )
-//                                                     vwindow_edl->remove_user();
-//                                             vwindow_edl_shared = 0;
-//                                             vwindow_edl = new_edl;
-
-                                       append_vwindow_edl(new_edl, 0);
-
+                       if( file->tag.title_is("VWINDOW_EDL") ) {
+                               if( !parent_edl ) {
+                                       EDL *new_edl = new EDL(this);
+                                       new_edl->create_objects();
+                                       new_edl->read_xml(file, LOAD_ALL);
+
+
+                                       if( (load_flags & LOAD_ALL) == LOAD_ALL ) {
+                                               append_vwindow_edl(new_edl, 0);
+                                       }
+                                       else { // Discard if not replacing EDL
+                                               new_edl->remove_user();
+                                       }
                                }
                                else
-// Discard if not replacing EDL
-                               {
-                                       new_edl->remove_user();
-                                       new_edl = 0;
-                               }
+                                       result = file->skip_tag();
                        }
                }
        } while(!result);
@@ -336,7 +332,7 @@ int EDL::read_xml(FileXML *file, uint32_t load_flags)
 // The string is not terminated in this call.
 int EDL::save_xml(FileXML *file, const char *output_path)
 {
-       copy(1, file, output_path, 0);
+       copy(COPY_EDL, file, output_path, 0);
        return 0;
 }
 
@@ -416,11 +412,8 @@ void EDL::copy_session(EDL *edl, int session_only)
        }
 }
 
-int EDL::copy_assets(double start,
-       double end,
-       FileXML *file,
-       int all,
-       const char *output_path)
+int EDL::copy_assets(int copy_flags, double start, double end,
+               FileXML *file, const char *output_path)
 {
        ArrayList<Asset*> asset_list;
        Track* current;
@@ -430,15 +423,15 @@ int EDL::copy_assets(double start,
        file->append_newline();
 
 // Copy everything for a save
-       if( all ) {
+       if( (copy_flags & COPY_ALL_ASSETS) ) {
                for( Asset *asset=assets->first; asset; asset=asset->next ) {
                        asset_list.append(asset);
                }
        }
-       else {
+       if( (copy_flags & COPY_USED_ASSETS) ) {
 // Copy just the ones being used.
                for( current = tracks->first; current; current = NEXT ) {
-                       if( !current->record ) continue;
+                       if( !current->is_armed() ) continue;
                        current->copy_assets(start, end, &asset_list);
                }
        }
@@ -456,67 +449,66 @@ int EDL::copy_assets(double start,
 }
 
 
-int EDL::copy(double start, double end, int all,
+int EDL::copy(int copy_flags, double start, double end,
        FileXML *file, const char *output_path, int rewind_it)
 {
        file->tag.set_title("EDL");
        file->tag.set_property("VERSION", CINELERRA_VERSION);
 // Save path for restoration of the project title from a backup.
        if( this->path[0] ) file->tag.set_property("PATH", path);
-       return copy(start, end, all,
-               "/EDL", file, output_path, rewind_it);
+       return copy_xml(copy_flags, start, end, file, "/EDL", output_path, rewind_it);
 }
-int EDL::copy(int all, FileXML *file, const char *output_path, int rewind_it)
+int EDL::copy(int copy_flags, FileXML *file, const char *output_path, int rewind_it)
 {
-       return copy(0, tracks->total_length(), all, file, output_path, rewind_it);
+       return copy(copy_flags, 0., tracks->total_length(),
+               file, output_path, rewind_it);
 }
 
-int EDL::copy_clip(double start, double end, int all,
+int EDL::copy_clip(int copy_flags, double start, double end,
        FileXML *file, const char *output_path, int rewind_it)
 {
        file->tag.set_title("CLIP_EDL");
-       return copy(start, end, all,
-               "/CLIP_EDL", file, output_path, rewind_it);
+       return copy_xml(copy_flags, start, end, file, "/CLIP_EDL", output_path, rewind_it);
 }
-int EDL::copy_clip(int all, FileXML *file, const char *output_path, int rewind_it)
+int EDL::copy_clip(int copy_flags, FileXML *file, const char *output_path, int rewind_it)
 {
-       return copy_clip(0, tracks->total_length(), all, file, output_path, rewind_it);
+       return copy_clip(copy_flags, 0., tracks->total_length(),
+               file, output_path, rewind_it);
 }
 
-int EDL::copy_nested_edl(double start, double end, int all,
+int EDL::copy_nested(int copy_flags, double start, double end,
        FileXML *file, const char *output_path, int rewind_it)
 {
        file->tag.set_title("NESTED_EDL");
        if( this->path[0] ) file->tag.set_property("PATH", path);
-       return copy(start, end, all,
-               "/NESTED_EDL", file, output_path, rewind_it);
+       return copy_xml(copy_flags, start, end, file, "/NESTED_EDL", output_path, rewind_it);
 }
-int EDL::copy_nested_edl(int all, FileXML *file, const char *output_path, int rewind_it)
+int EDL::copy_nested(int copy_flags, FileXML *file, const char *output_path, int rewind_it)
 {
-       return copy_nested_edl(0, tracks->total_length(), all, file, output_path, rewind_it);
+       return copy_nested(copy_flags, 0., tracks->total_length(),
+               file, output_path, rewind_it);
 }
 
-int EDL::copy_vwindow_edl(double start, double end, int all,
+int EDL::copy_vwindow(int copy_flags, double start, double end,
        FileXML *file, const char *output_path, int rewind_it)
 {
        file->tag.set_title("VWINDOW_EDL");
-       return copy(start, end, all,
-               "/VWINDOW_EDL", file, output_path, rewind_it);
+       return copy_xml(copy_flags, start, end, file, "/VWINDOW_EDL", output_path, rewind_it);
 }
-int EDL::copy_vwindow_edl(int all, FileXML *file, const char *output_path, int rewind_it)
+int EDL::copy_vwindow(int copy_flags, FileXML *file, const char *output_path, int rewind_it)
 {
-       return copy_vwindow_edl(0, tracks->total_length(), all, file, output_path, rewind_it);
+       return copy_vwindow(copy_flags, 0., tracks->total_length(),
+               file, output_path, rewind_it);
 }
 
-
-int EDL::copy(double start, double end, int all,
-       const char *closer, FileXML *file,
-       const char *output_path, int rewind_it)
+int EDL::copy_xml(int copy_flags, double start, double end,
+        FileXML *file, const char *closer, const char *output_path,
+       int rewind_it)
 {
        file->append_tag();
        file->append_newline();
 // Set clipboard samples only if copying to clipboard
-       if( !all ) {
+       if( (copy_flags & COPY_LENGTH) ) {
                file->tag.set_title("CLIPBOARD");
                file->tag.set_property("LENGTH", end - start);
                file->append_tag();
@@ -528,45 +520,54 @@ int EDL::copy(double start, double end, int all,
 //printf("EDL::copy 1\n");
 
 // Sessions
-       local_session->save_xml(file, start);
-
-//printf("EDL::copy 1\n");
+       if( (copy_flags & COPY_LOCAL_SESSION) )
+               local_session->save_xml(file, start);
 
 // Top level stuff.
-//     if(!parent_edl)
-       {
 // Need to copy all this from child EDL if pasting is desired.
-// Session
+
+       if( (copy_flags & COPY_SESSION) )
                session->save_xml(file);
+
+       if( (copy_flags & COPY_VIDEO_CONFIG) )
                session->save_video_config(file);
+
+       if( (copy_flags & COPY_AUDIO_CONFIG) )
                session->save_audio_config(file);
+
+       if( (copy_flags & COPY_FOLDERS) )
                folders.save_xml(file);
 
-               if( !parent_edl )
-                       copy_assets(start, end, file, all, output_path);
+       if( (copy_flags & (COPY_ALL_ASSETS | COPY_USED_ASSETS)) )
+               copy_assets(copy_flags, start, end, file, output_path);
 
+       if( (copy_flags & COPY_NESTED_EDL) ) {
                for( int i=0; i<nested_edls.size(); ++i )
-                       nested_edls[i]->copy_nested_edl(0, tracks->total_length(), 1,
+                       nested_edls[i]->copy_nested(copy_flags,
                                file, output_path, 0);
-
+       }
 // Clips
-// Don't want this if using clipboard
-               if( all ) {
-                       for( int i=0; i<total_vwindow_edls(); ++i )
-                               get_vwindow_edl(i)->copy_vwindow_edl(1, file, output_path, 0);
+       if( (copy_flags & COPY_CLIPS) ) {
+               for( int i=0; i<clips.size(); ++i )
+                       clips[i]->copy_clip(copy_flags, file, output_path, 0);
+       }
 
-                       for( int i=0; i<clips.size(); ++i )
-                               clips[i]->copy_clip(1, file, output_path, 0);
+       if( (copy_flags & COPY_VWINDOWS) ) {
+               for( int i=0; i<total_vwindow_edls(); ++i )
+                       get_vwindow_edl(i)->copy_vwindow(copy_flags,
+                               file, output_path, 0);
+       }
 
-                       mixers.save(file);
-               }
+       if( (copy_flags & COPY_MIXERS) )
+               mixers.save(file);
 
-               file->append_newline();
-               file->append_newline();
-       }
+       file->append_newline();
+       file->append_newline();
 
-       labels->copy(start, end, file);
-       tracks->copy(start, end, all, file, output_path);
+       if( (copy_flags & COPY_LABELS) )
+               labels->copy(start, end, file);
+
+       tracks->copy(copy_flags, start, end, file, output_path);
 
 // terminate file
        file->tag.set_title(closer);
@@ -594,7 +595,7 @@ void EDL::copy_indexables(EDL *edl)
        }
 }
 
-EDL *EDL::new_nested(EDL *edl, const char *path)
+EDL *EDL::new_nested_clip(EDL *edl, const char *path)
 {
        EDL *nested = new EDL;  // no parent for nested edl
        nested->create_objects();
@@ -607,6 +608,17 @@ EDL *EDL::new_nested(EDL *edl, const char *path)
        return nested;
 }
 
+EDL *EDL::get_nested_edl(const char *path)
+{
+       for( int i=0; i<nested_edls.size(); ++i ) {
+               EDL *nested_edl = nested_edls[i];
+               if( !strcmp(path, nested_edl->path) )
+                       return nested_edl;
+       }
+       return 0;
+}
+
+
 EDL *EDL::create_nested_clip(EDL *nested)
 {
        EDL *new_edl = new EDL(this);  // parent for clip edl
@@ -617,14 +629,51 @@ EDL *EDL::create_nested_clip(EDL *nested)
 
 void EDL::create_nested(EDL *nested)
 {
+       int video_tracks = 0, audio_tracks = 0;
+       for( Track *track=nested->tracks->first; track!=0; track=track->next ) {
+               if( track->data_type == TRACK_VIDEO && track->play ) ++video_tracks;
+               if( track->data_type == TRACK_AUDIO && track->play ) ++audio_tracks;
+       }
+// renderengine properties
+       if( video_tracks > 0 )
+               video_tracks = 1;
+       if( audio_tracks > 0 )
+               audio_tracks = nested->session->audio_channels;
+       
 // Keep frame rate, sample rate, and output size unchanged.
 // Nest all video & audio outputs
+       session->video_channels = video_tracks;
+       session->audio_channels = audio_tracks;
        session->video_tracks = 1;
-       session->audio_tracks = nested->session->audio_channels;
+       session->audio_tracks = audio_tracks;
        create_default_tracks();
        insert_asset(0, nested, 0, 0, 0);
 }
 
+void EDL::overwrite_clip(EDL *clip)
+{
+       int folder = folder_no;
+       char clip_title[BCTEXTLEN], clip_notes[BCTEXTLEN], clip_icon[BCSTRLEN];
+       if( parent_edl ) {
+               strcpy(clip_title, local_session->clip_title);
+               strcpy(clip_notes, local_session->clip_notes);
+               strcpy(clip_icon,  local_session->clip_icon);
+       }
+       copy_all(clip);
+       folder_no = folder;
+       if( parent_edl ) {
+               strcpy(local_session->clip_title, clip_title);
+               strcpy(local_session->clip_notes, clip_notes);
+               strcpy(local_session->clip_icon, clip_icon);
+       }
+       if( !clip_icon[0] ) return;
+// discard old clip icon to reconstruct 
+       char clip_icon_path[BCTEXTLEN];
+       snprintf(clip_icon_path, sizeof(clip_icon_path),
+               "%s/%s", File::get_config_path(), clip_icon);
+       remove(clip_icon_path);
+}
+
 void EDL::retrack()
 {
        int min_w = session->output_w, min_h = session->output_h;
@@ -795,6 +844,11 @@ int EDL::clear(double start, double end,
        return 0;
 }
 
+int EDL::clear_hard_edges(double start, double end)
+{
+       return tracks->clear_hard_edges(start, end);
+}
+
 static int dead_edit_cmp(Edit**ap, Edit**bp)
 {
        Edit *a = *ap, *b = *bp;
@@ -829,8 +883,8 @@ void EDL::delete_edits(ArrayList<Edit*> *edits, int collapse)
                                edit->startproject -= length;
                }
                delete dead_edit;
-               track->edits->optimize();
        }
+       optimize();
 }
 
 class Range {
@@ -849,8 +903,8 @@ static void get_edit_regions(ArrayList<Edit*> *edits, ArrayList<Range> &regions)
 // move edit inclusive labels by regions
        for( int i=0; i<edits->size(); ++i ) {
                Edit *edit = edits->get(i);
-               double pos = edit->track->from_units(edit->startproject);
-               double end = edit->track->from_units(edit->startproject + edit->length);
+               volatile double pos = edit->track->from_units(edit->startproject);
+               volatile double end = edit->track->from_units(edit->startproject + edit->length);
                int n = regions.size(), k = n;
                while( --k >= 0 ) {
                        Range &range = regions[k];
@@ -909,7 +963,6 @@ void EDL::move_edit_labels(ArrayList<Edit*> *edits, double dist)
        }
 }
 
-
 void EDL::modify_edithandles(double oldposition, double newposition,
        int currentend, int handle_mode, int edit_labels,
        int edit_plugins, int edit_autos, int group_id)
@@ -917,8 +970,6 @@ void EDL::modify_edithandles(double oldposition, double newposition,
        tracks->modify_edithandles(oldposition, newposition,
                currentend, handle_mode, edit_labels,
                edit_plugins, edit_autos, group_id);
-       labels->modify_handles(oldposition, newposition,
-               currentend, handle_mode, edit_labels);
 }
 
 void EDL::modify_pluginhandles(double oldposition, double newposition,
@@ -987,6 +1038,7 @@ int EDL::get_tracks_height(Theme *theme)
 {
        int total_pixels = 0;
        for( Track *current=tracks->first; current; current=NEXT ) {
+               if( current->is_hidden() ) continue;
                total_pixels += current->vertical_span(theme);
        }
        return total_pixels;
@@ -996,6 +1048,7 @@ int64_t EDL::get_tracks_width()
 {
        int64_t total_pixels = 0;
        for( Track *current=tracks->first; current; current=NEXT ) {
+               if( current->is_hidden() ) continue;
                int64_t pixels = current->horizontal_span();
                if( pixels > total_pixels ) total_pixels = pixels;
        }
@@ -1150,7 +1203,7 @@ void EDL::insert_asset(Asset *asset,
 
        if( new_nested_edl ) {
                length = new_nested_edl->tracks->total_length();
-               layers = 1;
+               layers = new_nested_edl->session->video_channels;
                channels = new_nested_edl->session->audio_channels;
        }
 
@@ -1171,7 +1224,7 @@ void EDL::insert_asset(Asset *asset,
        }
 
        for( ; current && vtrack<layers; current=NEXT ) {
-               if( !current->record || current->data_type != TRACK_VIDEO ) continue;
+               if( !current->is_armed() || current->data_type != TRACK_VIDEO ) continue;
                current->insert_asset(new_asset, new_nested_edl,
                        length, position, vtrack++);
        }
@@ -1193,7 +1246,7 @@ void EDL::insert_asset(Asset *asset,
 
        current = tracks->first;
        for( ; current && atrack < channels; current=NEXT ) {
-               if( !current->record || current->data_type != TRACK_AUDIO ) continue;
+               if( !current->is_armed() || current->data_type != TRACK_AUDIO ) continue;
                current->insert_asset(new_asset, new_nested_edl,
                        length, position, atrack++);
        }
@@ -1247,7 +1300,7 @@ void EDL::get_shared_plugins(Track *source,
        int data_type)
 {
        for( Track *track=tracks->first; track; track=track->next ) {
-               if( track->record && omit_recordable ) continue;
+               if( track->is_armed() && omit_recordable ) continue;
                if( track == source || track->data_type != data_type ) continue;
                for( int i=0; i<track->plugin_set.size(); ++i ) {
                        Plugin *plugin = track->get_current_plugin(
@@ -1264,7 +1317,7 @@ void EDL::get_shared_tracks(Track *track,
        int omit_recordable, int data_type)
 {
        for( Track *current=tracks->first; current; current=NEXT ) {
-               if( omit_recordable && current->record ) continue;
+               if( omit_recordable && current->is_armed() ) continue;
                if( current == track || current->data_type != data_type ) continue;
                module_locations->append(new SharedLocation(tracks->number_of(current), 0));
        }
@@ -1428,14 +1481,7 @@ if( debug ) printf("EDL::get_use_vconsole %d\n", __LINE__);
            asset->height != session->output_h )
                return 1;
 
-
 if( debug ) printf("EDL::get_use_vconsole %d\n", __LINE__);
-// Asset and output device must have same resulting de-interlacing method
-       if( ilaceautofixmethod2(session->interlace_mode,
-           asset->interlace_autofixoption, asset->interlace_mode,
-           asset->interlace_fixmethod) != ILACE_FIXMETHOD_NONE )
-               return 1;
-
 // If we get here the frame is going to be directly copied.  Whether it is
 // decompressed in hardware depends on the colormodel.
        return 0;
@@ -1544,7 +1590,7 @@ double EDL::next_edit(double position)
 
 // Test for edit handles after position
        for( Track *track=tracks->first; track; track=track->next ) {
-               if( !track->record ) continue;
+               if( !track->is_armed() ) continue;
                for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
                        double edit_end = track->from_units(edit->startproject + edit->length);
                        Units::fix_double(&edit_end);
@@ -1568,7 +1614,7 @@ double EDL::prev_edit(double position)
 
 // Test for edit handles before cursor position
        for( Track *track=tracks->first; track; track=track->next ) {
-               if( !track->record ) continue;
+               if( !track->is_armed() ) continue;
                for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
                        double edit_end = track->from_units(edit->startproject);
                        Units::fix_double(&edit_end);
@@ -1580,6 +1626,21 @@ double EDL::prev_edit(double position)
        return new_position;
 }
 
+double EDL::skip_silence(double position)
+{
+       double result = position, nearest = DBL_MAX;
+       for( Track *track=tracks->first; track; track=track->next ) {
+               if( !track->play ) continue;
+               Edit *edit = track->edits->editof(position, PLAY_FORWARD, 0);
+               while( edit && edit->silence() ) edit = edit->next;
+               if( !edit ) continue;
+               double pos = track->from_units(edit->startproject);
+               if( pos > position && pos < nearest )
+                       nearest = result = pos;
+        }
+       return result;
+}
+
 void EDL::rescale_proxy(int orig_scale, int new_scale)
 {
        if( orig_scale == new_scale ) return;
@@ -1611,39 +1672,34 @@ void EDL::rescale_proxy(int orig_scale, int new_scale)
        }
 }
 
-void EDL::set_proxy(int new_scale, int use_scaler,
+void EDL::set_proxy(int new_scale, int new_use_scaler,
        ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets)
 {
        int orig_scale = session->proxy_scale;
+       int proxy_scale = new_scale;
+       if( !proxy_scale ) proxy_scale = 1;
+       session->proxy_scale = proxy_scale;
        int orig_use_scaler = session->proxy_use_scaler;
-
-// rescale to full size asset in read_frame
-       session->proxy_scale = new_scale;
-       session->proxy_use_scaler = use_scaler;
-
-       if( use_scaler ) {
-               for( int i=0; i<proxy_assets->size(); ++i ) {
-                       Asset *proxy_asset = (Asset *)proxy_assets->get(i);
-                       proxy_asset->width = orig_assets->get(i)->get_w();
-                       proxy_asset->height = orig_assets->get(i)->get_h();
-               }
-               new_scale = 1;
-       }
-
-       if( !orig_use_scaler )
-               rescale_proxy(orig_scale, new_scale);
-
+       session->proxy_use_scaler = new_use_scaler;
+       if( orig_use_scaler ) orig_scale = 1;
+       int scale = new_use_scaler ? proxy_scale : 1;
+       int asset_scale = !new_scale ? 0 : !new_use_scaler ? 1 : scale;
 // change original assets to proxy assets
-       int folder_no = use_scaler || new_scale != 1 ? AW_PROXY_FOLDER : AW_MEDIA_FOLDER;
+       int folder_no = !new_use_scaler && !new_scale ? AW_MEDIA_FOLDER : AW_PROXY_FOLDER;
        for( int i=0,n=proxy_assets->size(); i<n; ++i ) {
                Indexable *proxy_idxbl = proxy_assets->get(i);
                proxy_idxbl->folder_no = folder_no;
                if( !proxy_idxbl->is_asset ) continue;
                Asset *proxy_asset = assets->update((Asset *)proxy_idxbl);
-               if( proxy_asset == (Asset *)proxy_idxbl ) continue;
-               proxy_asset->width = proxy_idxbl->get_w();
-               proxy_asset->height = proxy_idxbl->get_h();
+               proxy_asset->proxy_scale = asset_scale;
+               if( !new_scale ) continue;  // in case geom resized
+               proxy_asset->width = proxy_asset->actual_width * scale;
+               proxy_asset->height = proxy_asset->actual_height * scale;
        }
+// rescale to full size asset in read_frame
+       if( new_use_scaler ) proxy_scale = 1;
+       rescale_proxy(orig_scale, proxy_scale);
+
 // replace track contents
        for( Track *track=tracks->first; track; track=track->next ) {
                if( track->data_type != TRACK_VIDEO ) continue;
@@ -1686,19 +1742,21 @@ void EDL::set_proxy(int new_scale, int use_scaler,
                        }
                }
                if( has_proxy && !orig_use_scaler )
-                       clip->rescale_proxy(orig_scale, new_scale);
+                       clip->rescale_proxy(orig_scale, proxy_scale);
        }
 }
 
-void EDL::add_proxy(int use_scaler,
-       ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets)
+void EDL::add_proxy(ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets)
 {
-       if( use_scaler ) {
-               for( int i=0,n=proxy_assets->size(); i<n; ++i ) {
-                       Asset *proxy_asset = (Asset *)proxy_assets->get(i);
-                       proxy_asset->width = orig_assets->get(i)->get_w();
-                       proxy_asset->height = orig_assets->get(i)->get_h();
-               }
+       int asset_scale = session->proxy_scale;
+       if( asset_scale == 1 ) asset_scale = 0;
+       int scale = !asset_scale ? 1 : asset_scale;
+// update proxy geom using scale
+       for( int i=0; i<proxy_assets->size(); ++i ) {
+               Asset *proxy_asset = (Asset *)proxy_assets->get(i);
+               proxy_asset->proxy_scale = asset_scale;
+               proxy_asset->width = proxy_asset->actual_width * scale;
+               proxy_asset->height = proxy_asset->actual_height * scale;
        }
 
 // change original assets to proxy assets
@@ -1798,3 +1856,495 @@ int EDL::regroup(int next_id)
        return new_groups.size();
 }
 
+EDL *EDL::selected_edits_to_clip(int packed,
+               double *start_position, Track **start_track,
+               int edit_labels, int edit_autos, int edit_plugins)
+{
+       double start = DBL_MAX, end = DBL_MIN;
+       Track *first_track=0, *last_track = 0;
+       for( Track *track=tracks->first; track; track=track->next ) {
+               if( !track->is_armed() ) continue;
+               int empty = 1;
+               for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
+                       if( !edit->is_selected || edit->silence() ) continue;
+                       double edit_pos = track->from_units(edit->startproject);
+                       if( start > edit_pos ) start = edit_pos;
+                       if( end < (edit_pos+=edit->length) ) end = edit_pos;
+                       empty = 0;
+               }
+               if( empty ) continue;
+               if( !first_track ) first_track = track;
+               last_track = track;
+       }
+       if( start_position ) *start_position = start;
+       if( start_track ) *start_track = first_track;
+       if( !first_track ) return 0;
+       EDL *new_edl = new EDL();
+       new_edl->create_objects();
+       new_edl->copy_session(this);
+       const char *text = _("new_edl edit");
+       new_edl->set_path(text);
+       strcpy(new_edl->local_session->clip_title, text);
+       strcpy(new_edl->local_session->clip_notes, text);
+       new_edl->session->video_tracks = 0;
+       new_edl->session->audio_tracks = 0;
+       for( Track *track=tracks->first; track; track=track->next ) {
+               if( !track->is_armed() ) continue;
+               if( first_track ) {
+                       if( first_track != track ) continue;
+                       first_track = 0;
+               }
+               Track *new_track = 0;
+               if( !packed )
+                       new_track = new_edl->add_new_track(track->data_type);
+               int64_t start_pos = track->to_units(start, 0);
+               int64_t end_pos = track->to_units(end, 0);
+               int64_t startproject = 0;
+               Edit *edit = track->edits->first;
+               for( ; edit; edit=edit->next ) {
+                       if( !edit->is_selected || edit->silence() ) continue;
+                       if( edit->startproject < start_pos ) continue;
+                       if( edit->startproject >= end_pos ) break;
+                       int64_t edit_start_pos = edit->startproject;
+                       int64_t edit_end_pos = edit->startproject + edit->length;
+                       if( !new_track )
+                               new_track = new_edl->add_new_track(track->data_type);
+                       int64_t edit_pos = edit_start_pos - start_pos;
+                       if( !packed && edit_pos > startproject ) {
+                               Edit *silence = new Edit(new_edl, new_track);
+                               silence->startproject = startproject;
+                               silence->length = edit_pos - startproject;
+                               new_track->edits->append(silence);
+                               startproject = edit_pos;
+                       }
+                       int64_t clip_start_pos = startproject;
+                       Edit *clip_edit = new Edit(new_edl, new_track);
+                       clip_edit->clone_from(edit);
+                       clip_edit->startproject = startproject;
+                       startproject += clip_edit->length;
+                       new_track->edits->append(clip_edit);
+                       if( edit_labels ) {
+                               double edit_start = track->from_units(edit_start_pos);
+                               double edit_end = track->from_units(edit_end_pos);
+                               double clip_start = new_track->from_units(clip_start_pos);
+                               Label *label = labels->first;
+                               for( ; label; label=label->next ) {
+                                       if( label->position < edit_start ) continue;
+                                       if( label->position >= edit_end ) break;
+                                       double clip_position = label->position - edit_start + clip_start;
+                                       Label *clip_label = new_edl->labels->first;
+                                       while( clip_label && clip_label->position<clip_position )
+                                               clip_label = clip_label->next;
+                                       if( clip_label && clip_label->position == clip_position ) continue;
+                                       Label *new_label = new Label(new_edl,
+                                               new_edl->labels, clip_position, label->textstr);
+                                       new_edl->labels->insert_before(clip_label, new_label);
+                               }
+                       }
+                       if( edit_autos ) {
+                               Automation *automation = track->automation;
+                               Automation *new_automation = new_track->automation;
+                               for( int i=0; i<AUTOMATION_TOTAL; ++i ) {
+                                       Autos *autos = automation->autos[i];
+                                       if( !autos ) continue;
+                                       Autos *new_autos = new_automation->autos[i];
+                                       new_autos->default_auto->copy_from(autos->default_auto);
+                                       Auto *aut0 = autos->first;
+                                       for( ; aut0; aut0=aut0->next ) {
+                                               if( aut0->position < edit_start_pos ) continue;
+                                               if( aut0->position >= edit_end_pos ) break;
+                                               Auto *new_auto = new_autos->new_auto();
+                                               new_auto->copy_from(aut0);
+                                               int64_t clip_position = aut0->position - edit_start_pos + clip_start_pos;
+                                               new_auto->position = clip_position;
+                                               new_autos->append(new_auto);
+                                       }
+                               }
+                       }
+                       if( edit_plugins ) {
+                               while( new_track->plugin_set.size() < track->plugin_set.size() )
+                                       new_track->plugin_set.append(0);
+                               for( int i=0; i<track->plugin_set.total; ++i ) {
+                                       PluginSet *plugin_set = track->plugin_set[i];
+                                       if( !plugin_set ) continue;
+                                       PluginSet *new_plugin_set = new_track->plugin_set[i];
+                                       if( !new_plugin_set ) {
+                                               new_plugin_set = new PluginSet(new_edl, new_track);
+                                               new_track->plugin_set[i] = new_plugin_set;
+                                       }
+                                       Plugin *plugin = (Plugin*)plugin_set->first;
+                                       int64_t startplugin = new_plugin_set->length();
+                                       for( ; plugin ; plugin=(Plugin*)plugin->next ) {
+                                               if( plugin->silence() ) continue;
+                                               int64_t plugin_start_pos = plugin->startproject;
+                                               int64_t plugin_end_pos = plugin_start_pos + plugin->length;
+                                               if( plugin_end_pos < start_pos ) continue;
+                                               if( plugin_start_pos > end_pos ) break;
+                                               if( plugin_start_pos < edit_start_pos )
+                                                       plugin_start_pos = edit_start_pos;
+                                               if( plugin_end_pos > edit_end_pos )
+                                                       plugin_end_pos = edit_end_pos;
+                                               if( plugin_start_pos >= plugin_end_pos ) continue;
+                                               int64_t plugin_pos = plugin_start_pos - start_pos;
+                                               if( !packed && plugin_pos > startplugin ) {
+                                                       Plugin *silence = new Plugin(new_edl, new_track, "");
+                                                       silence->startproject = startplugin;
+                                                       silence->length = plugin_pos - startplugin;
+                                                       new_plugin_set->append(silence);
+                                                       startplugin = plugin_pos;
+                                               }
+                                               Plugin *new_plugin = new Plugin(new_edl, new_track, plugin->title);
+                                               new_plugin->copy_base(plugin);
+                                               new_plugin->startproject = startplugin;
+                                               new_plugin->length = plugin_end_pos - plugin_start_pos;
+                                               startplugin += new_plugin->length;
+                                               new_plugin_set->append(new_plugin);
+                                               KeyFrames *keyframes = plugin->keyframes;
+                                               KeyFrames *new_keyframes = new_plugin->keyframes;
+                                               new_keyframes->default_auto->copy_from(keyframes->default_auto);
+                                               new_keyframes->default_auto->position = new_plugin->startproject;
+                                               KeyFrame *keyframe = (KeyFrame*)keyframes->first;
+                                               for( ; keyframe; keyframe=(KeyFrame*)keyframe->next ) {
+                                                       if( keyframe->position < edit_start_pos ) continue;
+                                                       if( keyframe->position >= edit_end_pos ) break;
+                                                       KeyFrame *clip_keyframe = new KeyFrame(new_edl, new_keyframes);
+                                                       clip_keyframe->copy_from(keyframe);
+                                                       int64_t key_position = keyframe->position - start_pos;
+                                                       if( packed )
+                                                               key_position += new_plugin->startproject - plugin_pos;
+                                                       clip_keyframe->position = key_position;
+                                                       new_keyframes->append(clip_keyframe);
+                                               }
+                                       }
+                               }
+                       }
+               }
+               if( last_track == track ) break;
+       }
+       return new_edl;
+}
+
+EDL *EDL::selected_edits_to_clip(int packed, double *start_position, Track **start_track)
+{
+       return selected_edits_to_clip(packed, start_position, start_track,
+               session->labels_follow_edits,
+               session->autos_follow_edits,
+               session->plugins_follow_edits);
+}
+
+void EDL::paste_edits(EDL *clip, Track *first_track, double position, int overwrite,
+               int edit_edits, int edit_labels, int edit_autos, int edit_plugins)
+{
+       if( !first_track )
+               first_track = tracks->first;
+       Track *src = clip->tracks->first;
+       for( Track *track=first_track; track && src; track=track->next ) {
+               if( !track->is_armed() ) continue;
+               int64_t pos = track->to_units(position, 0);
+               if( edit_edits ) {
+                       for( Edit *edit=src->edits->first; edit; edit=edit->next ) {
+                               if( edit->silence() ) continue;
+                               int64_t start = pos + edit->startproject;
+                               int64_t len = edit->length, end = start + len;
+                               if( overwrite )
+                                       track->edits->clear(start, end);
+                               Edit *dst = track->edits->insert_new_edit(start);
+                               dst->clone_from(edit);
+                               dst->startproject = start;
+                               dst->is_selected = 1;
+                               while( (dst=dst->next) != 0 )
+                                       dst->startproject += edit->length;
+                               if( overwrite ) continue;
+                               if( edit_labels && track == first_track ) {
+                                       double dst_pos = track->from_units(start);
+                                       double dst_len = track->from_units(len);
+                                       for( Label *label=labels->first; label; label=label->next ) {
+                                               if( label->position >= dst_pos )
+                                                       label->position += dst_len;
+                                       }
+                               }
+                               if( edit_autos ) {
+                                       for( int i=0; i<AUTOMATION_TOTAL; ++i ) {
+                                               Autos *autos = track->automation->autos[i];
+                                               if( !autos ) continue;
+                                               for( Auto *aut0=autos->first; aut0; aut0=aut0->next ) {
+                                                       if( aut0->position >= start )
+                                                               aut0->position += edit->length;
+                                               }
+                                       }
+                               }
+                               if( edit_plugins ) {
+                                       for( int i=0; i<track->plugin_set.size(); ++i ) {
+                                               PluginSet *plugin_set = track->plugin_set[i];
+                                               Plugin *plugin = (Plugin *)plugin_set->first;
+                                               for( ; plugin; plugin=(Plugin *)plugin->next ) {
+                                                       if( plugin->startproject >= start )
+                                                               plugin->startproject += edit->length;
+                                                       else if( plugin->startproject+plugin->length > end )
+                                                               plugin->length += edit->length;
+                                                       Auto *default_keyframe = plugin->keyframes->default_auto;
+                                                       if( default_keyframe->position >= start )
+                                                               default_keyframe->position += edit->length;
+                                                       KeyFrame *keyframe = (KeyFrame*)plugin->keyframes->first;
+                                                       for( ; keyframe; keyframe=(KeyFrame*)keyframe->next ) {
+                                                               if( keyframe->position >= start )
+                                                                       keyframe->position += edit->length;
+                                                       }
+                                               }
+                                               plugin_set->optimize();
+                                       }
+                               }
+                       }
+               }
+               if( edit_autos ) {
+                       for( int i=0; i<AUTOMATION_TOTAL; ++i ) {
+                               Autos *src_autos = src->automation->autos[i];
+                               if( !src_autos ) continue;
+                               Autos *autos = track->automation->autos[i];
+                               for( Auto *aut0=src_autos->first; aut0; aut0=aut0->next ) {
+                                       int64_t auto_pos = pos + aut0->position;
+                                       autos->insert_auto(auto_pos, aut0);
+                               }
+                       }
+               }
+               if( edit_plugins ) {
+                       for( int i=0; i<src->plugin_set.size(); ++i ) {
+                               PluginSet *plugin_set = src->plugin_set[i];
+                               if( !plugin_set ) continue;
+                               while( i >= track->plugin_set.size() )
+                                       track->plugin_set.append(0);
+                               PluginSet *dst_plugin_set = track->plugin_set[i];
+                               if( !dst_plugin_set ) {
+                                       dst_plugin_set = new PluginSet(this, track);
+                                       track->plugin_set[i] = dst_plugin_set;
+                               }
+                               Plugin *plugin = (Plugin *)plugin_set->first;
+                               if( plugin ) track->expand_view = 1;
+                               for( ; plugin; plugin=(Plugin *)plugin->next ) {
+                                       int64_t start = pos + plugin->startproject;
+                                       int64_t end = start + plugin->length;
+                                       if( overwrite || edit_edits )
+                                               dst_plugin_set->clear(start, end, 1);
+                                       Plugin *new_plugin = dst_plugin_set->insert_plugin(plugin->title,
+                                               start, end-start, plugin->plugin_type, &plugin->shared_location,
+                                               (KeyFrame*)plugin->keyframes->default_auto, 0);
+                                       new_plugin->on = plugin->on;
+                                       KeyFrame *keyframe = (KeyFrame*)plugin->keyframes->first;
+                                       for( ; keyframe; keyframe=(KeyFrame*)keyframe->next ) {
+                                               int64_t keyframe_pos = pos + keyframe->position;
+                                               new_plugin->keyframes->insert_auto(keyframe_pos, keyframe);
+                                       }
+                                       while( (new_plugin=(Plugin *)new_plugin->next) ) {
+                                               KeyFrame *keyframe = (KeyFrame*)new_plugin->keyframes->first;
+                                               for( ; keyframe; keyframe=(KeyFrame*)keyframe->next )
+                                                       keyframe->position += plugin->length;
+                                       }
+                               }
+                       }
+               }
+               src = src->next;
+       }
+       if( edit_labels ) {
+               Label *edl_label = labels->first;
+               for( Label *label=clip->labels->first; label; label=label->next ) {
+                       double label_pos = position + label->position;
+                       int exists = 0;
+                       while( edl_label &&
+                               !(exists=equivalent(edl_label->position, label_pos)) &&
+                               edl_label->position < position ) edl_label = edl_label->next;
+                       if( exists ) continue;
+                       labels->insert_before(edl_label,
+                               new Label(this, labels, label_pos, label->textstr));
+               }
+       }
+       optimize();
+}
+
+void EDL::paste_edits(EDL *clip, Track *first_track, double position, int overwrite)
+{
+       paste_edits(clip, first_track, position, overwrite, 1,
+               session->labels_follow_edits,
+               session->autos_follow_edits,
+               session->plugins_follow_edits);
+}
+
+void EDL::replace_assets(ArrayList<Indexable*> &orig_idxbls, ArrayList<Asset*> &new_assets)
+{
+       for( Track *track=tracks->first; track; track=track->next ) {
+               for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
+                       Indexable *idxbl = (Indexable *)edit->asset;
+                       if( !idxbl ) continue;
+                       int i = orig_idxbls.size();
+                       while( --i>=0 && strcmp(orig_idxbls[i]->path, idxbl->path) );
+                       if( i < 0 ) continue;
+                       Asset *new_asset = new_assets[i];
+                       if( track->data_type == TRACK_VIDEO && !new_asset->video_data ) continue;
+                       if( track->data_type == TRACK_AUDIO && !new_asset->audio_data ) continue;
+                       edit->asset = assets->update(new_assets[i]);
+               }
+       }
+       if( !parent_edl ) {
+               for( int j=0,n=clips.size(); j<n; ++j )
+                       clips[j]->replace_assets(orig_idxbls, new_assets);
+       }
+}
+
+
+int EDL::collect_effects(EDL *&group)
+{
+// to remap shared plugins in copied plugin stack
+       edl_shared_list shared_map;
+       int ret = 0;
+       EDL *new_edl = new EDL(parent_edl ? parent_edl : this);
+       new_edl->create_objects();
+       Tracks *new_tracks = new_edl->tracks;
+       Track *track = tracks->first;
+       for( ; !ret && track; track=track->next ) {
+               if( track->data_type != TRACK_AUDIO &&
+                   track->data_type != TRACK_VIDEO ) continue;
+               Edit *edit = track->edits->first;
+               while( edit && !edit->is_selected ) edit = edit->next;
+               if( !edit ) continue;
+               if( !track->is_armed() ) { ret = COLLECT_EFFECTS_RECORD;  break; } 
+               Track *new_track = 0;
+               edl_shared *location = 0;
+               int64_t start_pos = edit->startproject;
+               int64_t end_pos = start_pos + edit->length;
+               int pluginsets = track->plugin_set.size();
+               for( int i=0; i<pluginsets; ++i ) {
+                       PluginSet *plugins = track->plugin_set[i];
+                       Plugin *plugin = (Plugin *)plugins->first;
+                       for( ; plugin; plugin=(Plugin *)plugin->next ) {
+                               if( plugin->silence() ) continue;
+                               if( start_pos < plugin->startproject+plugin->length ) break;
+                       }
+                       if( !plugin || plugin->startproject >= end_pos ) continue;
+                       if( !location ) {
+                               location = &shared_map.append();
+                               location->trk = tracks->number_of(track);
+                       }
+                       location->append(i);
+                       if( !new_track )
+                               new_track = track->data_type == TRACK_AUDIO ?
+                                       new_tracks->add_audio_track(0, 0) :
+                                       new_tracks->add_video_track(0, 0) ;
+                       PluginSet *new_plugins = new PluginSet(new_edl, new_track);
+                       new_track->plugin_set.append(new_plugins);
+                       Plugin *new_plugin = (Plugin *)new_plugins->create_edit();
+                       new_plugin->copy_base(plugin);
+                       new_plugins->append(new_plugin);
+                       KeyFrame *keyframe = plugin->keyframes->
+                               get_prev_keyframe(start_pos, PLAY_FORWARD);
+                       KeyFrame *default_auto = (KeyFrame *)
+                               new_plugin->keyframes->default_auto;
+                       default_auto->copy_from(keyframe);
+                       default_auto->position = 0;
+                       default_auto->is_default = 1;
+               }
+               if( !new_track ) { ret = COLLECT_EFFECTS_MISSING;  break; }
+               while( (edit=edit->next) && !edit->is_selected );
+               if( edit ) ret = COLLECT_EFFECTS_MULTIPLE;
+       }
+       track = new_edl->tracks->first;
+       if( !ret && !track ) ret = COLLECT_EFFECTS_EMPTY;
+// remap shared plugins in copied new_edl
+       for( ; !ret && track; track=track->next ) {
+               int pluginsets = track->plugin_set.size();
+               for( int i=0; i<pluginsets; ++i ) {
+                       PluginSet *plugins = track->plugin_set[i];
+                       Plugin *plugin = (Plugin *)plugins->first;
+                       for( ; plugin; plugin=(Plugin *)plugin->next ) {
+                               if( plugin->plugin_type != PLUGIN_SHAREDPLUGIN ) continue;
+                               int trk = plugin->shared_location.module;
+                               int set = plugin->shared_location.plugin;
+                               int m = shared_map.size(), n = -1;
+                               while( --m>=0 && shared_map[m].trk!=trk );
+                               if( m >= 0 ) {
+                                       edl_shared &location = shared_map[m];
+                                       n = location.size();
+                                       while( --n>=0 && location[n]!=set );
+                               }
+                               if( n < 0 ) { ret = COLLECT_EFFECTS_MASTER;  break; }
+                               plugin->shared_location.module = m;
+                               plugin->shared_location.plugin = n;
+                       }
+               }
+       }
+       if( !ret )
+               group = new_edl;
+       else
+               new_edl->remove_user();
+       return ret;
+}
+
+void edl_SharedLocations::add(int trk, int plg)
+{
+       SharedLocation &s = append();
+       s.module = trk;  s.plugin = plg;
+}
+
+// inserts pluginsets in group to first selected edit in tracks
+int EDL::insert_effects(EDL *group, Track *first_track)
+{
+       edl_SharedLocations edl_locs, new_locs;
+       Track *new_track = group->tracks->first;
+       if( !first_track ) first_track = tracks->first;
+       Track *track = first_track;
+       for( ; track && new_track; track=track->next ) {
+               Edit *edit = track->edits->first;
+               while( edit && !edit->is_selected ) edit = edit->next;
+               if( !edit ) continue;
+               if( !track->is_armed() ) return INSERT_EFFECTS_RECORD;
+               if( track->data_type != new_track->data_type ) return INSERT_EFFECTS_TYPE;
+               int gtrk = group->tracks->number_of(new_track);
+               int trk = tracks->number_of(track);
+               int psz = track->plugin_set.size();
+               int new_pluginsets = new_track->plugin_set.size();
+               for( int i=0; i<new_pluginsets; ++psz, ++i ) {
+                       new_locs.add(gtrk, i);
+                       edl_locs.add(trk, psz);
+               }
+               while( (edit=edit->next) && !edit->is_selected );
+               if( edit ) return INSERT_EFFECTS_MULTIPLE;
+               new_track = new_track->next;
+       }
+       if( new_track ) return INSERT_EFFECTS_MISSING;
+       for( ; track; track=track->next ) {
+               Edit *edit = track->edits->first;
+               while( edit && !edit->is_selected ) edit = edit->next;
+               if( edit ) return INSERT_EFFECTS_EXTRA;
+       }
+       new_track = group->tracks->first;
+       track = first_track;
+       for( ; track && new_track; track=track->next ) {
+               if( !track->is_armed() ) continue;
+               Edit *edit = track->edits->first;
+               while( edit && !edit->is_selected ) edit = edit->next;
+               if( !edit ) continue;
+               int64_t start_pos = edit->startproject;
+               int64_t end_pos = start_pos + edit->length;
+               int new_pluginsets = new_track->plugin_set.size();
+               for( int i=0; i<new_pluginsets; ++i ) {
+                       Plugin *new_plugin = (Plugin *)new_track->plugin_set[i]->first;
+                       if( !new_plugin ) continue;
+                       PluginSet *plugins = new PluginSet(this, track);
+                       track->plugin_set.append(plugins);
+                       SharedLocation shared_location;
+                       if( new_plugin->plugin_type == PLUGIN_SHAREDPLUGIN ) {
+                               SharedLocation &new_loc = new_plugin->shared_location;
+                               int k = new_locs.size();
+                               while( --k>=0 && !new_loc.equivalent(&new_locs[k]) );
+                               if( k < 0 ) return INSERT_EFFECTS_MASTER;
+                               shared_location.copy_from(&edl_locs[k]);
+                       }
+                       KeyFrame *default_keyframe = (KeyFrame *)new_plugin->keyframes->default_auto;
+                       plugins->insert_plugin(new_plugin->title,
+                               start_pos, end_pos - start_pos, new_plugin->plugin_type,
+                               &shared_location, default_keyframe, 0);
+                       track->expand_view = 1;
+               }
+               new_track = new_track->next;
+       }
+       return 0;
+}
+