auto bump fixes, undo tweaks, add drag_speed_highlight, ffmpeg filter setup fixes...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / track.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2010 Adam Williams <broadcast at earthling dot net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #ifndef TRACK_H
23 #define TRACK_H
24
25 #include <stdio.h>
26 #include <stdint.h>
27
28 #include "arraylist.h"
29 #include "asset.inc"
30 #include "autoconf.inc"
31 #include "automation.inc"
32 #include "datatype.h"
33 #include "bchash.inc"
34 #include "edit.inc"
35 #include "edits.inc"
36 #include "edl.inc"
37 #include "filexml.inc"
38 #include "floatautos.inc"
39 #include "guicast.h"
40 #include "indexable.inc"
41 #include "keyframe.inc"
42 #include "linklist.h"
43 #include "module.inc"
44 #include "patch.inc"
45 #include "plugin.inc"
46 #include "pluginset.inc"
47 #include "sharedlocation.inc"
48 #include "theme.inc"
49 #include "intautos.inc"
50 #include "trackcanvas.inc"
51 #include "tracks.inc"
52 #include "transition.inc"
53 #include "zwindow.inc"
54
55 // UNITS ARE SAMPLES FOR ALL
56
57 class Track : public ListItem<Track>
58 {
59 public:
60         Track(EDL *edl, Tracks *tracks);
61         virtual ~Track();
62
63         void create_objects();
64         int get_id();
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);
72         int get_mixer_id();
73
74         void get_fauto_xyz(int fauto, float &x, float &y, float &z);
75         void set_fauto_xyz(int fauto, float x, float y, float z);
76         void get_projector(float &x, float &y, float &z);
77         void set_projector(float x, float y, float z);
78         void get_camera(float &x, float &y, float &z);
79         void set_camera(float x, float y, float z);
80
81         virtual void copy_from(Track *track);
82         Track& operator=(Track& track);
83         virtual PluginSet* new_plugins() { return 0; };
84 // Synchronize playback numbers
85         virtual void synchronize_params(Track *track);
86
87 // Get number of pixels to display
88         virtual int vertical_span(Theme *theme);
89         int64_t horizontal_span();
90         void resample(double old_rate, double new_rate);
91
92 // Speed curve in use
93         int has_speed();
94 // length when speed is applied
95         int64_t speed_length(int64_t start, int64_t end);
96 // Get length of track in seconds
97         double get_length();
98 // Get dimensions of source for convenience functions
99         void get_source_dimensions(double position, int &w, int &h);
100
101 // Editing
102         void insert_asset(Asset *asset, EDL *nested_edl,
103                 double length, double position, int track_number);
104         Plugin* insert_effect(const char *title, SharedLocation *shared_location,
105                 KeyFrame *keyframe, PluginSet *plugin_set,
106                 double start, double length, int plugin_type);
107         void insert_plugin_set(Track *track, int64_t position,
108                 int64_t min_length, int edit_autos);
109         void detach_effect(Plugin *plugin);
110 // Insert a track from another EDL
111         void insert_track(Track *track, double position,
112                 int replace_default, int edit_plugins, int edit_autos,
113 // Pad pasted sections to a minimum of this length.
114                 double edl_length);
115         void shuffle_edits(double start, double end, int first_track);
116         void reverse_edits(double start, double end, int first_track);
117         void align_edits(double start, double end, Track *master_track);
118 // Optimize editing
119         void optimize();
120         int is_muted(int64_t position, int direction);  // Test muting status
121
122         void move_plugins_up(PluginSet *plugin_set);
123         void move_plugins_down(PluginSet *plugin_set);
124         void remove_pluginset(PluginSet *plugin_set);
125         void remove_asset(Indexable *asset);
126
127 // Used for determining a selection for editing so leave as int.
128 // converts the selection to SAMPLES OR FRAMES and stores in value
129         virtual int64_t to_units(double position, int round);
130 // For drawing
131         virtual double to_doubleunits(double position);
132         virtual double from_units(int64_t position);
133
134
135 // Positions are identical for handle modifications
136     virtual int identical(int64_t sample1, int64_t sample2) { return 0; };
137
138 // Get the plugin belonging to the set.
139         Plugin* get_current_plugin(double position,
140                 int plugin_set, int direction, int convert_units, int use_nudge);
141         Plugin* get_current_transition(double position,
142                 int direction, int convert_units, int use_nudge);
143
144 // detach shared effects referencing module
145         void detach_shared_effects(int module);
146 // detach all corresponding effects in gang
147         void detach_ganged_effects(Plugin *plugin);
148
149 // Called by playable tracks to test for playable server.
150 // Descends the plugin tree without creating a virtual console.
151 // Used by PlayableTracks::is_playable.
152         int is_synthesis(int64_t position, int direction, int depth=0);
153
154 // Used by PlayableTracks::is_playable
155 // Returns 1 if the track is in the output boundaries.
156         virtual int is_playable(int64_t position, int direction);
157
158 // Test direct copy conditions common to all the rendering routines
159         virtual int direct_copy_possible(int64_t start, int direction, int use_nudge);
160
161 // Used by PlayableTracks::is_playable
162         int plugin_used(int64_t position, int64_t direction);
163 // align to frame boundary
164         int64_t frame_align(int64_t position, int round);
165
166         virtual int copy_settings(Track *track);
167         void shift_keyframes(int64_t position, int64_t length);
168         void shift_effects(int64_t position, int64_t length, int edit_autos, Edits *trim_edits);
169         void change_plugins(SharedLocation &old_location, SharedLocation &new_location, int do_swap);
170         void change_modules(int old_location, int new_location, int do_swap);
171         Plugin *plugin_exists(int plugin_id);
172         Track *gang_master();
173         int is_hidden();
174         int in_gang(Track *track);
175         int is_armed();
176         int is_ganged();
177         int armed_gang(Track *track);
178         int index_in(Mixer *mixer);
179
180         EDL *edl;
181         Tracks *tracks;
182
183         Edits *edits;
184 // Plugin set uses key frames for automation
185         ArrayList<PluginSet*> plugin_set;
186         Automation *automation;
187
188 // Vertical offset from top of timeline
189         int y_pixel;
190 // Vertical height of the track asset
191         int data_h;
192         int expand_view;
193         int draw;
194 // There is some debate on whether to expand gang from faders to
195 // dragging operations.  This would allow every edit in a column to get dragged
196 // simultaneously.
197         int ganged;
198         char title[BCTEXTLEN];
199         int play;
200         int armed;
201 // mask enable bit flags
202         int masks;
203 // Nudge in track units.  Positive shifts track earlier in time.  This way
204 // the position variables only need to add the nudge.
205         int64_t nudge;
206 // TRACK_AUDIO or TRACK_VIDEO
207         int data_type;
208
209
210         int load_automation(FileXML *file);
211         int load_edits(FileXML *file);
212
213         virtual int change_channels(int oldchannels, int newchannels) { return 0; };
214         virtual int dump(FILE *fp);
215
216 // ===================================== editing
217         int copy(int copy_flags, double start, double end,
218                 FileXML *file, const char *output_path = "");
219         int copy_assets(double start, double end, ArrayList<Asset*> *asset_list);
220         virtual int copy_derived(int64_t start, int64_t end, FileXML *file) { return 0; };
221         virtual int paste_derived(int64_t start, int64_t end,
222                 int64_t total_length, FileXML *file, int &current_channel) { return 0; };
223         int blade(double position);
224         int clear(double start, double end,
225                 int edit_edits, int edit_labels, int clear_plugins,
226                 int edit_autos, Edits *trim_edits);
227         int clear(int64_t start, int64_t end,
228                 int edit_edits, int edit_labels, int clear_plugins,
229                 int edit_autos, Edits *trim_edits);
230 // Returns the point to restart background rendering at.
231 // -1 means nothing changed.
232         void clear_automation(double selectionstart, double selectionend,
233                 int shift_autos   /* = 1 */,
234                 int default_only  /* = 0 */);
235         void set_automation_mode(double selectionstart, double selectionend,
236                 int mode);
237         virtual int clear_automation_derived(AutoConf *auto_conf,
238                 double selectionstart, double selectionend,
239                 int shift_autos = 1) { return 0; };
240         virtual int clear_derived(double start,
241                 double end) { return 0; };
242
243         int copy_automation(double selectionstart, double selectionend,
244                 FileXML *file, int default_only, int active_only);
245         virtual int copy_automation_derived(AutoConf *auto_conf,
246                 double selectionstart, double selectionend,
247                 FileXML *file) { return 0; };
248         int paste_automation(FileXML *file,
249                 double selectionstart, double src_length, double src_rate,
250                 int default_only, int active_only);
251         virtual int paste_automation_derived(double selectionstart, double selectionend,
252                 double total_length, FileXML *file, int shift_autos, int &current_pan) { return 0; };
253         int paste_auto_silence(double start, double end);
254         virtual int paste_auto_silence_derived(int64_t start, int64_t end) { return 0; };
255         int scale_time(float rate_scale, int scale_edits, int scale_autos, int64_t start, int64_t end);
256         virtual int scale_time_derived(float rate_scale, int scale_edits, int scale_autos, int64_t start, int64_t end) { return 0; };
257         int purge_asset(Asset *asset);
258         int asset_used(Asset *asset);
259         int clear_handle(double start, double end,
260                 int clear_labels, int clear_plugins, int edit_autos,
261                 double &distance);
262         int paste_silence(double start, double end, int edit_plugins, int edit_autos);
263         int paste_silence(int64_t start, int64_t end, int edit_plugins, int edit_autos);
264         virtual int select_translation(int cursor_x, int cursor_y) { return 0; };  // select video coordinates for frame
265         virtual int update_translation(int cursor_x, int cursor_y, int shift_down) { return 0; };  // move video coordinates
266         int select_auto(AutoConf *auto_conf, int cursor_x, int cursor_y);
267         virtual int select_auto_derived(float zoom_units, float view_start, AutoConf *auto_conf, int cursor_x, int cursor_y) { return 0; };
268         int move_auto(AutoConf *auto_conf, int cursor_x, int cursor_y, int shift_down);
269         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; };
270         int release_auto();
271         virtual int release_auto_derived() { return 0; };
272 // Return whether automation would prevent direct frame copies.  Not fully implemented.
273         int automation_is_used(int64_t start, int64_t end);
274         virtual int automation_is_used_derived(int64_t start, int64_t end) { return 0; }
275
276         int popup_transition(int cursor_x, int cursor_y);
277
278 // Return 1 if the left handle was selected 2 if the right handle was selected 3 if the track isn't recordable
279         int modify_edithandles(double oldposition, double newposition,
280                 int currentend, int handle_mode, int edit_labels,
281                 int edit_plugins, int edit_autos, int group_id);
282         int modify_pluginhandles(double oldposition,
283                 double newposition,
284                 int currentend,
285                 int handle_mode,
286                 int edit_labels,
287                 int edit_autos,
288                 Edits *trim_edits);
289         int select_edit(int cursor_x,
290                 int cursor_y,
291                 double &new_start,
292                 double &new_end);
293         virtual int end_translation() { return 0; };
294         virtual int reset_translation(int64_t start, int64_t end) { return 0; };
295         int feather_edits(int64_t start, int64_t end, int64_t units);
296         int64_t get_feather(int64_t selectionstart, int64_t selectionend);
297
298         int show_assets();
299         int show_titles();
300         int show_transitions();
301
302 // Absolute number of this track
303         int number_of();
304
305 // get_dimensions is used for getting drawing regions so use floats for partial frames
306 // get the display dimensions in SAMPLES OR FRAMES
307 //      virtual int get_dimensions(double &view_start,
308 //              double &view_units,
309 //              double &zoom_units) { return 0; };
310 // Longest time from current_position in which nothing changes
311         int64_t edit_change_duration(int64_t input_position,
312                 int64_t input_length,
313                 int reverse,
314                 int test_transitions,
315                 int use_nudge);
316         int64_t plugin_change_duration(int64_t input_position,
317                 int64_t input_length,
318                 int reverse,
319                 int use_nudge);
320 // Utility for edit_change_duration.
321         int need_edit(Edit *current, int test_transitions);
322 // If the edit under position is playable.
323 // Used by PlayableTracks::is_playable.
324         int playable_edit(int64_t position, int direction);
325         void create_keyframes(double position, int mask, int mode);
326
327 // ===================================== for handles, titles, etc
328
329         int64_t old_view_start;
330         int pixel;   // pixel position from top of track view
331 // Dimensions of this track if video
332         int track_w, track_h;
333 // mixer set track id, gang master flag
334         int mixer_id, master;
335
336 private:
337 // Identification of the track
338         int id;
339 };
340
341 #endif