r827: Fix a crash when no audio output device can be opened.
[cinelerra_cv.git] / cinelerra / autos.h
blob41c985b47d8d37faf868da7c0f8a0d9198d50063
1 #ifndef AUTOS_H
2 #define AUTOS_H
4 // Base class for automation lists.
5 // Units are the native units for the track data type.
7 #include "auto.h"
8 #include "edl.inc"
9 #include "guicast.h"
10 #include "filexml.inc"
11 #include "track.inc"
13 #define AUTOS_VIRTUAL_HEIGHT 160
15 class Autos : public List<Auto>
17 public:
18 Autos(EDL *edl,
19 Track *track);
21 virtual ~Autos();
23 void resample(double old_rate, double new_rate);
25 virtual void create_objects();
26 void equivalent_output(Autos *autos, int64_t startproject, int64_t *result);
27 void copy_from(Autos *autos);
28 virtual Auto* new_auto();
29 // Get existing auto on or before position.
30 // If use_default is true, return default_auto if none exists
31 // on or before position.
32 // Return 0 if none exists and use_default is false.
33 // If &current is nonzero it is used as a starting point for searching.
34 Auto* get_prev_auto(int64_t position, int direction, Auto* &current, int use_default = 1);
35 Auto* get_prev_auto(int direction, Auto* &current);
36 Auto* get_next_auto(int64_t position, int direction, Auto* &current, int use_default = 1);
37 // Determine if a keyframe exists before creating it.
38 int auto_exists_for_editing(double position);
39 // Returns auto at exact position, null if non-existent. ignores autokeyframming and align on frames
40 Auto* get_auto_at_position(double position = -1);
42 // Get keyframe for editing with automatic creation if enabled
43 Auto* get_auto_for_editing(double position = -1);
45 // Insert keyframe at the point if it doesn't exist
46 Auto* insert_auto(int64_t position);
47 // Insert keyframe at the point if it doesn't exist
48 // Interpolate it insead of copying
49 Auto* insert_auto_for_editing(int64_t position);
50 void insert_track(Autos *automation,
51 int64_t start_unit,
52 int64_t length_units,
53 int replace_default);
54 virtual int load(FileXML *xml);
55 void paste(int64_t start,
56 int64_t length,
57 double scale,
58 FileXML *file,
59 int default_only);
60 void remove_nonsequential(Auto *keyframe);
61 void optimize();
63 // Returns a type enumeration
64 int get_type();
65 int64_t get_length();
66 virtual void get_extents(float *min,
67 float *max,
68 int *coords_undefined,
69 int64_t unit_start,
70 int64_t unit_end);
72 EDL *edl;
73 Track *track;
74 // Default settings if no autos.
75 // Having a persistent keyframe created problems when files were loaded and
76 // we wanted to keep only 1 auto.
77 // Default auto has position 0 except in effects, where multiple default autos
78 // exist.
79 Auto *default_auto;
81 int type;
85 virtual void dump();
92 int clear_all();
93 int insert(int64_t start, int64_t end);
94 int paste_silence(int64_t start, int64_t end);
95 int copy(int64_t start,
96 int64_t end,
97 FileXML *xml,
98 int default_only,
99 int autos_only);
100 // Stores the background rendering position in result
101 void clear(int64_t start,
102 int64_t end,
103 int shift_autos);
104 int clear_auto(int64_t position);
105 int save(FileXML *xml);
106 virtual int slope_adjustment(int64_t ax, double slope);
107 int release_auto();
108 virtual int release_auto_derived() {};
109 Auto* append_auto();
110 int scale_time(float rate_scale, int scale_edits, int scale_autos, int64_t start, int64_t end);
112 // rendering utilities
113 int get_neighbors(int64_t start, int64_t end, Auto **before, Auto **after);
114 // 1 if automation doesn't change
115 virtual int automation_is_constant(int64_t start, int64_t end);
116 virtual double get_automation_constant(int64_t start, int64_t end);
117 int init_automation(int64_t &buffer_position,
118 int64_t &input_start,
119 int64_t &input_end,
120 int &automate,
121 double &constant,
122 int64_t input_position,
123 int64_t buffer_len,
124 Auto **before,
125 Auto **after,
126 int reverse);
128 int init_slope(Auto **current_auto,
129 double &slope_start,
130 double &slope_value,
131 double &slope_position,
132 int64_t &input_start,
133 int64_t &input_end,
134 Auto **before,
135 Auto **after,
136 int reverse);
138 int get_slope(Auto **current_auto,
139 double &slope_start,
140 double &slope_end,
141 double &slope_value,
142 double &slope,
143 int64_t buffer_len,
144 int64_t buffer_position,
145 int reverse);
147 int advance_slope(Auto **current_auto,
148 double &slope_start,
149 double &slope_value,
150 double &slope_position,
151 int reverse);
153 Auto* autoof(int64_t position); // return nearest auto equal to or after position
154 // 0 if after all autos
155 Auto* nearest_before(int64_t position); // return nearest auto before or 0
156 Auto* nearest_after(int64_t position); // return nearest auto after or 0
158 Auto *selected;
159 int skip_selected; // if selected was added
160 int64_t selected_position, selected_position_; // original position for moves
161 double selected_value, selected_value_; // original position for moves
162 float virtual_h; // height cursor moves to cover entire range when track height is less than this
163 int virtual_center;
164 int stack_number;
165 int stack_total;
173 #endif