00001 #include "autoconf.h"
00002 #include "automation.h"
00003 #include "autos.h"
00004 #include "atrack.inc"
00005 #include "bcsignals.h"
00006 #include "colors.h"
00007 #include "edl.h"
00008 #include "edlsession.h"
00009 #include "filexml.h"
00010 #include "intautos.h"
00011 #include "track.h"
00012 #include "transportque.inc"
00013
00014
00015 int Automation::autogrouptypes_fixedrange[] =
00016 {
00017 0,
00018 0,
00019 0,
00020 0,
00021 0,
00022 1
00023 };
00024
00025
00026
00027 Automation::Automation(EDL *edl, Track *track)
00028 {
00029 this->edl = edl;
00030 this->track = track;
00031 bzero(autos, sizeof(Autos*) * AUTOMATION_TOTAL);
00032 }
00033
00034 Automation::~Automation()
00035 {
00036 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00037 {
00038 delete autos[i];
00039 }
00040 }
00041
00042 int Automation::autogrouptype(int autoidx, Track *track)
00043 {
00044 int autogrouptype = -1;
00045 switch (autoidx)
00046 {
00047 case AUTOMATION_CAMERA_X:
00048 case AUTOMATION_PROJECTOR_X:
00049 autogrouptype = AUTOGROUPTYPE_X;
00050 break;
00051 case AUTOMATION_CAMERA_Y:
00052 case AUTOMATION_PROJECTOR_Y:
00053 autogrouptype = AUTOGROUPTYPE_Y;
00054 break;
00055 case AUTOMATION_CAMERA_Z:
00056 case AUTOMATION_PROJECTOR_Z:
00057 autogrouptype = AUTOGROUPTYPE_ZOOM;
00058 break;
00059 case AUTOMATION_FADE:
00060 if (track->data_type == TRACK_AUDIO)
00061 autogrouptype = AUTOGROUPTYPE_AUDIO_FADE;
00062 else
00063 autogrouptype = AUTOGROUPTYPE_VIDEO_FADE;
00064 break;
00065 case AUTOMATION_MUTE:
00066 autogrouptype = AUTOGROUPTYPE_INT255;
00067 break;
00068 }
00069 return (autogrouptype);
00070 }
00071
00072 int Automation::create_objects()
00073 {
00074 autos[AUTOMATION_MUTE] = new IntAutos(edl, track, 0);
00075 autos[AUTOMATION_MUTE]->create_objects();
00076 autos[AUTOMATION_MUTE]->autoidx = AUTOMATION_MUTE;
00077 autos[AUTOMATION_MUTE]->autogrouptype = AUTOGROUPTYPE_INT255;
00078 return 0;
00079 }
00080
00081 Automation& Automation::operator=(Automation& automation)
00082 {
00083 printf("Automation::operator= 1\n");
00084 copy_from(&automation);
00085 return *this;
00086 }
00087
00088 void Automation::equivalent_output(Automation *automation, int64_t *result)
00089 {
00090 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00091 {
00092 if(autos[i] && automation->autos[i])
00093 autos[i]->equivalent_output(automation->autos[i], 0, result);
00094 }
00095 }
00096
00097 void Automation::copy_from(Automation *automation)
00098 {
00099 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00100 {
00101 if(autos[i] && automation->autos[i])
00102 autos[i]->copy_from(automation->autos[i]);
00103 }
00104 }
00105
00106
00107 static char *xml_titles[] =
00108 {
00109 "MUTEAUTOS",
00110 "CAMERA_X",
00111 "CAMERA_Y",
00112 "CAMERA_Z",
00113 "PROJECTOR_X",
00114 "PROJECTOR_Y",
00115 "PROJECTOR_Z",
00116 "FADEAUTOS",
00117 "PANAUTOS",
00118 "MODEAUTOS",
00119 "MASKAUTOS",
00120 "NUDGEAUTOS"
00121 };
00122
00123 int Automation::load(FileXML *file)
00124 {
00125 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00126 {
00127 if(file->tag.title_is(xml_titles[i]) && autos[i])
00128 {
00129 autos[i]->load(file);
00130 return 1;
00131 }
00132 }
00133 return 0;
00134 }
00135
00136 int Automation::paste(int64_t start,
00137 int64_t length,
00138 double scale,
00139 FileXML *file,
00140 int default_only,
00141 AutoConf *autoconf)
00142 {
00143 if(!autoconf) autoconf = edl->session->auto_conf;
00144
00145 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00146 {
00147 if(file->tag.title_is(xml_titles[i]) && autos[i] && autoconf->autos[i])
00148 {
00149 autos[i]->paste(start, length, scale, file, default_only);
00150 return 1;
00151 }
00152 }
00153 return 0;
00154 }
00155
00156 int Automation::copy(int64_t start,
00157 int64_t end,
00158 FileXML *file,
00159 int default_only,
00160 int autos_only)
00161 {
00162
00163 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00164 {
00165 if(autos[i])
00166 {
00167 file->tag.set_title(xml_titles[i]);
00168 file->append_tag();
00169 file->append_newline();
00170 autos[i]->copy(start,
00171 end,
00172 file,
00173 default_only,
00174 autos_only);
00175 char string[BCTEXTLEN];
00176 sprintf(string, "/%s", xml_titles[i]);
00177 file->tag.set_title(string);
00178 file->append_tag();
00179 file->append_newline();
00180 }
00181 }
00182
00183 return 0;
00184 }
00185
00186
00187 void Automation::clear(int64_t start,
00188 int64_t end,
00189 AutoConf *autoconf,
00190 int shift_autos)
00191 {
00192 AutoConf *temp_autoconf = 0;
00193
00194 if(!autoconf)
00195 {
00196 temp_autoconf = new AutoConf;
00197 temp_autoconf->set_all(1);
00198 autoconf = temp_autoconf;
00199 }
00200
00201 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00202 {
00203 if(autos[i] && autoconf->autos[i])
00204 {
00205 autos[i]->clear(start, end, shift_autos);
00206 }
00207 }
00208
00209 if(temp_autoconf) delete temp_autoconf;
00210 }
00211
00212 void Automation::straighten(int64_t start,
00213 int64_t end,
00214 AutoConf *autoconf)
00215 {
00216 AutoConf *temp_autoconf = 0;
00217
00218 if(!autoconf)
00219 {
00220 temp_autoconf = new AutoConf;
00221 temp_autoconf->set_all(1);
00222 autoconf = temp_autoconf;
00223 }
00224
00225 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00226 {
00227 if(autos[i] && autoconf->autos[i])
00228 {
00229 autos[i]->straighten(start, end);
00230 }
00231 }
00232
00233 if(temp_autoconf) delete temp_autoconf;
00234 }
00235
00236
00237 void Automation::paste_silence(int64_t start, int64_t end)
00238 {
00239
00240 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00241 {
00242 if(autos[i])
00243 autos[i]->paste_silence(start, end);
00244 }
00245 }
00246
00247
00248
00249
00250 void Automation::insert_track(Automation *automation,
00251 int64_t start_unit,
00252 int64_t length_units,
00253 int replace_default)
00254 {
00255 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00256 {
00257 if(autos[i] && automation->autos[i])
00258 {
00259 autos[i]->insert_track(automation->autos[i],
00260 start_unit,
00261 length_units,
00262 replace_default);
00263 }
00264 }
00265
00266
00267 }
00268
00269 void Automation::resample(double old_rate, double new_rate)
00270 {
00271
00272 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00273 {
00274 if(autos[i]) autos[i]->resample(old_rate, new_rate);
00275 }
00276 }
00277
00278
00279
00280 int Automation::direct_copy_possible(int64_t start, int direction)
00281 {
00282 return 1;
00283 }
00284
00285
00286
00287
00288 void Automation::get_projector(float *x,
00289 float *y,
00290 float *z,
00291 int64_t position,
00292 int direction)
00293 {
00294 }
00295
00296 void Automation::get_camera(float *x,
00297 float *y,
00298 float *z,
00299 int64_t position,
00300 int direction)
00301 {
00302 }
00303
00304
00305
00306
00307 int64_t Automation::get_length()
00308 {
00309 int64_t length = 0;
00310 int64_t total_length = 0;
00311
00312 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00313 {
00314 if(autos[i])
00315 {
00316 length = autos[i]->get_length();
00317 if(length > total_length) total_length = length;
00318 }
00319 }
00320
00321
00322 return total_length;
00323 }
00324
00325 void Automation::get_extents(float *min,
00326 float *max,
00327 int *coords_undefined,
00328 int64_t unit_start,
00329 int64_t unit_end,
00330 int autogrouptype)
00331 {
00332 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00333 {
00334 if(autos[i] && edl->session->auto_conf->autos[i])
00335 {
00336 if (autos[i]->autogrouptype == autogrouptype)
00337 autos[i]->get_extents(min, max, coords_undefined, unit_start, unit_end);
00338 }
00339 }
00340 }
00341
00342
00343 void Automation::dump()
00344 {
00345 printf(" Automation: %p\n", this);
00346
00347
00348 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00349 {
00350 if(autos[i])
00351 {
00352 printf(" %s %p\n", xml_titles[i], autos[i]);
00353 autos[i]->dump();
00354 }
00355 }
00356
00357 }