4 * Copyright (C) 2008 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 // Base class for automation lists.
29 // Units are the native units for the track data type.
34 #include "filexml.inc"
37 #define AUTOS_VIRTUAL_HEIGHT 160
39 class Autos : public List<Auto>
42 Autos(EDL *edl, Track *track);
46 void resample(double old_rate, double new_rate);
48 virtual void create_objects();
49 void equivalent_output(Autos *autos, int64_t startproject, int64_t *result);
50 void copy_from(Autos *autos);
51 virtual Auto* new_auto();
52 // Get existing auto on or before position.
53 // If use_default is true, return default_auto if none exists
54 // on or before position.
55 // Return 0 if none exists and use_default is false.
56 // If ¤t is nonzero it is used as a starting point for searching.
57 Auto* get_prev_auto(int64_t position, int direction, Auto* ¤t, int use_default = 1);
58 Auto* get_prev_auto(int direction, Auto* ¤t);
59 Auto* get_next_auto(int64_t position, int direction, Auto* ¤t, int use_default = 1);
60 // Determine if a keyframe exists before creating it.
61 int auto_exists_for_editing(double position);
62 // Returns auto at exact position, null if non-existent. ignores autokeyframming and align on frames
63 Auto* get_auto_at_position(double position = -1);
64 Auto* get_auto(int id);
66 // Get keyframe for editing with creation
67 // create: <0: always new keyframe, =0: no new keyframe, >0: auto keyframe
68 Auto* get_auto_for_editing(double position=-1, int create=1);
70 // Insert keyframe at the point if it doesn't exist
71 // Interpolate its value if possible
72 Auto* insert_auto(int64_t position, Auto *templ=0);
73 void insert_track(Autos *automation,
77 virtual int load(FileXML *xml);
78 void remove_nonsequential(Auto *keyframe);
81 // Returns a type enumeration
84 virtual void get_extents(float *min,
86 int *coords_undefined,
92 // Default settings if no autos.
93 // Having a persistent keyframe created problems when files were loaded and
94 // we wanted to keep only 1 auto.
95 // Default auto has position 0 except in effects, where multiple default autos
104 AUTOMATION_TYPE_FLOAT,
105 AUTOMATION_TYPE_MASK,
108 AUTOMATION_TYPE_PLUGIN
113 virtual void dump(FILE *fp);
121 int insert(int64_t start, int64_t end);
122 int paste_silence(int64_t start, int64_t end);
123 // Copy for keyframe clipboard & drag & drop
124 // default_only - only copy the default keyframe
125 int copy(int64_t start,
130 // Paste for keyframe clipboard & drag & drop
131 // default_only - only paste the default keyframe
132 void paste(int64_t start,
138 // Stores the background rendering position in result
139 void clear(int64_t start,
142 virtual void set_automation_mode(int64_t start, int64_t end, int mode);
143 int clear_auto(int64_t position);
144 int save(FileXML *xml);
145 virtual int slope_adjustment(int64_t ax, double slope);
147 virtual int release_auto_derived() { return 0; }
149 int scale_time(float rate_scale, int scale_edits, int scale_autos, int64_t start, int64_t end);
151 // rendering utilities
152 int get_neighbors(int64_t start, int64_t end, Auto **before, Auto **after);
153 // 1 if automation doesn't change
154 virtual int automation_is_constant(int64_t start, int64_t end);
155 virtual double get_automation_constant(int64_t start, int64_t end);
156 int init_automation(int64_t &buffer_position,
157 int64_t &input_start,
161 int64_t input_position,
167 int init_slope(Auto **current_auto,
170 double &slope_position,
171 int64_t &input_start,
177 int get_slope(Auto **current_auto,
183 int64_t buffer_position,
186 int advance_slope(Auto **current_auto,
189 double &slope_position,
192 Auto* autoof(int64_t position); // return nearest auto equal to or after position
193 // 0 if after all autos
194 Auto* nearest_before(int64_t position); // return nearest auto before or 0
195 Auto* nearest_after(int64_t position); // return nearest auto after or 0