3 #include "automation.h"
8 #include "edlsession.h"
10 #include "floatauto.h"
11 #include "floatautos.h"
13 #include "localsession.h"
18 #include "pluginset.h"
19 #include "mainsession.h"
23 #include "trackcanvas.h"
25 #include "transition.h"
26 #include "transportque.inc"
32 Track::Track(EDL *edl, Tracks *tracks) : ListItem<Track>()
35 this->tracks = tracks;
44 track_w = edl->session->output_w;
45 track_h = edl->session->output_h;
53 plugin_set.remove_all_objects();
56 int Track::create_objects()
62 int Track::copy_settings(Track *track)
64 this->expand_view = track->expand_view;
65 this->draw = track->draw;
66 this->gang = track->gang;
67 this->record = track->record;
68 this->nudge = track->nudge;
69 this->play = track->play;
70 this->track_w = track->track_w;
71 this->track_h = track->track_h;
72 strcpy(this->title, track->title);
82 int Track::load_defaults(Defaults *defaults)
87 void Track::equivalent_output(Track *track, double *result)
89 if(data_type != track->data_type ||
90 track_w != track->track_w ||
91 track_h != track->track_h ||
92 play != track->play ||
93 nudge != track->nudge)
96 // Convert result to track units
98 automation->equivalent_output(track->automation, &result2);
99 edits->equivalent_output(track->edits, &result2);
101 int plugin_sets = MIN(plugin_set.total, track->plugin_set.total);
102 // Test existing plugin sets
103 for(int i = 0; i < plugin_sets; i++)
105 plugin_set.values[i]->equivalent_output(
106 track->plugin_set.values[i],
110 // New EDL has more plugin sets. Get starting plugin in new plugin sets
111 for(int i = plugin_sets; i < plugin_set.total; i++)
113 Plugin *current = plugin_set.values[i]->get_first_plugin();
116 if(result2 < 0 || current->startproject < result2)
117 result2 = current->startproject;
121 // New EDL has fewer plugin sets. Get starting plugin in old plugin set
122 for(int i = plugin_sets; i < track->plugin_set.total; i++)
124 Plugin *current = track->plugin_set.values[i]->get_first_plugin();
127 if(result2 < 0 || current->startproject < result2)
128 result2 = current->startproject;
132 // Number of plugin sets differs but somehow we didn't find the start of the
134 if(track->plugin_set.total != plugin_set.total && result2 < 0)
138 (*result < 0 || from_units(result2) < *result))
139 *result = from_units(result2);
143 int Track::is_synthesis(RenderEngine *renderengine,
147 int is_synthesis = 0;
148 for(int i = 0; i < plugin_set.total; i++)
150 Plugin *plugin = get_current_plugin(position,
157 is_synthesis = plugin->is_synthesis(renderengine,
160 if(is_synthesis) break;
166 void Track::copy_from(Track *track)
168 copy_settings(track);
169 edits->copy_from(track->edits);
170 for(int i = 0; i < this->plugin_set.total; i++)
171 delete this->plugin_set.values[i];
172 this->plugin_set.remove_all_objects();
174 for(int i = 0; i < track->plugin_set.total; i++)
176 PluginSet *new_plugin_set = plugin_set.append(new PluginSet(edl, this));
177 new_plugin_set->copy_from(track->plugin_set.values[i]);
179 automation->copy_from(track->automation);
180 this->track_w = track->track_w;
181 this->track_h = track->track_h;
184 Track& Track::operator=(Track& track)
186 printf("Track::operator= 1\n");
191 int Track::vertical_span(Theme *theme)
195 result = edl->local_session->zoom_track +
197 theme->plugin_bg_data->get_h();
199 result = edl->local_session->zoom_track;
201 if(edl->session->show_titles)
202 result += theme->title_bg_data->get_h();
207 double Track::get_length()
209 double total_length = 0;
215 length = from_units(edits->last->startproject + edits->last->length);
216 if(length > total_length) total_length = length;
220 for(int i = 0; i < plugin_set.total; i++)
222 if(plugin_set.values[i]->last)
224 length = from_units(plugin_set.values[i]->last->startproject +
225 plugin_set.values[i]->last->length);
226 if(length > total_length) total_length = length;
231 length = from_units(automation->get_length());
232 if(length > total_length) total_length = length;
240 void Track::get_source_dimensions(double position, int &w, int &h)
242 int64_t native_position = to_units(position, 0);
243 for(Edit *current = edits->first; current; current = NEXT)
245 if(current->startproject <= native_position &&
246 current->startproject + current->length > native_position &&
249 w = current->asset->width;
250 h = current->asset->height;
257 int64_t Track::horizontal_span()
259 return (int64_t)(get_length() *
260 edl->session->sample_rate /
261 edl->local_session->zoom_sample +
266 int Track::load(FileXML *file, int track_offset, uint32_t load_flags)
269 int current_channel = 0;
270 int current_plugin = 0;
273 record = file->tag.get_property("RECORD", record);
274 play = file->tag.get_property("PLAY", play);
275 gang = file->tag.get_property("GANG", gang);
276 draw = file->tag.get_property("DRAW", draw);
277 nudge = file->tag.get_property("NUDGE", nudge);
278 expand_view = file->tag.get_property("EXPAND", expand_view);
279 track_w = file->tag.get_property("TRACK_W", track_w);
280 track_h = file->tag.get_property("TRACK_H", track_h);
282 load_header(file, load_flags);
285 result = file->read_tag();
289 if(file->tag.title_is("/TRACK"))
294 if(file->tag.title_is("TITLE"))
296 file->read_text_until("/TITLE", title);
299 if(strstr(file->tag.get_title(), "AUTOS"))
303 automation->load(file);
307 if(file->tag.title_is("EDITS"))
309 if(load_flags & LOAD_EDITS)
310 edits->load(file, track_offset);
313 if(file->tag.title_is("PLUGINSET"))
315 if(load_flags & LOAD_EDITS)
317 PluginSet *plugin_set = new PluginSet(edl, this);
318 this->plugin_set.append(plugin_set);
319 plugin_set->load(file, load_flags);
322 if(load_flags & LOAD_AUTOMATION)
324 if(current_plugin < this->plugin_set.total)
326 PluginSet *plugin_set = this->plugin_set.values[current_plugin];
327 plugin_set->load(file, load_flags);
333 load_derived(file, load_flags);
342 void Track::insert_asset(Asset *asset,
347 //printf("Track::insert_asset %f\n", length);
348 edits->insert_asset(asset,
350 to_units(position, 0),
356 // Default keyframes: We don't replace default keyframes in pasting but
357 // when inserting the first EDL of a load operation we need to replace
358 // the default keyframes.
360 // Plugins: This is an arbitrary behavior
362 // 1) No plugin in source track: Paste silence into destination
364 // 2) Plugin in source track: plugin in source track is inserted into
365 // existing destination track plugin sets, new sets being added when
368 void Track::insert_track(Track *track,
373 // Decide whether to copy settings based on load_mode
374 if(replace_default) copy_settings(track);
376 edits->insert_edits(track->edits, to_units(position, 0));
379 insert_plugin_set(track, position);
381 automation->insert_track(track->automation,
382 to_units(position, 0),
383 to_units(track->get_length(), 1),
389 // Called by insert_track
390 void Track::insert_plugin_set(Track *track, double position)
392 // Extend plugins if no incoming plugins
393 if(!track->plugin_set.total)
395 shift_effects(position,
400 for(int i = 0; i < track->plugin_set.total; i++)
402 if(i >= plugin_set.total)
403 plugin_set.append(new PluginSet(edl, this));
405 plugin_set.values[i]->insert_edits(track->plugin_set.values[i],
406 to_units(position, 0));
411 Plugin* Track::insert_effect(char *title,
412 SharedLocation *shared_location,
413 KeyFrame *default_keyframe,
414 PluginSet *plugin_set,
421 plugin_set = new PluginSet(edl, this);
422 this->plugin_set.append(plugin_set);
427 // Position is identical to source plugin
428 if(plugin_type == PLUGIN_SHAREDPLUGIN)
430 Track *source_track = tracks->get_item_number(shared_location->module);
433 Plugin *source_plugin = source_track->get_current_plugin(
434 edl->local_session->get_selectionstart(),
435 shared_location->plugin,
440 // From an attach operation
443 plugin = plugin_set->insert_plugin(title,
444 source_plugin->startproject,
445 source_plugin->length,
452 // From a drag operation
454 plugin = plugin_set->insert_plugin(title,
466 // This should be done in the caller
469 if(edl->local_session->get_selectionend() >
470 edl->local_session->get_selectionstart())
472 start = edl->local_session->get_selectionstart();
473 length = edl->local_session->get_selectionend() - start;
478 length = get_length();
481 //printf("Track::insert_effect %f %f %d %d\n", start, length, to_units(start, 0),
482 // to_units(length, 0));
484 plugin = plugin_set->insert_plugin(title,
492 //printf("Track::insert_effect 2 %f %f\n", start, length);
498 void Track::move_plugins_up(PluginSet *plugin_set)
500 for(int i = 0; i < this->plugin_set.total; i++)
502 if(this->plugin_set.values[i] == plugin_set)
506 PluginSet *temp = this->plugin_set.values[i - 1];
507 this->plugin_set.values[i - 1] = this->plugin_set.values[i];
508 this->plugin_set.values[i] = temp;
510 SharedLocation old_location, new_location;
511 new_location.module = old_location.module = tracks->number_of(this);
512 old_location.plugin = i;
513 new_location.plugin = i - 1;
514 tracks->change_plugins(old_location, new_location, 1);
520 void Track::move_plugins_down(PluginSet *plugin_set)
522 for(int i = 0; i < this->plugin_set.total; i++)
524 if(this->plugin_set.values[i] == plugin_set)
526 if(i == this->plugin_set.total - 1) break;
528 PluginSet *temp = this->plugin_set.values[i + 1];
529 this->plugin_set.values[i + 1] = this->plugin_set.values[i];
530 this->plugin_set.values[i] = temp;
532 SharedLocation old_location, new_location;
533 new_location.module = old_location.module = tracks->number_of(this);
534 old_location.plugin = i;
535 new_location.plugin = i + 1;
536 tracks->change_plugins(old_location, new_location, 1);
543 void Track::remove_asset(Asset *asset)
545 for(Edit *edit = edits->first; edit; edit = edit->next)
547 if(edit->asset && edit->asset == asset)
555 void Track::remove_pluginset(PluginSet *plugin_set)
558 for(i = 0; i < this->plugin_set.total; i++)
559 if(plugin_set == this->plugin_set.values[i]) break;
561 this->plugin_set.remove_object(plugin_set);
562 for(i++ ; i < this->plugin_set.total; i++)
564 SharedLocation old_location, new_location;
565 new_location.module = old_location.module = tracks->number_of(this);
566 old_location.plugin = i;
567 new_location.plugin = i - 1;
568 tracks->change_plugins(old_location, new_location, 0);
572 void Track::shift_keyframes(double position, double length, int convert_units)
576 position = to_units(position, 0);
577 length = to_units(length, 0);
580 automation->paste_silence(Units::to_int64(position),
581 Units::to_int64(position + length));
582 // Effect keyframes are shifted in shift_effects
585 void Track::shift_effects(double position, double length, int convert_units)
589 position = to_units(position, 0);
590 length = to_units(length, 0);
593 for(int i = 0; i < plugin_set.total; i++)
595 plugin_set.values[i]->shift_effects(Units::to_int64(position), Units::to_int64(length));
599 void Track::detach_effect(Plugin *plugin)
601 //printf("Track::detach_effect 1\n");
602 for(int i = 0; i < plugin_set.total; i++)
604 PluginSet *plugin_set = this->plugin_set.values[i];
605 for(Plugin *dest = (Plugin*)plugin_set->first;
607 dest = (Plugin*)dest->next)
611 int64_t start = plugin->startproject;
612 int64_t end = plugin->startproject + plugin->length;
614 plugin_set->clear(start, end);
615 plugin_set->paste_silence(start, end);
617 // Delete 0 length pluginsets
618 plugin_set->optimize();
619 //printf("Track::detach_effect 2 %d\n", plugin_set->length());
620 if(!plugin_set->length())
621 this->plugin_set.remove_object(plugin_set);
629 void Track::resample(double old_rate, double new_rate)
631 edits->resample(old_rate, new_rate);
632 automation->resample(old_rate, new_rate);
633 for(int i = 0; i < plugin_set.total; i++)
634 plugin_set.values[i]->resample(old_rate, new_rate);
635 nudge = (int64_t)(nudge * new_rate / old_rate);
640 void Track::optimize()
643 for(int i = 0; i < plugin_set.total; i++)
645 plugin_set.values[i]->optimize();
646 //printf("Track::optimize %d\n", plugin_set.values[i]->total());
647 if(plugin_set.values[i]->total() <= 0)
649 remove_pluginset(plugin_set.values[i]);
655 Plugin* Track::get_current_plugin(double position,
662 if(convert_units) position = to_units(position, 0);
663 if(use_nudge) position += nudge;
665 if(plugin_set >= this->plugin_set.total || plugin_set < 0) return 0;
667 //printf("Track::get_current_plugin 1 %d %d %d\n", position, this->plugin_set.total, direction);
668 if(direction == PLAY_FORWARD)
670 for(current = (Plugin*)this->plugin_set.values[plugin_set]->last;
672 current = (Plugin*)PREVIOUS)
674 // printf("Track::get_current_plugin 2 %d %ld %ld\n",
675 // current->startproject,
676 // current->startproject + current->length,
678 if(current->startproject <= position &&
679 current->startproject + current->length > position)
686 if(direction == PLAY_REVERSE)
688 for(current = (Plugin*)this->plugin_set.values[plugin_set]->first;
690 current = (Plugin*)NEXT)
692 if(current->startproject < position &&
693 current->startproject + current->length >= position)
703 Plugin* Track::get_current_transition(double position,
710 if(convert_units) position = to_units(position, 0);
711 if(use_nudge) position += nudge;
713 if(direction == PLAY_FORWARD)
715 for(current = edits->last; current; current = PREVIOUS)
717 if(current->startproject <= position && current->startproject + current->length > position)
719 //printf("Track::get_current_transition %p\n", current->transition);
720 if(current->transition && position < current->startproject + current->transition->length)
722 result = current->transition;
729 if(direction == PLAY_REVERSE)
731 for(current = edits->first; current; current = NEXT)
733 if(current->startproject < position && current->startproject + current->length >= position)
735 if(current->transition && position <= current->startproject + current->transition->length)
737 result = current->transition;
747 void Track::synchronize_params(Track *track)
749 for(Edit *this_edit = edits->first, *that_edit = track->edits->first;
750 this_edit && that_edit;
751 this_edit = this_edit->next, that_edit = that_edit->next)
753 this_edit->synchronize_params(that_edit);
756 for(int i = 0; i < plugin_set.total && i < track->plugin_set.total; i++)
757 plugin_set.values[i]->synchronize_params(track->plugin_set.values[i]);
759 automation->copy_from(track->automation);
760 this->nudge = track->nudge;
769 printf(" Data type %d\n", data_type);
770 printf(" Title %s\n", title);
772 for(Edit* current = edits->first; current; current = NEXT)
777 printf(" Plugin Sets: %d\n", plugin_set.total);
779 for(int i = 0; i < plugin_set.total; i++)
780 plugin_set.values[i]->dump();
781 //printf("Track::dump 2\n");
805 Track::Track() : ListItem<Track>()
810 // ======================================== accounting
812 int Track::number_of()
814 return tracks->number_of(this);
829 // ================================================= editing
831 int Track::select_auto(AutoConf *auto_conf, int cursor_x, int cursor_y)
836 int Track::move_auto(AutoConf *auto_conf, int cursor_x, int cursor_y, int shift_down)
841 int Track::release_auto()
846 // used for copying automation alone
847 int Track::copy_automation(double selectionstart,
853 int64_t start = to_units(selectionstart, 0);
854 int64_t end = to_units(selectionend, 0);
856 file->tag.set_title("TRACK");
860 file->append_newline();
862 automation->copy(start, end, file, default_only, autos_only);
864 if(edl->session->auto_conf->plugins)
866 file->tag.set_title("PLUGINSETS");
868 file->append_newline();
869 for(int i = 0; i < plugin_set.total; i++)
872 plugin_set.values[i]->copy_keyframes(start,
878 file->tag.set_title("/PLUGINSETS");
880 file->append_newline();
883 file->tag.set_title("/TRACK");
885 file->append_newline();
886 file->append_newline();
887 file->append_newline();
888 file->append_newline();
893 int Track::paste_automation(double selectionstart,
900 // Only used for pasting automation alone.
906 if(data_type == TRACK_AUDIO)
907 scale = edl->session->sample_rate / sample_rate;
909 scale = edl->session->frame_rate / frame_rate;
911 total_length *= scale;
912 start = to_units(selectionstart, 0);
913 length = to_units(total_length, 0);
915 //printf("Track::paste_automation 1\n");
919 result = file->read_tag();
923 if(file->tag.title_is("/TRACK"))
926 if(strstr(file->tag.get_title(), "AUTOS"))
928 automation->paste(start,
936 if(file->tag.title_is("PLUGINSETS"))
938 //printf("Track::paste_automation 2 %d\n", current_pluginset);
939 PluginSet::paste_keyframes(start,
947 //printf("Track::paste_automation 3\n");
953 void Track::clear_automation(double selectionstart,
958 int64_t start = to_units(selectionstart, 0);
959 int64_t end = to_units(selectionend, 0);
961 automation->clear(start, end, edl->session->auto_conf, 0);
963 if(edl->session->auto_conf->plugins)
965 for(int i = 0; i < plugin_set.total; i++)
967 plugin_set.values[i]->clear_keyframes(start, end);
974 int Track::copy(double start,
979 // Use a copy of the selection in converted units
980 // So copy_automation doesn't reconvert.
981 int64_t start_unit = to_units(start, 0);
982 int64_t end_unit = to_units(end, 1);
987 file->tag.set_title("TRACK");
988 file->tag.set_property("RECORD", record);
989 file->tag.set_property("NUDGE", nudge);
990 file->tag.set_property("PLAY", play);
991 file->tag.set_property("GANG", gang);
992 file->tag.set_property("DRAW", draw);
993 file->tag.set_property("EXPAND", expand_view);
994 file->tag.set_property("TRACK_W", track_w);
995 file->tag.set_property("TRACK_H", track_h);
998 file->append_newline();
1001 file->tag.set_title("TITLE");
1003 file->append_text(title);
1004 file->tag.set_title("/TITLE");
1006 file->append_newline();
1010 edits->copy(start_unit, end_unit, file, output_path);
1013 auto_conf.set_all();
1014 automation->copy(start_unit, end_unit, file, 0, 0);
1017 for(int i = 0; i < plugin_set.total; i++)
1019 plugin_set.values[i]->copy(start_unit, end_unit, file);
1022 copy_derived(start_unit, end_unit, file);
1024 file->tag.set_title("/TRACK");
1026 file->append_newline();
1027 file->append_newline();
1028 file->append_newline();
1029 file->append_newline();
1034 int Track::copy_assets(double start,
1036 ArrayList<Asset*> *asset_list)
1040 start = to_units(start, 0);
1041 end = to_units(end, 0);
1043 Edit *current = edits->editof((int64_t)start, PLAY_FORWARD, 0);
1046 while(current && current->startproject < end)
1048 // Check for duplicate assets
1051 for(i = 0, result = 0; i < asset_list->total; i++)
1053 if(asset_list->values[i] == current->asset) result = 1;
1055 // append pointer to new asset
1056 if(!result) asset_list->append(current->asset);
1069 int Track::clear(double start,
1077 // Edits::move_auto calls this routine after the units are converted to the track
1079 //printf("Track::clear 1 %d %d %d\n", edit_edits, edit_labels, edit_plugins);
1082 start = to_units(start, 0);
1083 end = to_units(end, 0);
1087 automation->clear((int64_t)start, (int64_t)end, 0, 1);
1090 for(int i = 0; i < plugin_set.total; i++)
1092 if(!trim_edits || trim_edits == (Edits*)plugin_set.values[i])
1093 plugin_set.values[i]->clear((int64_t)start, (int64_t)end);
1097 edits->clear((int64_t)start, (int64_t)end);
1101 int Track::clear_handle(double start,
1107 edits->clear_handle(start, end, clear_plugins, distance);
1110 int Track::popup_transition(int cursor_x, int cursor_y)
1117 int Track::modify_edithandles(double oldposition,
1124 edits->modify_handles(oldposition,
1137 int Track::modify_pluginhandles(double oldposition,
1144 for(int i = 0; i < plugin_set.total; i++)
1146 if(!trim_edits || trim_edits == (Edits*)plugin_set.values[i])
1147 plugin_set.values[i]->modify_handles(oldposition,
1151 // Don't allow plugin tweeks to affect edits.
1161 int Track::paste_silence(double start, double end, int edit_plugins)
1163 start = to_units(start, 0);
1164 end = to_units(end, 1);
1166 edits->paste_silence((int64_t)start, (int64_t)end);
1167 shift_keyframes(start, end - start, 0);
1168 if(edit_plugins) shift_effects(start, end - start, 0);
1174 int Track::select_edit(int cursor_x,
1182 int Track::scale_time(float rate_scale, int scale_edits, int scale_autos, int64_t start, int64_t end)
1187 void Track::change_plugins(SharedLocation &old_location, SharedLocation &new_location, int do_swap)
1189 for(int i = 0; i < plugin_set.total; i++)
1191 for(Plugin *plugin = (Plugin*)plugin_set.values[i]->first;
1193 plugin = (Plugin*)plugin->next)
1195 if(plugin->plugin_type == PLUGIN_SHAREDPLUGIN)
1197 if(plugin->shared_location == old_location)
1198 plugin->shared_location = new_location;
1200 if(do_swap && plugin->shared_location == new_location)
1201 plugin->shared_location = old_location;
1207 void Track::change_modules(int old_location, int new_location, int do_swap)
1209 for(int i = 0; i < plugin_set.total; i++)
1211 for(Plugin *plugin = (Plugin*)plugin_set.values[i]->first;
1213 plugin = (Plugin*)plugin->next)
1215 if(plugin->plugin_type == PLUGIN_SHAREDPLUGIN ||
1216 plugin->plugin_type == PLUGIN_SHAREDMODULE)
1218 if(plugin->shared_location.module == old_location)
1219 plugin->shared_location.module = new_location;
1221 if(do_swap && plugin->shared_location.module == new_location)
1222 plugin->shared_location.module = old_location;
1229 int Track::delete_module_pointers(int deleted_track)
1231 for(int i = 0; i < plugin_set.total; i++)
1233 for(Plugin *plugin = (Plugin*)plugin_set.values[i]->first;
1235 plugin = (Plugin*)plugin->next)
1237 if(plugin->plugin_type == PLUGIN_SHAREDPLUGIN ||
1238 plugin->plugin_type == PLUGIN_SHAREDMODULE)
1240 if(plugin->shared_location.module == deleted_track)
1246 plugin->shared_location.module--;
1255 int Track::playable_edit(int64_t position, int direction)
1258 if(direction == PLAY_REVERSE) position--;
1259 for(Edit *current = edits->first; current && !result; current = NEXT)
1261 if(current->startproject <= position &&
1262 current->startproject + current->length > position)
1264 //printf("Track::playable_edit %p %p\n", current->transition, current->asset);
1265 if(current->transition || current->asset) result = 1;
1272 int Track::need_edit(Edit *current, int test_transitions)
1274 return ((test_transitions && current->transition) ||
1275 (!test_transitions && current->asset));
1278 int64_t Track::plugin_change_duration(int64_t input_position,
1279 int64_t input_length,
1283 if(use_nudge) input_position += nudge;
1284 for(int i = 0; i < plugin_set.total; i++)
1286 int64_t new_duration = plugin_set.values[i]->plugin_change_duration(
1290 if(new_duration < input_length) input_length = new_duration;
1292 return input_length;
1295 int64_t Track::edit_change_duration(int64_t input_position,
1296 int64_t input_length,
1298 int test_transitions,
1302 int64_t edit_length = input_length;
1303 if(use_nudge) input_position += nudge;
1307 // ================================= Reverse playback
1308 // Get first edit on or after position
1309 for(current = edits->first;
1310 current && current->startproject + current->length <= input_position;
1316 if(current->startproject > input_position)
1318 // Before first edit
1322 if(need_edit(current, test_transitions))
1324 // Over an edit of interest.
1325 if(input_position - current->startproject < input_length)
1326 edit_length = input_position - current->startproject + 1;
1330 // Over an edit that isn't of interest.
1331 // Search for next edit of interest.
1332 for(current = PREVIOUS ;
1334 current->startproject + current->length > input_position - input_length &&
1335 !need_edit(current, test_transitions);
1340 need_edit(current, test_transitions) &&
1341 current->startproject + current->length > input_position - input_length)
1342 edit_length = input_position - current->startproject - current->length + 1;
1347 // Not over an edit. Try the last edit.
1348 current = edits->last;
1350 ((test_transitions && current->transition) ||
1351 (!test_transitions && current->asset)))
1352 edit_length = input_position - edits->last->startproject - edits->last->length + 1;
1357 // =================================== forward playback
1358 // Get first edit on or before position
1359 for(current = edits->last;
1360 current && current->startproject > input_position;
1366 if(current->startproject + current->length <= input_position)
1368 // Beyond last edit.
1372 if(need_edit(current, test_transitions))
1374 // Over an edit of interest.
1375 // Next edit is going to require a change.
1376 if(current->length + current->startproject - input_position < input_length)
1377 edit_length = current->startproject + current->length - input_position;
1381 // Over an edit that isn't of interest.
1382 // Search for next edit of interest.
1383 for(current = NEXT ;
1385 current->startproject < input_position + input_length &&
1386 !need_edit(current, test_transitions);
1391 need_edit(current, test_transitions) &&
1392 current->startproject < input_position + input_length)
1393 edit_length = current->startproject - input_position;
1398 // Not over an edit. Try the first edit.
1399 current = edits->first;
1401 ((test_transitions && current->transition) ||
1402 (!test_transitions && current->asset)))
1403 edit_length = edits->first->startproject - input_position;
1407 if(edit_length < input_length)
1410 return input_length;
1413 int Track::purge_asset(Asset *asset)
1418 int Track::asset_used(Asset *asset)
1423 for(current_edit = edits->first; current_edit; current_edit = current_edit->next)
1425 if(current_edit->asset == asset)
1433 int Track::channel_is_playable(int64_t position, int direction, int *do_channel)
1439 int Track::plugin_used(int64_t position, int64_t direction)
1441 //printf("Track::plugin_used 1 %d\n", this->plugin_set.total);
1442 for(int i = 0; i < this->plugin_set.total; i++)
1444 Plugin *current_plugin = get_current_plugin(position,
1450 //printf("Track::plugin_used 2 %p\n", current_plugin);
1451 if(current_plugin &&
1452 (current_plugin->on &&
1453 current_plugin->plugin_type != PLUGIN_NONE))
1458 //printf("Track::plugin_used 3 %p\n", current_plugin);
1462 // Audio is always rendered through VConsole
1463 int Track::direct_copy_possible(int64_t start, int direction, int use_nudge)
1468 int64_t Track::to_units(double position, int round)
1470 return (int64_t)position;
1473 double Track::to_doubleunits(double position)
1478 double Track::from_units(int64_t position)
1480 return (double)position;