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);
62 void create_objects();
64 virtual int load_defaults(BC_Hash *defaults);
65 int load(FileXML *file, int track_offset, uint32_t load_flags);
66 virtual int save_header(FileXML *file) { return 0; };
67 virtual int save_derived(FileXML *file) { return 0; };
68 virtual int load_header(FileXML *file, uint32_t load_flags) { return 0; };
69 virtual int load_derived(FileXML *file, uint32_t load_flags) { return 0; };
70 void equivalent_output(Track *track, double *result);
73 void get_fauto_xyz(int fauto, float &x, float &y, float &z);
74 void set_fauto_xyz(int fauto, float x, float y, float z);
75 void get_projector(float &x, float &y, float &z);
76 void set_projector(float x, float y, float z);
77 void get_camera(float &x, float &y, float &z);
78 void set_camera(float x, float y, float z);
80 virtual void copy_from(Track *track);
81 Track& operator=(Track& track);
82 virtual PluginSet* new_plugins() { return 0; };
83 // Synchronize playback numbers
84 virtual void synchronize_params(Track *track);
86 // Get number of pixels to display
87 virtual int vertical_span(Theme *theme);
88 int64_t horizontal_span();
89 void resample(double old_rate, double new_rate);
93 // Get length of track in seconds
95 // Get dimensions of source for convenience functions
96 void get_source_dimensions(double position, int &w, int &h);
99 void insert_asset(Asset *asset, EDL *nested_edl,
100 double length, double position, int track_number);
101 Plugin* insert_effect(const char *title, SharedLocation *shared_location,
102 KeyFrame *keyframe, PluginSet *plugin_set,
103 double start, double length, int plugin_type);
104 void insert_plugin_set(Track *track, int64_t position,
105 int64_t min_length, int edit_autos);
106 void detach_effect(Plugin *plugin);
107 // Insert a track from another EDL
108 void insert_track(Track *track, double position,
109 int replace_default, int edit_plugins, int edit_autos,
110 // Pad pasted sections to a minimum of this length.
112 void shuffle_edits(double start, double end, int first_track);
113 void reverse_edits(double start, double end, int first_track);
114 void align_edits(double start, double end, Track *master_track);
117 int is_muted(int64_t position, int direction); // Test muting status
119 void move_plugins_up(PluginSet *plugin_set);
120 void move_plugins_down(PluginSet *plugin_set);
121 void remove_pluginset(PluginSet *plugin_set);
122 void remove_asset(Indexable *asset);
124 // Used for determining a selection for editing so leave as int.
125 // converts the selection to SAMPLES OR FRAMES and stores in value
126 virtual int64_t to_units(double position, int round);
128 virtual double to_doubleunits(double position);
129 virtual double from_units(int64_t position);
132 // Positions are identical for handle modifications
133 virtual int identical(int64_t sample1, int64_t sample2) { return 0; };
135 // Get the plugin belonging to the set.
136 Plugin* get_current_plugin(double position,
137 int plugin_set, int direction, int convert_units, int use_nudge);
138 Plugin* get_current_transition(double position,
139 int direction, int convert_units, int use_nudge);
141 // detach shared effects referencing module
142 void detach_shared_effects(int module);
145 // Called by playable tracks to test for playable server.
146 // Descends the plugin tree without creating a virtual console.
147 // Used by PlayableTracks::is_playable.
148 int is_synthesis(int64_t position, int direction, int depth=0);
150 // Used by PlayableTracks::is_playable
151 // Returns 1 if the track is in the output boundaries.
152 virtual int is_playable(int64_t position, int direction);
154 // Test direct copy conditions common to all the rendering routines
155 virtual int direct_copy_possible(int64_t start, int direction, int use_nudge);
157 // Used by PlayableTracks::is_playable
158 int plugin_used(int64_t position, int64_t direction);
159 // align to frame boundary
160 int64_t frame_align(int64_t position, int round);
162 virtual int copy_settings(Track *track);
163 void shift_keyframes(int64_t position, int64_t length);
164 void shift_effects(int64_t position, int64_t length, int edit_autos, Edits *trim_edits);
165 void change_plugins(SharedLocation &old_location, SharedLocation &new_location, int do_swap);
166 void change_modules(int old_location, int new_location, int do_swap);
167 Plugin *plugin_exists(int plugin_id);
173 // Plugin set uses key frames for automation
174 ArrayList<PluginSet*> plugin_set;
175 Automation *automation;
177 // Vertical offset from top of timeline
179 // Vertical height of the track asset
183 // There is some debate on whether to expand gang from faders to
184 // dragging operations. This would allow every edit in a column to get dragged
187 char title[BCTEXTLEN];
190 // mask enable bit flags
192 // Nudge in track units. Positive shifts track earlier in time. This way
193 // the position variables only need to add the nudge.
195 // TRACK_AUDIO or TRACK_VIDEO
199 int load_automation(FileXML *file);
200 int load_edits(FileXML *file);
202 virtual int change_channels(int oldchannels, int newchannels) { return 0; };
203 virtual int dump(FILE *fp);
205 // ===================================== editing
206 int copy(int copy_flags, double start, double end,
207 FileXML *file, const char *output_path = "");
208 int copy_assets(double start, double end, ArrayList<Asset*> *asset_list);
209 virtual int copy_derived(int64_t start, int64_t end, FileXML *file) { return 0; };
210 virtual int paste_derived(int64_t start, int64_t end,
211 int64_t total_length, FileXML *file, int ¤t_channel) { return 0; };
212 int blade(double position);
213 int clear(double start, double end,
214 int edit_edits, int edit_labels, int clear_plugins,
215 int edit_autos, Edits *trim_edits);
216 int clear(int64_t start, int64_t end,
217 int edit_edits, int edit_labels, int clear_plugins,
218 int edit_autos, Edits *trim_edits);
219 // Returns the point to restart background rendering at.
220 // -1 means nothing changed.
221 void clear_automation(double selectionstart, double selectionend,
222 int shift_autos /* = 1 */,
223 int default_only /* = 0 */);
224 void set_automation_mode(double selectionstart, double selectionend,
226 virtual int clear_automation_derived(AutoConf *auto_conf,
227 double selectionstart, double selectionend,
228 int shift_autos = 1) { return 0; };
229 virtual int clear_derived(double start,
230 double end) { return 0; };
232 int copy_automation(double selectionstart, double selectionend,
233 FileXML *file, int default_only, int active_only);
234 virtual int copy_automation_derived(AutoConf *auto_conf,
235 double selectionstart, double selectionend,
236 FileXML *file) { return 0; };
237 int paste_automation(double selectionstart, double total_length,
238 double frame_rate, int64_t sample_rate, FileXML *file,
239 int default_only, int active_only);
240 virtual int paste_automation_derived(double selectionstart, double selectionend,
241 double total_length, FileXML *file, int shift_autos, int ¤t_pan) { return 0; };
242 int paste_auto_silence(double start, double end);
243 virtual int paste_auto_silence_derived(int64_t start, int64_t end) { return 0; };
244 int scale_time(float rate_scale, int scale_edits, int scale_autos, int64_t start, int64_t end);
245 virtual int scale_time_derived(float rate_scale, int scale_edits, int scale_autos, int64_t start, int64_t end) { return 0; };
246 int purge_asset(Asset *asset);
247 int asset_used(Asset *asset);
248 int clear_handle(double start, double end,
249 int clear_labels, int clear_plugins, int edit_autos,
251 int paste_silence(double start, double end, int edit_plugins, int edit_autos);
252 int paste_silence(int64_t start, int64_t end, int edit_plugins, int edit_autos);
253 virtual int select_translation(int cursor_x, int cursor_y) { return 0; }; // select video coordinates for frame
254 virtual int update_translation(int cursor_x, int cursor_y, int shift_down) { return 0; }; // move video coordinates
255 int select_auto(AutoConf *auto_conf, int cursor_x, int cursor_y);
256 virtual int select_auto_derived(float zoom_units, float view_start, AutoConf *auto_conf, int cursor_x, int cursor_y) { return 0; };
257 int move_auto(AutoConf *auto_conf, int cursor_x, int cursor_y, int shift_down);
258 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; };
260 virtual int release_auto_derived() { return 0; };
261 // Return whether automation would prevent direct frame copies. Not fully implemented.
262 int automation_is_used(int64_t start, int64_t end);
263 virtual int automation_is_used_derived(int64_t start, int64_t end) { return 0; }
265 int popup_transition(int cursor_x, int cursor_y);
267 // Return 1 if the left handle was selected 2 if the right handle was selected 3 if the track isn't recordable
268 int modify_edithandles(double oldposition, double newposition,
269 int currentend, int handle_mode, int edit_labels,
270 int edit_plugins, int edit_autos, int group_id);
271 int modify_pluginhandles(double oldposition,
278 int select_edit(int cursor_x,
282 virtual int end_translation() { return 0; };
283 virtual int reset_translation(int64_t start, int64_t end) { return 0; };
284 int feather_edits(int64_t start, int64_t end, int64_t units);
285 int64_t get_feather(int64_t selectionstart, int64_t selectionend);
289 int show_transitions();
291 // Absolute number of this track
294 // get_dimensions is used for getting drawing regions so use floats for partial frames
295 // get the display dimensions in SAMPLES OR FRAMES
296 // virtual int get_dimensions(double &view_start,
297 // double &view_units,
298 // double &zoom_units) { return 0; };
299 // Longest time from current_position in which nothing changes
300 int64_t edit_change_duration(int64_t input_position,
301 int64_t input_length,
303 int test_transitions,
305 int64_t plugin_change_duration(int64_t input_position,
306 int64_t input_length,
309 // Utility for edit_change_duration.
310 int need_edit(Edit *current, int test_transitions);
311 // If the edit under position is playable.
312 // Used by PlayableTracks::is_playable.
313 int playable_edit(int64_t position, int direction);
315 // ===================================== for handles, titles, etc
317 int64_t old_view_start;
318 int pixel; // pixel position from top of track view
319 // Dimensions of this track if video
320 int track_w, track_h;
324 // Identification of the track