2 #include "automation.h"
8 #include "edlsession.h"
12 #include "transportque.inc"
15 Automation::Automation(EDL *edl, Track *track)
19 bzero(autos, sizeof(Autos*) * AUTOMATION_TOTAL);
22 Automation::~Automation()
24 for(int i = 0; i < AUTOMATION_TOTAL; i++)
30 int Automation::create_objects()
32 autos[AUTOMATION_MUTE] = new IntAutos(edl, track, 0);
33 autos[AUTOMATION_MUTE]->create_objects();
37 Automation& Automation::operator=(Automation& automation)
39 printf("Automation::operator= 1\n");
40 copy_from(&automation);
44 void Automation::equivalent_output(Automation *automation, int64_t *result)
46 for(int i = 0; i < AUTOMATION_TOTAL; i++)
48 if(autos[i] && automation->autos[i])
49 autos[i]->equivalent_output(automation->autos[i], 0, result);
53 void Automation::copy_from(Automation *automation)
55 for(int i = 0; i < AUTOMATION_TOTAL; i++)
57 if(autos[i] && automation->autos[i])
58 autos[i]->copy_from(automation->autos[i]);
62 // These must match the enumerations
63 static char *xml_titles[] =
79 int Automation::load(FileXML *file)
81 for(int i = 0; i < AUTOMATION_TOTAL; i++)
83 if(file->tag.title_is(xml_titles[i]) && autos[i])
92 int Automation::paste(int64_t start,
99 if(!autoconf) autoconf = edl->session->auto_conf;
101 for(int i = 0; i < AUTOMATION_TOTAL; i++)
103 if(file->tag.title_is(xml_titles[i]) && autos[i] && autoconf->autos[i])
105 autos[i]->paste(start, length, scale, file, default_only);
112 int Automation::copy(int64_t start,
118 // Copy regardless of what's visible.
119 for(int i = 0; i < AUTOMATION_TOTAL; i++)
123 file->tag.set_title(xml_titles[i]);
125 file->append_newline();
126 autos[i]->copy(start,
131 char string[BCTEXTLEN];
132 sprintf(string, "/%s", xml_titles[i]);
133 file->tag.set_title(string);
135 file->append_newline();
143 void Automation::clear(int64_t start,
148 AutoConf *temp_autoconf = 0;
152 temp_autoconf = new AutoConf;
153 temp_autoconf->set_all(1);
154 autoconf = temp_autoconf;
157 for(int i = 0; i < AUTOMATION_TOTAL; i++)
159 if(autos[i] && autoconf->autos[i])
161 autos[i]->clear(start, end, shift_autos);
165 if(temp_autoconf) delete temp_autoconf;
168 void Automation::straighten(int64_t start,
172 AutoConf *temp_autoconf = 0;
176 temp_autoconf = new AutoConf;
177 temp_autoconf->set_all(1);
178 autoconf = temp_autoconf;
181 for(int i = 0; i < AUTOMATION_TOTAL; i++)
183 if(autos[i] && autoconf->autos[i])
185 autos[i]->straighten(start, end);
189 if(temp_autoconf) delete temp_autoconf;
193 void Automation::paste_silence(int64_t start, int64_t end)
195 // Unit conversion done in calling routine
196 for(int i = 0; i < AUTOMATION_TOTAL; i++)
199 autos[i]->paste_silence(start, end);
203 // We don't replace it in pasting but
204 // when inserting the first EDL of a load operation we need to replace
205 // the default keyframe.
206 void Automation::insert_track(Automation *automation,
208 int64_t length_units,
211 for(int i = 0; i < AUTOMATION_TOTAL; i++)
213 if(autos[i] && automation->autos[i])
215 autos[i]->insert_track(automation->autos[i],
225 void Automation::resample(double old_rate, double new_rate)
227 // Run resample for all the autos structures and all the keyframes
228 for(int i = 0; i < AUTOMATION_TOTAL; i++)
230 if(autos[i]) autos[i]->resample(old_rate, new_rate);
236 int Automation::direct_copy_possible(int64_t start, int direction)
244 void Automation::get_projector(float *x,
252 void Automation::get_camera(float *x,
263 int64_t Automation::get_length()
266 int64_t total_length = 0;
268 for(int i = 0; i < AUTOMATION_TOTAL; i++)
272 length = autos[i]->get_length();
273 if(length > total_length) total_length = length;
281 void Automation::get_extents(float *min,
283 int *coords_undefined,
287 for(int i = 0; i < AUTOMATION_TOTAL; i++)
289 if(autos[i] && edl->session->auto_conf->autos[i])
291 autos[i]->get_extents(min, max, coords_undefined, unit_start, unit_end);
297 void Automation::dump()
299 printf(" Automation: %p\n", this);
302 for(int i = 0; i < AUTOMATION_TOTAL; i++)
306 printf(" %s %p\n", xml_titles[i], autos[i]);