4 * Copyright (C) 2010 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "arraylist.h"
30 #include "autoconf.inc"
31 #include "automation.inc"
37 #include "filexml.inc"
38 #include "floatautos.inc"
40 #include "indexable.inc"
41 #include "keyframe.inc"
46 #include "pluginset.inc"
47 #include "sharedlocation.inc"
49 #include "intautos.inc"
50 #include "trackcanvas.inc"
52 #include "transition.inc"
54 // UNITS ARE SAMPLES FOR ALL
56 class Track : public ListItem<Track>
59 Track(EDL *edl, Tracks *tracks);
63 void create_objects();
65 virtual int load_defaults(BC_Hash *defaults);
66 int load(FileXML *file, int track_offset, uint32_t load_flags);
67 virtual int save_header(FileXML *file) { return 0; };
68 virtual int save_derived(FileXML *file) { return 0; };
69 virtual int load_header(FileXML *file, uint32_t load_flags) { return 0; };
70 virtual int load_derived(FileXML *file, uint32_t load_flags) { return 0; };
71 void equivalent_output(Track *track, double *result);
73 virtual void copy_from(Track *track);
74 Track& operator=(Track& track);
75 virtual PluginSet* new_plugins() { return 0; };
76 // Synchronize playback numbers
77 virtual void synchronize_params(Track *track);
79 // Get number of pixels to display
80 virtual int vertical_span(Theme *theme);
81 int64_t horizontal_span();
82 void resample(double old_rate, double new_rate);
86 // Get length of track in seconds
88 // Get dimensions of source for convenience functions
89 void get_source_dimensions(double position, int &w, int &h);
92 void insert_asset(Asset *asset,
97 Plugin* insert_effect(const char *title,
98 SharedLocation *shared_location,
100 PluginSet *plugin_set,
104 void insert_plugin_set(Track *track,
108 void detach_effect(Plugin *plugin);
109 // Insert a track from another EDL
110 void insert_track(Track *track,
115 // Pad pasted sections to a minimum of this length.
117 void shuffle_edits(double start, double end, int first_track);
118 void reverse_edits(double start, double end, int first_track);
119 void align_edits(double start,
121 ArrayList<double> *times);
124 int is_muted(int64_t position, int direction); // Test muting status
126 void move_plugins_up(PluginSet *plugin_set);
127 void move_plugins_down(PluginSet *plugin_set);
128 void remove_pluginset(PluginSet *plugin_set);
129 void remove_asset(Indexable *asset);
131 // Used for determining a selection for editing so leave as int.
132 // converts the selection to SAMPLES OR FRAMES and stores in value
133 virtual int64_t to_units(double position, int round);
135 virtual double to_doubleunits(double position);
136 virtual double from_units(int64_t position);
140 // Positions are identical for handle modifications
141 virtual int identical(int64_t sample1, int64_t sample2) { return 0; };
143 // Get the plugin belonging to the set.
144 Plugin* get_current_plugin(double position,
149 Plugin* get_current_transition(double position,
154 // detach shared effects referencing module
155 void detach_shared_effects(int module);
158 // Called by playable tracks to test for playable server.
159 // Descends the plugin tree without creating a virtual console.
160 // Used by PlayableTracks::is_playable.
161 int is_synthesis(int64_t position,
164 // Used by PlayableTracks::is_playable
165 // Returns 1 if the track is in the output boundaries.
166 virtual int is_playable(int64_t position,
169 // Test direct copy conditions common to all the rendering routines
170 virtual int direct_copy_possible(int64_t start, int direction, int use_nudge);
172 // Used by PlayableTracks::is_playable
173 int plugin_used(int64_t position, int64_t direction);
179 virtual int copy_settings(Track *track);
180 void shift_keyframes(int64_t position, int64_t length);
181 void shift_effects(int64_t position, int64_t length, int edit_autos);
182 void change_plugins(SharedLocation &old_location,
183 SharedLocation &new_location,
185 void change_modules(int old_location,
188 int plugin_exists(Plugin *plugin);
194 // Plugin set uses key frames for automation
195 ArrayList<PluginSet*> plugin_set;
196 Automation *automation;
198 // Vertical offset from top of timeline
202 // There is some debate on whether to expand gang from faders to
203 // dragging operations. This would allow every edit in a column to get dragged
206 char title[BCTEXTLEN];
209 // Nudge in track units. Positive shifts track earlier in time. This way
210 // the position variables only need to add the nudge.
212 // TRACK_AUDIO or TRACK_VIDEO
233 int load_automation(FileXML *file);
234 int load_edits(FileXML *file);
236 virtual int change_channels(int oldchannels, int newchannels) { return 0; };
237 virtual int dump(FILE *fp);
241 // ===================================== editing
242 int copy(double start, double end,
243 FileXML *file, const char *output_path = "");
244 int copy_assets(double start,
246 ArrayList<Asset*> *asset_list);
247 virtual int copy_derived(int64_t start, int64_t end, FileXML *file) { return 0; };
248 virtual int paste_derived(int64_t start, int64_t end, int64_t total_length, FileXML *file, int ¤t_channel) { return 0; };
249 int clear(double start,
257 // Returns the point to restart background rendering at.
258 // -1 means nothing changed.
259 void clear_automation(double selectionstart,
261 int shift_autos /* = 1 */,
262 int default_only /* = 0 */);
263 void set_automation_mode(double selectionstart,
266 virtual int clear_automation_derived(AutoConf *auto_conf,
267 double selectionstart,
269 int shift_autos = 1) { return 0; };
270 virtual int clear_derived(double start,
271 double end) { return 0; };
273 int copy_automation(double selectionstart,
278 virtual int copy_automation_derived(AutoConf *auto_conf,
279 double selectionstart,
281 FileXML *file) { return 0; };
282 int paste_automation(double selectionstart,
289 virtual int paste_automation_derived(double selectionstart,
294 int ¤t_pan) { return 0; };
295 int paste_auto_silence(double start, double end);
296 virtual int paste_auto_silence_derived(int64_t start, int64_t end) { return 0; };
297 int scale_time(float rate_scale, int scale_edits, int scale_autos, int64_t start, int64_t end);
298 virtual int scale_time_derived(float rate_scale, int scale_edits, int scale_autos, int64_t start, int64_t end) { return 0; };
299 int purge_asset(Asset *asset);
300 int asset_used(Asset *asset);
301 int clear_handle(double start,
307 int paste_silence(double start, double end, int edit_plugins, int edit_autos);
308 virtual int select_translation(int cursor_x, int cursor_y) { return 0; }; // select video coordinates for frame
309 virtual int update_translation(int cursor_x, int cursor_y, int shift_down) { return 0; }; // move video coordinates
310 int select_auto(AutoConf *auto_conf, int cursor_x, int cursor_y);
311 virtual int select_auto_derived(float zoom_units, float view_start, AutoConf *auto_conf, int cursor_x, int cursor_y) { return 0; };
312 int move_auto(AutoConf *auto_conf, int cursor_x, int cursor_y, int shift_down);
313 virtual int move_auto_derived(float zoom_units, float view_start, AutoConf *auto_conf, int cursor_x, int cursor_y, int shift_down) { return 0; };
315 virtual int release_auto_derived() { return 0; };
316 // Return whether automation would prevent direct frame copies. Not fully implemented.
317 int automation_is_used(int64_t start, int64_t end);
318 virtual int automation_is_used_derived(int64_t start, int64_t end) { return 0; }
320 int popup_transition(int cursor_x, int cursor_y);
322 // Return 1 if the left handle was selected 2 if the right handle was selected 3 if the track isn't recordable
323 int modify_edithandles(double oldposition,
330 int modify_pluginhandles(double oldposition,
337 int select_edit(int cursor_x,
341 virtual int end_translation() { return 0; };
342 virtual int reset_translation(int64_t start, int64_t end) { return 0; };
343 int feather_edits(int64_t start, int64_t end, int64_t units);
344 int64_t get_feather(int64_t selectionstart, int64_t selectionend);
347 // Absolute number of this track
350 // get_dimensions is used for getting drawing regions so use floats for partial frames
351 // get the display dimensions in SAMPLES OR FRAMES
352 // virtual int get_dimensions(double &view_start,
353 // double &view_units,
354 // double &zoom_units) { return 0; };
355 // Longest time from current_position in which nothing changes
356 int64_t edit_change_duration(int64_t input_position,
357 int64_t input_length,
359 int test_transitions,
361 int64_t plugin_change_duration(int64_t input_position,
362 int64_t input_length,
365 // Utility for edit_change_duration.
366 int need_edit(Edit *current, int test_transitions);
367 // If the edit under position is playable.
368 // Used by PlayableTracks::is_playable.
369 int playable_edit(int64_t position, int direction);
371 // ===================================== for handles, titles, etc
373 int64_t old_view_start;
374 int pixel; // pixel position from top of track view
375 // Dimensions of this track if video
376 int track_w, track_h;
382 // Identification of the track