Merge CV, ver=5.1; ops/methods from HV, and interface from CV where possible
[goodguy/history.git] / cinelerra-5.1 / cinelerra / automation.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008-2013 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 AUTOMATION_H
23 #define AUTOMATION_H
24
25 #include <stdio.h>
26 #include <stdint.h>
27
28 #include "arraylist.h"
29 #include "autoconf.inc"
30 #include "automation.inc"
31 #include "autos.inc"
32 #include "edl.inc"
33 #include "filexml.inc"
34 #include "maxchannels.h"
35 #include "module.inc"
36 #include "track.inc"
37
38 // Match the clipping at per cinelerra/virtualanode.C which contains:
39 //  if(fade_value <= INFINITYGAIN) fade_value = 0;
40 //  in reality, this should be matched to a user-defined minimum in the preferences
41 #define AUTOMATIONCLAMPS(value, autogrouptype)                          \
42         if (autogrouptype == AUTOGROUPTYPE_AUDIO_FADE && value <= INFINITYGAIN) \
43                 value = INFINITYGAIN;                                   \
44         if (autogrouptype == AUTOGROUPTYPE_VIDEO_FADE)                  \
45                 CLAMP(value, 0, 100);                                   \
46         if (autogrouptype == AUTOGROUPTYPE_ZOOM && value < 0)           \
47                 value = 0;
48
49 #define AUTOMATIONVIEWCLAMPS(value, autogrouptype)                      \
50         if (autogrouptype == AUTOGROUPTYPE_ZOOM && value < 0)           \
51                 value = 0;
52
53
54 class Automation
55 {
56 public:
57         static int autogrouptypes_fixedrange[];
58         Automation(EDL *edl, Track *track);
59         virtual ~Automation();
60
61         int autogrouptype(int autoidx, Track *track);
62         virtual void create_objects();
63         void equivalent_output(Automation *automation, int64_t *result);
64         virtual Automation& operator=(Automation& automation);
65         virtual void copy_from(Automation *automation);
66         int load(FileXML *file);
67 // For copy automation, copy, and save
68         int copy(int64_t start,
69                 int64_t end,
70                 FileXML *xml,
71                 int default_only,
72                 int active_only);
73         virtual void dump(FILE *fp);
74         virtual int direct_copy_possible(int64_t start, int direction);
75         virtual int direct_copy_possible_derived(int64_t start, int direction) { return 1; };
76 // For paste automation only
77         int paste(int64_t start,
78                 int64_t length,
79                 double scale,
80                 FileXML *file,
81                 int default_only,
82                 int active_only,
83                 AutoConf *autoconf);
84
85 // Get projector coordinates if this is video automation
86         virtual void get_projector(float *x,
87                 float *y,
88                 float *z,
89                 int64_t position,
90                 int direction);
91 // Get camera coordinates if this is video automation
92         virtual void get_camera(float *x,
93                 float *y,
94                 float *z,
95                 int64_t position,
96                 int direction);
97
98 // Returns the point to restart background rendering at.
99 // -1 means nothing changed.
100         void clear(int64_t start,
101                 int64_t end,
102                 AutoConf *autoconf,
103                 int shift_autos);
104         void set_automation_mode(int64_t start,
105                 int64_t end,
106                 int mode,
107                 AutoConf *autoconf);
108         void paste_silence(int64_t start, int64_t end);
109         void insert_track(Automation *automation,
110                 int64_t start_unit,
111 // Pad keyframes to this length.
112                 int64_t length_units,
113                 int replace_default);
114         void resample(double old_rate, double new_rate);
115         int64_t get_length();
116         virtual void get_extents(float *min,
117                 float *max,
118                 int *coords_undefined,
119                 int64_t unit_start,
120                 int64_t unit_end,
121                 int autogrouptype);
122
123
124
125
126
127         Autos *autos[AUTOMATION_TOTAL];
128
129
130         EDL *edl;
131         Track *track;
132 };
133
134 #endif