X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fpluginset.C;h=e1f1215e9f6beba10f7bd85ac7f7aa6062296269;hp=6805d8ae171a7409c9c82a2af9c80c71352bb152;hb=abf5c6bb4dec2c2d03df2872e1d337e3905b3619;hpb=5cdeee0e01761c9d53c45ab7d8983f7fb376a487 diff --git a/cinelerra-5.1/cinelerra/pluginset.C b/cinelerra-5.1/cinelerra/pluginset.C index 6805d8ae..e1f1215e 100644 --- a/cinelerra-5.1/cinelerra/pluginset.C +++ b/cinelerra-5.1/cinelerra/pluginset.C @@ -138,24 +138,15 @@ void PluginSet::synchronize_params(PluginSet *plugin_set) } Plugin* PluginSet::insert_plugin(const char *title, - int64_t unit_position, - int64_t unit_length, - int plugin_type, - SharedLocation *shared_location, - KeyFrame *default_keyframe, + int64_t unit_position, int64_t unit_length, int plugin_type, + SharedLocation *shared_location, KeyFrame *default_keyframe, int do_optimize) { Plugin *plugin = (Plugin*)create_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; - + plugin->init(title, unit_position, unit_length, plugin_type, + shared_location, default_keyframe); // May delete the plugin we just added so not desirable while loading. - if(do_optimize) optimize(); + if( do_optimize ) optimize(); return plugin; } @@ -352,6 +343,19 @@ void PluginSet::shift_effects(int64_t start, int64_t length, int edit_autos) } } +void PluginSet::paste_silence(int64_t start, int64_t end, int edit_autos) +{ + Plugin *new_plugin = (Plugin *) insert_new_edit(start); + int64_t length = end - start; + new_plugin->length = length; + while( (new_plugin=(Plugin *)new_plugin->next) != 0 ) { + new_plugin->startproject += length; + if( !edit_autos ) continue; + new_plugin->keyframes->default_auto->position += length; + new_plugin->keyframes->paste_silence(start, end); + } +} + void PluginSet::copy(int64_t start, int64_t end, FileXML *file) { file->tag.set_title("PLUGINSET"); @@ -438,6 +442,13 @@ int PluginSet::optimize() int result = 1; Plugin *current_edit; +// trim plugins before position 0 + while( first && first->startproject+first->length < 0 ) + delete first; + if( first && first->startproject < 0 ) { + first->length += first->startproject; + first->startproject = 0; + } // Delete keyframes out of range for(current_edit = (Plugin*)first;