2 #include "automation.h"
8 #include "edlsession.h"
12 #include "transportque.inc"
15 int Automation::autogrouptypes_fixedrange[] =
27 Automation::Automation(EDL *edl, Track *track)
31 bzero(autos, sizeof(Autos*) * AUTOMATION_TOTAL);
34 Automation::~Automation()
36 for(int i = 0; i < AUTOMATION_TOTAL; i++)
42 int Automation::autogrouptype(int autoidx, Track *track)
44 int autogrouptype = -1;
47 case AUTOMATION_CAMERA_X:
48 case AUTOMATION_PROJECTOR_X:
49 autogrouptype = AUTOGROUPTYPE_X;
51 case AUTOMATION_CAMERA_Y:
52 case AUTOMATION_PROJECTOR_Y:
53 autogrouptype = AUTOGROUPTYPE_Y;
55 case AUTOMATION_CAMERA_Z:
56 case AUTOMATION_PROJECTOR_Z:
57 autogrouptype = AUTOGROUPTYPE_ZOOM;
60 if (track->data_type == TRACK_AUDIO)
61 autogrouptype = AUTOGROUPTYPE_AUDIO_FADE;
63 autogrouptype = AUTOGROUPTYPE_VIDEO_FADE;
66 autogrouptype = AUTOGROUPTYPE_INT255;
69 return (autogrouptype);
72 int Automation::create_objects()
74 autos[AUTOMATION_MUTE] = new IntAutos(edl, track, 0);
75 autos[AUTOMATION_MUTE]->create_objects();
76 autos[AUTOMATION_MUTE]->autoidx = AUTOMATION_MUTE;
77 autos[AUTOMATION_MUTE]->autogrouptype = AUTOGROUPTYPE_INT255;
81 Automation& Automation::operator=(Automation& automation)
83 printf("Automation::operator= 1\n");
84 copy_from(&automation);
88 void Automation::equivalent_output(Automation *automation, int64_t *result)
90 for(int i = 0; i < AUTOMATION_TOTAL; i++)
92 if(autos[i] && automation->autos[i])
93 autos[i]->equivalent_output(automation->autos[i], 0, result);
97 void Automation::copy_from(Automation *automation)
99 for(int i = 0; i < AUTOMATION_TOTAL; i++)
101 if(autos[i] && automation->autos[i])
102 autos[i]->copy_from(automation->autos[i]);
106 // These must match the enumerations
107 static char *xml_titles[] =
123 int Automation::load(FileXML *file)
125 for(int i = 0; i < AUTOMATION_TOTAL; i++)
127 if(file->tag.title_is(xml_titles[i]) && autos[i])
129 autos[i]->load(file);
136 int Automation::paste(int64_t start,
143 if(!autoconf) autoconf = edl->session->auto_conf;
145 for(int i = 0; i < AUTOMATION_TOTAL; i++)
147 if(file->tag.title_is(xml_titles[i]) && autos[i] && autoconf->autos[i])
149 autos[i]->paste(start, length, scale, file, default_only);
156 int Automation::copy(int64_t start,
162 // Copy regardless of what's visible.
163 for(int i = 0; i < AUTOMATION_TOTAL; i++)
167 file->tag.set_title(xml_titles[i]);
169 file->append_newline();
170 autos[i]->copy(start,
175 char string[BCTEXTLEN];
176 sprintf(string, "/%s", xml_titles[i]);
177 file->tag.set_title(string);
179 file->append_newline();
187 void Automation::clear(int64_t start,
192 AutoConf *temp_autoconf = 0;
196 temp_autoconf = new AutoConf;
197 temp_autoconf->set_all(1);
198 autoconf = temp_autoconf;
201 for(int i = 0; i < AUTOMATION_TOTAL; i++)
203 if(autos[i] && autoconf->autos[i])
205 autos[i]->clear(start, end, shift_autos);
209 if(temp_autoconf) delete temp_autoconf;
212 void Automation::straighten(int64_t start,
216 AutoConf *temp_autoconf = 0;
220 temp_autoconf = new AutoConf;
221 temp_autoconf->set_all(1);
222 autoconf = temp_autoconf;
225 for(int i = 0; i < AUTOMATION_TOTAL; i++)
227 if(autos[i] && autoconf->autos[i])
229 autos[i]->straighten(start, end);
233 if(temp_autoconf) delete temp_autoconf;
237 void Automation::paste_silence(int64_t start, int64_t end)
239 // Unit conversion done in calling routine
240 for(int i = 0; i < AUTOMATION_TOTAL; i++)
243 autos[i]->paste_silence(start, end);
247 // We don't replace it in pasting but
248 // when inserting the first EDL of a load operation we need to replace
249 // the default keyframe.
250 void Automation::insert_track(Automation *automation,
252 int64_t length_units,
255 for(int i = 0; i < AUTOMATION_TOTAL; i++)
257 if(autos[i] && automation->autos[i])
259 autos[i]->insert_track(automation->autos[i],
269 void Automation::resample(double old_rate, double new_rate)
271 // Run resample for all the autos structures and all the keyframes
272 for(int i = 0; i < AUTOMATION_TOTAL; i++)
274 if(autos[i]) autos[i]->resample(old_rate, new_rate);
280 int Automation::direct_copy_possible(int64_t start, int direction)
288 void Automation::get_projector(float *x,
296 void Automation::get_camera(float *x,
307 int64_t Automation::get_length()
310 int64_t total_length = 0;
312 for(int i = 0; i < AUTOMATION_TOTAL; i++)
316 length = autos[i]->get_length();
317 if(length > total_length) total_length = length;
325 void Automation::get_extents(float *min,
327 int *coords_undefined,
332 for(int i = 0; i < AUTOMATION_TOTAL; i++)
334 if(autos[i] && edl->session->auto_conf->autos[i])
336 if (autos[i]->autogrouptype == autogrouptype)
337 autos[i]->get_extents(min, max, coords_undefined, unit_start, unit_end);
343 void Automation::dump()
345 printf(" Automation: %p\n", this);
348 for(int i = 0; i < AUTOMATION_TOTAL; i++)
352 printf(" %s %p\n", xml_titles[i], autos[i]);