Plugin* PluginSet::insert_plugin(const char *title, int64_t unit_position, int64_t unit_length, int plugin_type, SharedLocation *shared_location, KeyFrame *default_keyframe, int do_optimize) { Plugin *plugin = (Plugin*)paste_silence(unit_position, unit_position + unit_length); if(title) strcpy(plugin->title, title); if(shared_location) plugin->shared_location = *shared_location; plugin->plugin_type = plugin_type; if(default_keyframe) *plugin->keyframes->default_auto = *default_keyframe; plugin->keyframes->default_auto->position = unit_position; // May delete the plugin we just added so not desirable while loading. if(do_optimize) optimize(); return plugin; }
void Edits::insert_edits(Edits *source_edits, int64_t position, int64_t min_length, int edit_autos) { int64_t clipboard_end = position + min_length; // Length pasted so far int64_t source_len = 0; // Fill region between end of edit table and beginning of pasted segment // with silence. Can't call from insert_new_edit because it's recursive. if(position > length()) { paste_silence(length(), position); } for(Edit *source_edit = source_edits->first; source_edit; source_edit = source_edit->next) { EDL *dest_nested_edl = 0; if(source_edit->nested_edl) dest_nested_edl = edl->nested_edls->get_copy(source_edit->nested_edl); // Update Assets Asset *dest_asset = 0; if(source_edit->asset) dest_asset = edl->assets->update(source_edit->asset); // Open destination area Edit *dest_edit = insert_new_edit(position + source_edit->startproject); dest_edit->copy_from(source_edit); dest_edit->asset = dest_asset; dest_edit->nested_edl = dest_nested_edl; dest_edit->startproject = position + source_edit->startproject; // Shift keyframes in source edit to their position in the // destination edit for plugin case if(edit_autos) dest_edit->shift_keyframes(position); // Shift following edits and keyframes in following edits by length // in current source edit. for(Edit *future_edit = dest_edit->next; future_edit; future_edit = future_edit->next) { future_edit->startproject += dest_edit->length; future_edit->shift_keyframes(dest_edit->length); } source_len += source_edit->length; } // Fill remaining clipboard length with silence if(source_len < min_length) { //printf("Edits::insert_edits %d\n", __LINE__); paste_silence(position + source_len, position + min_length); } }