/*
* CINELERRA
- * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
+ * Copyright (C) 2008-2017 Adam Williams <broadcast at earthling dot net>
*
* 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
if(current_edit->asset && current_edit->next->asset) {
- if(current_edit->asset->equivalent(*current_edit->next->asset,
- 0, 0)) {
+ if(current_edit->asset->equivalent(*current_edit->next->asset, 0, 0, edl)) {
// Got two consecutive edits in same source
if(edl->equivalent(track->from_units(current_edit->next->startproject),
else
{
// move end of edit out
-//printf("Edits::modify_handle 6\n");
+//printf("Edits::modify_handle %d edit_mode=%d\n", __LINE__, edit_mode);
current_edit->shift_end_out(edit_mode,
track->to_units(newposition, 0),
track->to_units(oldposition, 0),
}
return new_edit;
}
-
+
Edit* Edits::shift(int64_t position, int64_t difference)
{
Edit *new_edit = split_edit(position);
track->shift_effects(position, length, edit_autos);
}
+// only used for audio but also used for plugins which inherit from Edits
+void Edits::deglitch(int64_t position)
+{
+// range from the splice junk appears
+ int64_t threshold = (int64_t)((double)edl->session->sample_rate /
+ edl->session->frame_rate) / 2;
+ Edit *current = 0;
+
+// the last edit before the splice
+ Edit *edit1 = 0;
+ if(first)
+ {
+ for(current = first; current; current = NEXT)
+ {
+ if(current->startproject + current->length >= position - threshold)
+ {
+ edit1 = current;
+ break;
+ }
+ }
+
+// ignore if it ends after the splice
+ if(current && current->startproject + current->length >= position)
+ {
+ edit1 = 0;
+ }
+ }
+
+// the first edit after the splice
+ Edit *edit2 = 0;
+ if(last)
+ {
+ for(current = last; current; current = PREVIOUS)
+ {
+ if(current->startproject < position + threshold)
+ {
+ edit2 = current;
+ break;
+ }
+ }
+
+ // ignore if it starts before the splice
+ if(current && current->startproject < position)
+ {
+ edit2 = 0;
+ }
+ }
+
+
+
+
+// printf("Edits::deglitch %d position=%ld edit1=%p edit2=%p\n", __LINE__,
+// position,
+// edit1,
+// edit2);
+// delete junk between the edits
+ if(edit1 != edit2)
+ {
+ if(edit1 != 0)
+ {
+// end the starting edit later
+ current = edit1->next;
+ while(current != 0 &&
+ current != edit2 &&
+ current->startproject < position)
+ {
+ Edit* next = NEXT;
+
+ edit1->length += current->length;
+ remove(current);
+
+ current = next;
+ }
+ }
+
+ if(edit2 != 0)
+ {
+// start the ending edit earlier
+ current = edit2->previous;
+ while(current != 0 &&
+ current != edit1 &&
+ current->startproject >= position)
+ {
+ Edit *previous = PREVIOUS;
+
+ int64_t length = current->length;
+//printf("Edits::deglitch %d length=%ld\n", __LINE__, length);
+ if(!edit2->silence() &&
+ length > edit2->startsource)
+ {
+ length = edit2->startsource;
+ }
+
+ // shift edit2 by using material from its source
+ edit2->startproject -= length;
+ edit2->startsource -= length;
+ // assume enough is at the end
+ edit2->length += length;
+
+ // shift edit2 & its source earlier by remainder
+ if(length < current->length)
+ {
+ int64_t remainder = current->length - length;
+ edit2->startproject -= remainder;
+ // assume enough is at the end
+ edit2->length += remainder;
+ }
+
+ remove(current);
+
+
+ current = previous;
+ }
+ }
+ }
+
+}
+
+
+
+